From cd16208dd777f2a002f6a66b472c6050268c03ad Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Sat, 26 Aug 2023 11:01:14 -0400 Subject: [PATCH 1/2] Move dateQuery to util.ts --- client/src/state.ts | 11 +---------- client/src/util.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/src/state.ts b/client/src/state.ts index b0e94fa..3f13eb9 100644 --- a/client/src/state.ts +++ b/client/src/state.ts @@ -2,7 +2,7 @@ import { reactive } from "vue" import { Track } from "./track" import { Tick } from './ticks' import { error } from "./error" -import { getCookie } from "./util"; +import { getCookie, dateQuery } from "./util"; import router from './router' enum State { @@ -11,15 +11,6 @@ enum State { Fetched, } -function dateQuery(date: Date): URLSearchParams { - let query = new URLSearchParams() - query.set("year", date.getUTCFullYear().toString()) - query.set("month", (date.getUTCMonth() + 1).toString()) - // good thing I still had this ^^^^^^^^^^^^^^ in mind when I wrote this 😬 - query.set("day", date.getUTCDate().toString()) - return query -} - interface LoggedInUser { name: string } diff --git a/client/src/util.ts b/client/src/util.ts index ebbda1c..023079c 100644 --- a/client/src/util.ts +++ b/client/src/util.ts @@ -5,4 +5,13 @@ export function getCookie(key: string): string | null { if(end === -1) end = undefined return document.cookie.substring(start + key.length + 1, end) -} \ No newline at end of file +} + +export function dateQuery(date: Date): URLSearchParams { + let query = new URLSearchParams() + query.set("year", date.getUTCFullYear().toString()) + query.set("month", (date.getUTCMonth() + 1).toString()) + // good thing I still had this ^^^^^^^^^^^^^^ in mind when I wrote this 😬 + query.set("day", date.getUTCDate().toString()) + return query +} From 89b018098985ee5ab51748357437822bebe0beb7 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Sat, 26 Aug 2023 11:05:15 -0400 Subject: [PATCH 2/2] Move API calls from state to Track methods --- client/src/components/NavBar.vue | 1 - client/src/components/TickComponent.vue | 4 +- client/src/components/TrackIcon.vue | 4 +- client/src/state.ts | 32 +------------ client/src/track.ts | 61 +++++++++++++++++++++++++ client/src/views/NewTrackView.vue | 3 +- 6 files changed, 67 insertions(+), 38 deletions(-) diff --git a/client/src/components/NavBar.vue b/client/src/components/NavBar.vue index 9a09c57..145a817 100644 --- a/client/src/components/NavBar.vue +++ b/client/src/components/NavBar.vue @@ -1,6 +1,5 @@ diff --git a/client/src/components/TickComponent.vue b/client/src/components/TickComponent.vue index 8b1d863..47d57e0 100644 --- a/client/src/components/TickComponent.vue +++ b/client/src/components/TickComponent.vue @@ -15,8 +15,8 @@ const className = computed(() => isSet.value ? "button is-rounded is-info" : "bu async function toggle() { if (isSet.value) { - await state.taskMarkedIncomplete(props.track, props.date) + await props.track.markIncomplete(props.date) } else - await state.taskCompleted(props.track, props.date) + await props.track.markComplete(props.date) } \ No newline at end of file diff --git a/client/src/components/TrackIcon.vue b/client/src/components/TrackIcon.vue index 273987e..e5aeabf 100644 --- a/client/src/components/TrackIcon.vue +++ b/client/src/components/TrackIcon.vue @@ -1,12 +1,12 @@