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}
-
-
-
- | Datum |
- Arbeitsstunden |
- Aktionen |
-
-
-
- {#each params.records as record}
+ {#if params.isLoading === true}
+ Loading...
+ {:else}
+
+
+
+
- | {record.workingDay} |
- {record.workingTime} |
-
-
- |
+ Datum |
+ Arbeitsstunden |
+ Aktionen |
- {/each}
-
-
+
+
+ {#each params.records as record}
+
+ | {record.workingDay} |
+ {record.workingTime} |
+
+
+ |
+
+ {/each}
+
+
+ {/if}
{:else}
@@ -127,17 +168,25 @@