fix: validation of allowing teachers create compliance courses without setting deadline (#778)
* Fixed Validation of allowing teachers create compliance courses without setting deadline * greptile highlightCertificateSettings decraration suggestion * greptile multiple error bar showing fix suggestion * organization race condition * Delete screenshots/Screenshot 2026-07-22 at 11.52.00 AM.png * deleted unwanted files * code review fixes * Changed AttentionHightlight component to work with just one parameter created fixed Route Enums, Paths and Sections for * Kebab-case naming fix * Changes for code comments --------- Co-authored-by: Rotimi Best <[email protected]>
This commit is contained in:
co-authored by
Rotimi Best
parent
05936e788d
commit
60056a6236
@@ -17,6 +17,8 @@
|
||||
import { profile } from '$lib/utils/store/user';
|
||||
import { t } from '$lib/utils/functions/translations';
|
||||
import { setupProgressApi } from '$features/setup/api/setup-progress.svelte';
|
||||
import { ROUTE_NAME, ROUTE_SECTIONS } from '$lib/routing/routes';
|
||||
import { goAndHighlight } from '$lib/routing/go-and-highlight';
|
||||
|
||||
let { data } = $props();
|
||||
|
||||
@@ -96,7 +98,9 @@
|
||||
const courses = setupProgressApi.progress.courses || [];
|
||||
const courseId = courses[0]?.id;
|
||||
if (courseId) {
|
||||
goto(`/courses/${courseId}/settings`);
|
||||
goAndHighlight(ROUTE_NAME.COURSE_SETTINGS, ROUTE_SECTIONS[ROUTE_NAME.COURSE_SETTINGS].PUBLISH, {
|
||||
id: courseId
|
||||
});
|
||||
}
|
||||
} else {
|
||||
snackbar.info('setup.info_course');
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
let enrollmentSucceeded = $state(false);
|
||||
let verificationEmailSent = $state(false);
|
||||
let enrolledPendingVerification = $state(false);
|
||||
let enrollmentError = $state<string | null>(null);
|
||||
|
||||
const session = authClient.useSession();
|
||||
const sessionReady = $derived(!$session.isPending && !$session.isRefetching);
|
||||
@@ -110,6 +111,7 @@
|
||||
|
||||
enrollmentInFlight = true;
|
||||
loading = true;
|
||||
enrollmentError = null;
|
||||
|
||||
let navigatingAway = false;
|
||||
|
||||
@@ -118,7 +120,7 @@
|
||||
const result = await courseApi.enroll(data.course.id, body);
|
||||
|
||||
if (!result?.data) {
|
||||
snackbar.error('snackbar.invite.failed_join');
|
||||
enrollmentError = t.get('snackbar.invite.failed_join');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -147,6 +149,10 @@
|
||||
|
||||
navigatingAway = true;
|
||||
await goto(resolve(getStudentCourseContinuePath(data.course.id), {}));
|
||||
} catch (error) {
|
||||
console.error('[enroll] unexpected error during enrollment:', error);
|
||||
enrollmentError = t.get('snackbar.invite.failed_join');
|
||||
snackbar.error('snackbar.invite.failed_join');
|
||||
} finally {
|
||||
enrollmentInFlight = false;
|
||||
if (!navigatingAway) {
|
||||
@@ -186,7 +192,15 @@
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (!sessionReady || !isLoggedIn || !canJoinCourse || enrollmentInFlight || loading || enrollmentSucceeded) {
|
||||
if (
|
||||
!sessionReady ||
|
||||
!isLoggedIn ||
|
||||
!canJoinCourse ||
|
||||
enrollmentInFlight ||
|
||||
loading ||
|
||||
enrollmentSucceeded ||
|
||||
enrollmentError
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -245,6 +259,8 @@
|
||||
>
|
||||
{$t('course.navItem.landing_page.enroll_page.back_to_course')}
|
||||
</a>
|
||||
{:else if enrollmentError}
|
||||
<p class="mt-3 text-center text-sm text-red-500">{enrollmentError}</p>
|
||||
{:else if !canJoinCourse}
|
||||
<p class="mt-3 text-center text-sm text-red-500">{getBlockedMessage()}</p>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user