From 331d25a21f9e7be0f0329aeab3e2ab34acc13952 Mon Sep 17 00:00:00 2001 From: EMcNugget Date: Mon, 11 Nov 2024 00:02:00 -0600 Subject: [PATCH] Added student side logic to student page --- .../dash/sessions/[sessionId]/+page.svelte | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/routes/(authed)/dash/sessions/[sessionId]/+page.svelte b/src/routes/(authed)/dash/sessions/[sessionId]/+page.svelte index a307db9..a2f7712 100644 --- a/src/routes/(authed)/dash/sessions/[sessionId]/+page.svelte +++ b/src/routes/(authed)/dash/sessions/[sessionId]/+page.svelte @@ -63,6 +63,18 @@ await invalidateAll(); rescheduleOpen = false; } + + function check_time(t: string) { + const start_time = DateTime.fromISO(t); + const now = DateTime.now(); + const interval = start_time.diff(now, 'hours'); + + if (interval.hours < 24) { + return false; + } else { + return true; + } + }
@@ -91,8 +103,8 @@ {data.sessionInfo.sessionType.category} - {data.sessionInfo.sessionType.name}

Duration: {data.sessionInfo.sessionType.length} minutes

- {#if data.isMentor} -

Mentor/Staff Actions

+ {#if data.isMentor || check_time(data.sessionInfo.session.start)} +

Session Actions

+ {:else} +

+ You cannot cancel or reschedule this session as it is less than 24 hours away. Please contact + your instructor if you need to cancel or reschedule. +

{/if}
@@ -130,7 +147,11 @@

- It is your responsibility to inform the student of the cancellation. + {#if data.isMentor} + It is your responsibility to inform the student of the cancellation. + {:else} + It is your responsibility to inform the instructor of the cancellation. + {/if}

@@ -169,7 +190,11 @@

- It is your responsibility to inform the student of the rescheduling. + {#if data.isMentor} + It is your responsibility to inform the student of the rescheduling. + {:else} + It is your responsibility to inform the instructor of the rescheduling. + {/if}