mirror of
https://github.com/donpat1to/Schichtenplaner.git
synced 2025-11-30 22:45:46 +01:00
moved range to slot for shift planing
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// frontend/src/pages/ShiftTemplates/ShiftTemplateEditor.tsx
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { TemplateShiftSlot, TemplateShift, TemplateShiftTimeRange, DEFAULT_DAYS } from '../../types/shiftTemplate';
|
||||
import { TemplateShiftSlot, TemplateShift, TemplateShiftTimeSlot, DEFAULT_DAYS } from '../../types/shiftTemplate';
|
||||
import { shiftTemplateService } from '../../services/shiftTemplateService';
|
||||
import ShiftDayEditor from './components/ShiftDayEditor';
|
||||
import DefaultTemplateView from './components/DefaultTemplateView';
|
||||
@@ -14,7 +14,7 @@ interface ExtendedTemplateShift extends Omit<TemplateShiftSlot, 'id'> {
|
||||
|
||||
const defaultShift: ExtendedTemplateShift = {
|
||||
dayOfWeek: 1, // Montag
|
||||
timeRange: { id: '', name: '', startTime: '', endTime: '' },
|
||||
timeSlot: { id: '', name: '', startTime: '', endTime: '' },
|
||||
requiredEmployees: 1,
|
||||
color: '#3498db'
|
||||
};
|
||||
@@ -85,7 +85,7 @@ const ShiftTemplateEditor: React.FC = () => {
|
||||
...defaultShift,
|
||||
id: Date.now().toString(),
|
||||
dayOfWeek,
|
||||
timeRange: { ...defaultShift.timeRange, id: Date.now().toString() },
|
||||
timeSlot: { ...defaultShift.timeSlot, id: Date.now().toString() },
|
||||
requiredEmployees: defaultShift.requiredEmployees,
|
||||
color: defaultShift.color
|
||||
};
|
||||
|
||||
@@ -38,9 +38,9 @@ const DefaultTemplateView: React.FC<DefaultTemplateViewProps> = ({ template }) =
|
||||
<div className={styles.shiftsContainer}>
|
||||
{shiftsByDay[dayIndex]?.map(shift => (
|
||||
<div key={shift.id} className={styles.shiftCard}>
|
||||
<h4>{shift.timeRange.name}</h4>
|
||||
<h4>{shift.timeSlot.name}</h4>
|
||||
<p>
|
||||
{formatTime(shift.timeRange.startTime)} - {formatTime(shift.timeRange.endTime)}
|
||||
{formatTime(shift.timeSlot.startTime)} - {formatTime(shift.timeSlot.endTime)}
|
||||
</p>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -55,8 +55,8 @@ const ShiftDayEditor: React.FC<ShiftDayEditorProps> = ({
|
||||
<div className={styles.formGroup}>
|
||||
<input
|
||||
type="text"
|
||||
value={shift.timeRange.name}
|
||||
onChange={(e) => onUpdateShift(shift.id, { timeRange: { ...shift.timeRange, name: e.target.value } })}
|
||||
value={shift.timeSlot.name}
|
||||
onChange={(e) => onUpdateShift(shift.id, { timeSlot: { ...shift.timeSlot, name: e.target.value } })}
|
||||
placeholder="Schichtname"
|
||||
/>
|
||||
</div>
|
||||
@@ -66,8 +66,8 @@ const ShiftDayEditor: React.FC<ShiftDayEditorProps> = ({
|
||||
<label>Start</label>
|
||||
<input
|
||||
type="time"
|
||||
value={shift.timeRange.startTime}
|
||||
onChange={(e) => onUpdateShift(shift.id, { timeRange: { ...shift.timeRange, startTime: e.target.value } })}
|
||||
value={shift.timeSlot.startTime}
|
||||
onChange={(e) => onUpdateShift(shift.id, { timeSlot: { ...shift.timeSlot, startTime: e.target.value } })}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -75,8 +75,8 @@ const ShiftDayEditor: React.FC<ShiftDayEditorProps> = ({
|
||||
<label>Ende</label>
|
||||
<input
|
||||
type="time"
|
||||
value={shift.timeRange.endTime}
|
||||
onChange={(e) => onUpdateShift(shift.id, { timeRange: { ...shift.timeRange, endTime: e.target.value } })}
|
||||
value={shift.timeSlot.endTime}
|
||||
onChange={(e) => onUpdateShift(shift.id, { timeSlot: { ...shift.timeSlot, endTime: e.target.value } })}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,19 +13,19 @@ export interface TemplateShiftSlot {
|
||||
id: string;
|
||||
templateId?: string;
|
||||
dayOfWeek: number;
|
||||
timeRange: TemplateShiftTimeRange;
|
||||
timeSlot: TemplateShiftTimeSlot;
|
||||
requiredEmployees: number;
|
||||
color?: string;
|
||||
}
|
||||
|
||||
export interface TemplateShiftTimeRange {
|
||||
export interface TemplateShiftTimeSlot {
|
||||
id: string;
|
||||
name: string; // e.g., "Frühschicht", "Spätschicht"
|
||||
startTime: string;
|
||||
endTime: string;
|
||||
}
|
||||
|
||||
export const DEFAULT_TIME_SLOTS: TemplateShiftTimeRange[] = [
|
||||
export const DEFAULT_TIME_SLOTS: TemplateShiftTimeSlot[] = [
|
||||
{ id: 'morning', name: 'Vormittag', startTime: '08:00', endTime: '12:00' },
|
||||
{ id: 'afternoon', name: 'Nachmittag', startTime: '11:30', endTime: '15:30' },
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user