From fd6f6f169f9ff9a1247228fb34dc9654a9584915 Mon Sep 17 00:00:00 2001
From: Zach Berwaldt <zberwaldt@tutamail.com>
Date: Thu, 21 Mar 2024 11:23:42 -0400
Subject: fix bugs, redo layout, reorg.

---
 fe/src/lib/forms/AddForm.svelte | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

(limited to 'fe/src/lib/forms/AddForm.svelte')

diff --git a/fe/src/lib/forms/AddForm.svelte b/fe/src/lib/forms/AddForm.svelte
index f85cce6..bbc8356 100644
--- a/fe/src/lib/forms/AddForm.svelte
+++ b/fe/src/lib/forms/AddForm.svelte
@@ -11,21 +11,10 @@
     const statistic: Statistic = newStatistic();
 
     function newStatistic(): Statistic {
-        let now = new Date(),
-            month,
-            day,
-            year;
-
-        month = `${now.getMonth() + 1}`;
-        day = `${now.getDate()}`;
-        year = now.getFullYear();
-        if (month.length < 2) month = "0" + month;
-        if (day.length < 2) day = "0" + day;
-
-        const date = [year, month, day].join("-");
+        let date = new Date().toString();
 
         return {
-            user_id: $user!.uuid,
+            user_id: $user!.id,
             date,
             quantity: 1
         };
@@ -37,7 +26,7 @@
 
     async function handleSubmitStat()
     {
-        const { date, quantity } = statistic;
+        const { user_id, date, quantity } = statistic;
         await fetch(apiURL("stats"), {
             method: "POST",
             headers: {
@@ -45,7 +34,7 @@
             },
             body: JSON.stringify({
                 date: new Date(date),
-                user_id: 2,
+                user_id,
                 quantity
             })
         });
@@ -54,12 +43,12 @@
 
 </script>
 
-<dialog {open} on:submit={handleSubmitStat}>
+<dialog id="addForm" {open} on:submit={handleSubmitStat}>
     <h2>Add Water</h2>
     <form method="dialog">
         <div class="form input group">
             <label for="date">Date:</label>
-            <input bind:value={statistic.date} id="date" name="date" type="date" />
+            <input bind:value={statistic.date} id="date" name="date" type="datetime-local" />
         </div>
         <div class="form input group">
             <label for="quantity">Quantity:</label>
@@ -75,4 +64,4 @@
         <button on:click={closeDialog}>Cancel</button>
         <button type="submit">Submit</button>
     </form>
-</dialog>
\ No newline at end of file
+</dialog>
-- 
cgit v1.1

