fix(dashboard): redirect to course start after auto-enroll (#741)

* fix(dashboard): redirect to course start after auto-enroll

After successful enrollment on the org-site enroll page, verified users
were always sent to /lms because resolvePostEnrollRedirect was hardcoded.
Restore the API redirectTo target (/courses/:id/lessons?next=true) so
students land on their first lesson, with /course/:slug as fallback.

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* fix(dashboard): match LMS continue path after auto-enroll

Use the same student course continue URL as the LMS home page
(/courses/:id/lessons?next=true) via a shared helper, and navigate with
goto instead of a hard reload or org-site /course/:slug fallback.

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

---------
Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>
This commit is contained in:
Rotimi Best
2026-07-12 22:06:40 +01:00
committed by GitHub
co-authored by Rotimi Best
parent 8bed9f6b4e
commit bce0f582ce
4 changed files with 9 additions and 7 deletions
@@ -0,0 +1,3 @@
export function getStudentCourseContinuePath(courseId: string): string {
return `/courses/${courseId}/lessons?next=true`;
}
@@ -13,10 +13,11 @@
getStudentCourseComplianceStatusVariant,
getStudentCourseProgressPercent
} from '$features/course/utils/compliance-utils';
import { getStudentCourseContinuePath } from '$features/course/utils/student-course-navigation';
const gotoCourse = (id: string | undefined) => {
if (!id) return;
goto(`/courses/${id}/lessons?next=true`);
goto(getStudentCourseContinuePath(id));
};
let highlightedCourses = $derived.by(() => {
@@ -35,6 +35,7 @@
getStudentCourseProgressPercent,
isStudentCourseComplete
} from '$features/course/utils/compliance-utils';
import { getStudentCourseContinuePath } from '$features/course/utils/student-course-navigation';
type EnrolledCourse = (typeof coursesApi.enrolledCourses)[number];
@@ -147,7 +148,7 @@
function gotoCourse(id: string | undefined) {
if (!id) return;
goto(`/courses/${id}/lessons?next=true`);
goto(getStudentCourseContinuePath(id));
}
function gotoCourseCertificates(id: string | undefined) {
@@ -13,6 +13,7 @@
import { resolve } from '$app/paths';
import { authClient } from '$lib/utils/services/auth/client';
import { appInitApi } from '$features/app/init.svelte';
import { getStudentCourseContinuePath } from '$features/course/utils/student-course-navigation';
let { data } = $props();
@@ -28,10 +29,6 @@
const isLoggedIn = $derived(sessionReady && Boolean(sessionUser));
const isEmailVerified = $derived(Boolean($profile.isEmailVerified || sessionUser?.emailVerified));
function resolvePostEnrollRedirect(): string {
return '/lms';
}
async function sendVerificationEmail() {
const email = $profile.email || sessionUser?.email;
if (!email) {
@@ -141,7 +138,7 @@
}
navigatingAway = true;
window.location.href = resolvePostEnrollRedirect();
await goto(resolve(getStudentCourseContinuePath(data.course.id), {}));
} finally {
enrollmentInFlight = false;
if (!navigatingAway) {