Skip to content

Commit

Permalink
Fixed student cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
EMcNugget committed Dec 22, 2024
1 parent 634b04d commit eb2458c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/routes/(authed)/schedule/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];
Expand Down Expand Up @@ -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 (
Expand All @@ -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()));
}
};

0 comments on commit eb2458c

Please sign in to comment.