Fallback edit lesson detail when missing

If /sub-module-lessons/:id returns not found, load the edit form from the linked question set instead.

Made-with: Cursor
This commit is contained in:
Yared Yemane 2026-04-16 06:31:27 -07:00
parent 5ee897cfad
commit f6344c19f9

View File

@ -1065,8 +1065,15 @@ export function HumanLanguagePage() {
}) })
try { try {
let detail: SubModuleLessonDetail | null = let detail: SubModuleLessonDetail | null = null
(await getSubModuleLessonById(lesson.id, { cacheBust: true })).data?.data ?? null
try {
detail = (await getSubModuleLessonById(lesson.id, { cacheBust: true })).data?.data ?? null
} catch {
// If the lesson row isn't available yet, fall back to the question set detail below.
detail = null
}
if (!detail && lesson.question_set_id > 0) { if (!detail && lesson.question_set_id > 0) {
const setDetail = (await getQuestionSetById(lesson.question_set_id)).data?.data const setDetail = (await getQuestionSetById(lesson.question_set_id)).data?.data
detail = setDetail detail = setDetail