From eb2458cf54037b32e5d733fc5787b74e724b385a Mon Sep 17 00:00:00 2001 From: EMcNugget Date: Tue, 10 Dec 2024 22:48:34 -0600 Subject: [PATCH] Fixed student cancel --- src/routes/(authed)/schedule/+page.server.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/routes/(authed)/schedule/+page.server.ts b/src/routes/(authed)/schedule/+page.server.ts index 24294b5..609beb8 100644 --- a/src/routes/(authed)/schedule/+page.server.ts +++ b/src/routes/(authed)/schedule/+page.server.ts @@ -56,7 +56,8 @@ function slottificate( const availability: MentorAvailability | null = JSON.parse(mentor.mentorAvailability); if (!availability) continue; - const mentorsOtherSessions: (typeof sessions.$inferSelect)[] = sessionsByMentor[mentor.id] || []; + const mentorsOtherSessions: (typeof sessions.$inferSelect)[] = + sessionsByMentor[mentor.id] || []; const availablePeriodsMentorsTime: Interval[] = []; const unavailablePeriodsMentorsTime: Interval[] = []; @@ -339,13 +340,14 @@ export const actions: Actions = { }, cancel: async ({ cookies, request }) => { const { user } = (await loadUserData(cookies))!; + const formData = await request.formData(); const sessionList = await db .select() .from(sessions) .leftJoin(sessionTypes, eq(sessionTypes.id, sessions.type)) .leftJoin(mentors, eq(mentors.id, sessions.mentor)) .leftJoin(students, eq(students.id, sessions.student)) - .where(eq(sessions.id, request.sessionId)); + .where(eq(sessions.id, formData.get('sessionId')!.toString())); const sessionAndFriends = sessionList[0]; if ( @@ -355,8 +357,6 @@ export const actions: Actions = { redirect(307, '/schedule'); } - const formData = await request.formData(); - await db.delete(sessions).where(eq(sessions.id, formData.get('sessionId')!.toString())); } };