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