Skip to content

Commit

Permalink
Fixed POST
Browse files Browse the repository at this point in the history
  • Loading branch information
EMcNugget committed Nov 14, 2024
1 parent b537ba9 commit 2259332
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/routes/(authed)/schedule/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ export const load: PageServerLoad = async ({ cookies, url }) => {
? url.searchParams.get('type')
: null;

const orginalSessionId = url.searchParams.get('sessionId')!;

return {
user,
role: roleString(roleOf(user)),
Expand All @@ -196,7 +198,8 @@ export const load: PageServerLoad = async ({ cookies, url }) => {
isDeveloper: roleOf(user) >= ROLE_DEVELOPER,
sessionTypes: sTypes,
slotData,
originalSessionType
originalSessionType,
orginalSessionId
};
};

Expand Down Expand Up @@ -280,8 +283,7 @@ export const actions: Actions = {
mentor: slotObj.mentor,
student: user.id,
start: start.toISO(),
type: requestedType,
timezone
type: requestedType
});

if (reschedule) {
Expand Down
6 changes: 5 additions & 1 deletion src/routes/(authed)/schedule/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
let bookingState: 'success' | 'fail' | 'loading' = $state('loading');
const bookingUrl = data.originalSessionType
? `?sessionId=${data.originalSessionId}&reschedule=true&type=${data.originalSessionType}`
: '?';
async function book() {
if (!timeslot) return;
Expand All @@ -80,7 +84,7 @@
data.set('type', sessionType!);
data.set('timezone', timezone);
let r = await fetch('?', {
let r = await fetch(bookingUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
Expand Down

0 comments on commit 2259332

Please sign in to comment.