From f7f3b3927b7aa81ccbbd072d97aeb05f6a502a79 Mon Sep 17 00:00:00 2001 From: Paul Sanders Date: Sun, 13 Aug 2023 11:12:56 -0400 Subject: [PATCH 1/2] Make it possible to mark a goal complete --- .../src/routes/edit-goal/[id]/+page.svelte | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/frontend/src/routes/edit-goal/[id]/+page.svelte b/frontend/src/routes/edit-goal/[id]/+page.svelte index 7ae8a60a..7860cf14 100644 --- a/frontend/src/routes/edit-goal/[id]/+page.svelte +++ b/frontend/src/routes/edit-goal/[id]/+page.svelte @@ -1,5 +1,6 @@
@@ -559,6 +568,19 @@
+
+
+ +
+
Date: Sun, 13 Aug 2023 13:12:55 -0400 Subject: [PATCH 2/2] Fix checks --- frontend/src/routes/edit-goal/[id]/+page.svelte | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/routes/edit-goal/[id]/+page.svelte b/frontend/src/routes/edit-goal/[id]/+page.svelte index 7860cf14..c8222d21 100644 --- a/frontend/src/routes/edit-goal/[id]/+page.svelte +++ b/frontend/src/routes/edit-goal/[id]/+page.svelte @@ -2,6 +2,7 @@ import { goto } from '$app/navigation'; import { onMount } from 'svelte'; import type { DaysOfWeekInput, GoalInfo, GoalOutput, GoalSuggestionCreate } from '$lib/generated'; + import { GoalStatus } from '$lib/generated'; import type { PageData } from './$types'; import DaysOfWeekSelector from '$lib/components/DaysOfWeekSelector.svelte'; import Message from '$lib/components/Message.svelte'; @@ -56,6 +57,8 @@ setToast('Goal was not found.'); goto('/'); return; + } else { + goal.status = isComplete ? GoalStatus.COMPLETED : GoalStatus.ACTIVE; } if (!goal.goal) { @@ -66,9 +69,6 @@ return; } - goal.status = isComplete ? 'completed' : 'active'; - console.log(goal.status); - try { const response = await updateGoal(goal); goals.set(response); @@ -132,7 +132,9 @@ } onMount(() => { - isComplete = goal.status === 'completed' ? true : false; + if (goal !== undefined) { + isComplete = goal.status === GoalStatus.COMPLETED ? true : false; + } });