From 98e939fce034c8b5379720c234b15e3702c319f0 Mon Sep 17 00:00:00 2001 From: Kevin Wu Date: Mon, 20 May 2024 16:58:53 -0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20convert=20availability=20st?= =?UTF-8?q?ring=20to=20binary=20rep=20(#104)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/utils/availability.ts | 4 ++-- src/routes/availability/[slug]/+page.server.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/utils/availability.ts b/src/lib/utils/availability.ts index a66f5506..5b18d64c 100644 --- a/src/lib/utils/availability.ts +++ b/src/lib/utils/availability.ts @@ -21,7 +21,7 @@ export async function getGuestAvailability(guestSession: GuestSession) { new ZotDate( new Date(availability.day), false, - JSON.parse("[" + availability.availability_string + "]"), + Array.from(availability.availability_string).map((char) => char === "1"), ), ); } @@ -33,7 +33,7 @@ export const getUserAvailability = (data: PageData) => { new ZotDate( new Date(availability.day), false, - JSON.parse("[" + availability.availability_string + "]"), + Array.from(availability.availability_string).map((char) => char === "1"), ), ); } diff --git a/src/routes/availability/[slug]/+page.server.ts b/src/routes/availability/[slug]/+page.server.ts index 5f30ae6e..a2845f22 100644 --- a/src/routes/availability/[slug]/+page.server.ts +++ b/src/routes/availability/[slug]/+page.server.ts @@ -81,7 +81,7 @@ async function save({ request, locals }: { request: Request; locals: App.Locals day: new Date(date.day).toISOString(), member_id: memberId, meeting_day: dbMeetingDates[index].id as string, // Type-cast since id is guaranteed if a meetingDate exists - availability_string: date.availability.toString(), + availability_string: date.availability.map((bool) => (bool ? "1" : "0")).join(""), })); await db.transaction(async (tx) => {