feat(employees): default minGapDays to 14, robust ID fallback
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
294de5276b
commit
6736021af1
1 file changed
+17
-2
+17
-2
@@ -1,3 +1,18 @@
|
||||
function generateId() {
|
||||
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
||||
return crypto.randomUUID();
|
||||
}
|
||||
if (typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function') {
|
||||
const b = new Uint8Array(16);
|
||||
crypto.getRandomValues(b);
|
||||
b[6] = (b[6] & 0x0f) | 0x40;
|
||||
b[8] = (b[8] & 0x3f) | 0x80;
|
||||
const h = [...b].map(x => x.toString(16).padStart(2, '0'));
|
||||
return `${h.slice(0,4).join('')}-${h.slice(4,6).join('')}-${h.slice(6,8).join('')}-${h.slice(8,10).join('')}-${h.slice(10,16).join('')}`;
|
||||
}
|
||||
return Date.now().toString(36) + Math.random().toString(36).slice(2, 10);
|
||||
}
|
||||
|
||||
function parseSettings(raw) {
|
||||
const n = raw?.moderatorsPerDay;
|
||||
const valid = Number.isInteger(n) && n >= 1 && n <= 5;
|
||||
@@ -40,14 +55,14 @@ export function createEmployee(name) {
|
||||
const trimmed = (name ?? '').trim();
|
||||
if (!trimmed) throw new Error('Mitarbeitername darf nicht leer sein');
|
||||
return {
|
||||
id: crypto.randomUUID(),
|
||||
id: generateId(),
|
||||
name: trimmed,
|
||||
constraints: {
|
||||
neverDays: [],
|
||||
lowPriorityDays: [],
|
||||
onlyDays: [],
|
||||
maxPerMonth: null,
|
||||
minGapDays: 0,
|
||||
minGapDays: 14,
|
||||
vacations: []
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user