From 834721f61aaee7c2e269cb1df70a973289a73852 Mon Sep 17 00:00:00 2001
From: ivarlovlie <git@ivarlovlie.no>
Date: Mon, 5 Dec 2022 15:03:11 +0900
Subject: refactor: Small changes

---
 .../(main)/(app)/projects/create/+page.svelte      | 32 +++++++++++++---------
 1 file changed, 19 insertions(+), 13 deletions(-)

(limited to 'code/app/src/routes/(main)/(app)/projects/create/+page.svelte')

diff --git a/code/app/src/routes/(main)/(app)/projects/create/+page.svelte b/code/app/src/routes/(main)/(app)/projects/create/+page.svelte
index 2b5e7bc..1741506 100644
--- a/code/app/src/routes/(main)/(app)/projects/create/+page.svelte
+++ b/code/app/src/routes/(main)/(app)/projects/create/+page.svelte
@@ -4,42 +4,48 @@
     import type { ProjectMember } from "$lib/models/projects/ProjectMember";
     import LL from "$lib/i18n/i18n-svelte";
 
-    const formFields = {
+    const formData = {
         name: {
             value: "",
-            error: "",
+            errors: [],
         },
         description: {
             value: "",
-            error: "",
+            errors: [],
         },
         start: {
             value: "",
-            error: "",
+            errors: [],
         },
         stop: {
             value: "",
-            error: "",
+            errors: [],
         },
         members: {
             value: [] as Array<ProjectMember>,
-            error: "",
+            errors: [],
         },
-        clear() {},
     };
-    async function submit(event: Event) {
+
+    const formError = {
+        title: "",
+        subtitle: "",
+    };
+
+    async function submit_form_async() {
         alert("Submitted");
     }
+
     const { data: members } = useSWR("projectMembers");
 </script>
 
 <h1>Create a new project</h1>
-<form on:submit|preventDefault={submit} class="max-w-md flex flex-col gap-2">
-    <Input label="Name" bind:value={formFields.name.value} errorText={formFields.name.error} required />
-    <TextArea label="Description" bind:value={formFields.description.value} errorText={formFields.description.error} />
+<form on:submit|preventDefault={submit_form_async} class="max-w-md flex flex-col gap-2">
+    <Input label="Name" bind:value={formData.name.value} errors={formData.name.errors} required />
+    <TextArea label="Description" bind:value={formData.description.value} errors={formData.description.errors} />
     <section class="grid grid-flow-row sm:grid-flow-col gap-2">
-        <Input type="date" label="Start" bind:value={formFields.start.value} errorText={formFields.start.error} />
-        <Input type="date" label="Stop" bind:value={formFields.stop.value} errorText={formFields.stop.error} />
+        <Input type="date" label="Start" bind:value={formData.start.value} errors={formData.start.errors} />
+        <Input type="date" label="Stop" bind:value={formData.stop.value} errors={formData.stop.errors} />
     </section>
     <Combobox options={$members} label={$LL.app.members()}>
         <svelte:fragment slot="no-records">
-- 
cgit v1.3

