feat(data): settings.moderatorsPerDay in load/save JSON
This commit is contained in:
1 parent
7bda92a0a3
commit
a825a63961
2 files changed
+58
-3
No files matched your search
+10
-2
@@ -1,3 +1,9 @@
|
||||
function parseSettings(raw) {
|
||||
const n = raw?.moderatorsPerDay;
|
||||
const valid = Number.isInteger(n) && n >= 1 && n <= 5;
|
||||
return { moderatorsPerDay: valid ? n : 1 };
|
||||
}
|
||||
|
||||
export function loadFromJSON(json) {
|
||||
let parsed;
|
||||
try {
|
||||
@@ -16,7 +22,8 @@ export function loadFromJSON(json) {
|
||||
companyClosures: Array.isArray(parsed.calendar.companyClosures) ? parsed.calendar.companyClosures : []
|
||||
}
|
||||
: { holidays: [], companyClosures: [] },
|
||||
history: Array.isArray(parsed.history) ? parsed.history : []
|
||||
history: Array.isArray(parsed.history) ? parsed.history : [],
|
||||
settings: parseSettings(parsed.settings)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -24,7 +31,8 @@ export function saveToJSON(state) {
|
||||
return JSON.stringify({
|
||||
employees: state.employees,
|
||||
calendar: state.calendar,
|
||||
history: state.history
|
||||
history: state.history,
|
||||
settings: state.settings
|
||||
}, null, 2);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user