diff --git a/ui/src/routes/WorkingHours.svelte b/ui/src/routes/WorkingHours.svelte index fae987b..137cb2f 100644 --- a/ui/src/routes/WorkingHours.svelte +++ b/ui/src/routes/WorkingHours.svelte @@ -5,7 +5,9 @@ import wrenchIcon from '@iconify-icons/oi/wrench'; import checkIcon from '@iconify-icons/oi/check'; import xIcon from '@iconify-icons/oi/x'; + import documentIcon from '@iconify-icons/oi/document'; let activeRecord = null; + let newRecord = false; params = { title: 'Einträge', records: [], @@ -50,6 +52,34 @@ console.log(err); }); }, + 'add': record => { + console.log(record); + // noinspection JSUnresolvedVariable + fetch(env.API_URL + '/working-hours', { + method: 'POST', + 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(() => { + newRecord = false; + Records.browse(); + }) + .catch(err => { + console.log(err); + }); + }, 'update': (date, record) => { console.log(record); // noinspection JSUnresolvedVariable @@ -71,7 +101,6 @@ } }) .then(() => { - activeRecord = null; Records.browse(); }) .catch(err => { @@ -92,28 +121,40 @@

{title}

- - - - - - - - - - {#each params.records as record} + {#if params.isLoading === true} +

Loading...

+ {:else} + + +
+ +
+ +
DatumArbeitsstundenAktionen
+ - - - + + + - {/each} - -
{record.workingDay}{record.workingTime} - - DatumArbeitsstundenAktionen
+ + + {#each params.records as record} + + {record.workingDay} + {record.workingTime} + + + + + {/each} + + + {/if}
{:else} @@ -127,17 +168,25 @@
- +
- +
- + {#if newRecord === true} + + {:else} + + {/if}