diff --git a/src/lib/components/availability/PersonalAvailability.svelte b/src/lib/components/availability/PersonalAvailability.svelte index c037bf0a..55d48a97 100644 --- a/src/lib/components/availability/PersonalAvailability.svelte +++ b/src/lib/components/availability/PersonalAvailability.svelte @@ -37,7 +37,6 @@ let currentPage = 0; - console.log(currentPage, lastPage); let currentPageAvailability: (ZotDate | null)[]; let selectionState: SelectionStateType | null = null; diff --git a/src/lib/stores/availabilityStores.ts b/src/lib/stores/availabilityStores.ts index c928c8fa..12e64457 100644 --- a/src/lib/stores/availabilityStores.ts +++ b/src/lib/stores/availabilityStores.ts @@ -105,6 +105,6 @@ export const isEditingAvailability = writable(false); export const isStateUnsaved = writable(false); export const guestSession = writable({ - guestName: "yippee", + guestName: "", meetingId: "", }); diff --git a/src/routes/api/availability/+server.ts b/src/routes/api/availability/+server.ts index 266c76f8..27f6137b 100644 --- a/src/routes/api/availability/+server.ts +++ b/src/routes/api/availability/+server.ts @@ -4,7 +4,7 @@ import { and, eq } from "drizzle-orm"; import type { RequestHandler } from "./$types"; import { db } from "$lib/db/drizzle"; -import { availabilities, guests } from "$lib/db/schema"; +import { availabilities, guests, meetingDates } from "$lib/db/schema"; export const POST: RequestHandler = async ({ request }) => { const data = await request.json(); @@ -25,11 +25,17 @@ export const POST: RequestHandler = async ({ request }) => { const availability = await db .select() .from(availabilities) - .where(eq(availabilities.member_id, guest.id)); + .innerJoin(meetingDates, eq(availabilities.meeting_day, meetingDates.id)) + .where( + and( + eq(availabilities.member_id, guest.id), + eq(meetingDates.meeting_id, data.meetingId ?? ""), + ), + ); if (availability.length == 0) { return json([]); } - return json(availability.sort((a, b) => (a.day < b.day ? -1 : 1))); + return json(availability.sort((a, b) => (a.meeting_dates.date > b.meeting_dates.date ? 1 : -1))); }; diff --git a/src/routes/api/availability/saveGuest/+server.ts b/src/routes/api/availability/saveGuest/+server.ts index a5c5bdce..1003eb25 100644 --- a/src/routes/api/availability/saveGuest/+server.ts +++ b/src/routes/api/availability/saveGuest/+server.ts @@ -15,14 +15,11 @@ import type { ZotDate } from "$lib/utils/ZotDate"; export async function POST({ request }: { request: Request }) { const formData = await request.formData(); - console.log(formData.get("availabilityDates")); const availabilityDates: ZotDate[] = JSON.parse( (formData.get("availabilityDates") as string) ?? "[]", ); const meetingId = (formData.get("meetingId") as string) ?? ""; - console.log(availabilityDates, meetingId); - let dbMeetingDates: MeetingDateSelectSchema[] = []; try { diff --git a/src/routes/availability/[slug]/+page.server.ts b/src/routes/availability/[slug]/+page.server.ts index e3d064b3..80d10ec2 100644 --- a/src/routes/availability/[slug]/+page.server.ts +++ b/src/routes/availability/[slug]/+page.server.ts @@ -40,7 +40,7 @@ const getAvailability = async (user: User, meetingId: string | undefined) => { and(eq(availabilities.member_id, user.id), eq(meetingDates.meeting_id, meetingId ?? "")), ); - return availability.map((item) => item.availabilities).sort((a, b) => (a.day < b.day ? -1 : 1)); + return availability.map((item) => item.meeting_dates).sort((a, b) => (a.date < b.date ? -1 : 1)); }; export const actions: Actions = { diff --git a/src/routes/summary/+page.server.ts b/src/routes/summary/+page.server.ts index b538d24d..de45fd5d 100644 --- a/src/routes/summary/+page.server.ts +++ b/src/routes/summary/+page.server.ts @@ -29,8 +29,6 @@ export const load: PageServerLoad = async ({ cookies }) => { .groupBy(meetings.id) .where(eq(availabilities.member_id, user_id)); - console.log(meetingList); - const scheduledMeetings = meetingList.filter((meeting) => meeting.scheduled === true); const scheduled: ScheduledMeeting[] = scheduledMeetings.map((meeting) => { const meetingDate = meeting.startDate?.toLocaleDateString();