diff --git a/ui/src/routes/WorkingHours.svelte b/ui/src/routes/WorkingHours.svelte index 441c32a..fae987b 100644 --- a/ui/src/routes/WorkingHours.svelte +++ b/ui/src/routes/WorkingHours.svelte @@ -22,6 +22,7 @@ return res.json(); }) .then(data => { + activeRecord = null; params.records = data; params.isLoading = false; }) @@ -41,6 +42,37 @@ }) .then(data => { activeRecord = data; + if (date === null) { + Records.browse(); + } + }) + .catch(err => { + console.log(err); + }); + }, + 'update': (date, record) => { + console.log(record); + // noinspection JSUnresolvedVariable + fetch(env.API_URL + '/working-hours/' + date, { + method: 'PUT', + mode: 'no-cors', + cache: 'no-cache', + credentials: 'same-origin', + headers: { + 'Content-Type': 'application/json' + }, + redirect: 'follow', + referrerPolicy: 'no-referrer', + body: JSON.stringify(record) + }) + .then(res => { + if (!res.ok) { + throw new Error('Fail!'); + } + }) + .then(() => { + activeRecord = null; + Records.browse(); }) .catch(err => { console.log(err); @@ -103,8 +135,12 @@
- - + +