Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to mark a goal complete #318

Merged
merged 2 commits into from
Aug 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions frontend/src/routes/edit-goal/[id]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
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';
Expand All @@ -25,6 +27,7 @@
}

let selectAll = false;
let isComplete = false;
let goalError = false;
let specificLocked = false;
let measurableLocked = false;
Expand Down Expand Up @@ -54,6 +57,8 @@
setToast('Goal was not found.');
goto('/');
return;
} else {
goal.status = isComplete ? GoalStatus.COMPLETED : GoalStatus.ACTIVE;
}

if (!goal.goal) {
Expand Down Expand Up @@ -125,6 +130,12 @@

loadingGenerate = false;
}

onMount(() => {
if (goal !== undefined) {
isComplete = goal.status === GoalStatus.COMPLETED ? true : false;
}
});
</script>

<div class="page-fade-in">
Expand Down Expand Up @@ -559,6 +570,19 @@
</figcaption>
</figure>
</div>
<div class="flex flex-col mt-3 items-left">
<div class="flex items-center">
<label for="completed" class="flex items-center cursor-pointer label">
<input
type="checkbox"
class="toggle toggle-primary"
id="completed"
bind:checked={isComplete}
/>
<span class="ml-2 text-md">Completed</span>
</label>
</div>
</div>
<div class="flex flex-col mt-3 items-left">
<button class="btn rounded-xl btn-primary" id="save-goal-button" on:click={handleSave}
>Save Smart Goal</button
Expand Down