Skip to content

Commit

Permalink
feat: ✨ convert availability string to binary rep (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinWu098 authored May 20, 2024
1 parent 8eecf2b commit 98e939f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lib/utils/availability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
);
}
Expand All @@ -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"),
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/availability/[slug]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 98e939f

Please sign in to comment.