Fix stale edit-lesson form after save
Made-with: Cursor
This commit is contained in:
parent
7c3f2192ef
commit
b5946b9da3
|
|
@ -299,8 +299,19 @@ export const deleteSubModule = (subModuleId: number) =>
|
|||
export const getVideosBySubModule = (subModuleId: number) =>
|
||||
http.get<GetSubCourseVideosResponse>(`/course-management/sub-modules/${subModuleId}/videos`)
|
||||
|
||||
export const getSubModuleLessonById = (lessonId: number) =>
|
||||
http.get<GetSubModuleLessonDetailResponse>(`/course-management/sub-module-lessons/${lessonId}`)
|
||||
export const getSubModuleLessonById = (
|
||||
lessonId: number,
|
||||
options?: {
|
||||
/**
|
||||
* Cache-bust the request to avoid serving stale lesson data after edits.
|
||||
* This is intentionally implemented via query string to work with default axios config.
|
||||
*/
|
||||
cacheBust?: boolean
|
||||
},
|
||||
) =>
|
||||
http.get<GetSubModuleLessonDetailResponse>(`/course-management/sub-module-lessons/${lessonId}`, {
|
||||
params: options?.cacheBust ? { _t: Date.now() } : undefined,
|
||||
})
|
||||
|
||||
export const createSubCourseVideo = (data: CreateSubCourseVideoRequest) =>
|
||||
http.post("/course-management/sub-module-videos", {
|
||||
|
|
|
|||
|
|
@ -944,7 +944,7 @@ export function HumanLanguagePage() {
|
|||
})
|
||||
if (skipFetch) return
|
||||
try {
|
||||
const res = await withTimeout(getSubModuleLessonById(lessonId), 12000)
|
||||
const res = await withTimeout(getSubModuleLessonById(lessonId, { cacheBust: forceRefresh }), 12000)
|
||||
const data = res.data?.data
|
||||
if (!data) throw new Error("Missing lesson detail payload")
|
||||
setLessonDetailState((prev) => ({
|
||||
|
|
@ -1022,7 +1022,7 @@ export function HumanLanguagePage() {
|
|||
setLessonDialog({ open: true, lessonId: lesson.id, questionSetId: lesson.question_set_id })
|
||||
setSavingLesson(false)
|
||||
try {
|
||||
const detail = (await getSubModuleLessonById(lesson.id)).data?.data
|
||||
const detail = (await getSubModuleLessonById(lesson.id, { cacheBust: true })).data?.data
|
||||
setLessonForm({
|
||||
title: detail?.title ?? lesson.title ?? "",
|
||||
description: detail?.description ?? "",
|
||||
|
|
@ -2704,7 +2704,7 @@ export function HumanLanguagePage() {
|
|||
if (!open) setLessonDialog({ open: false })
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-lg">
|
||||
<DialogContent className="sm:max-w-5xl max-h-[calc(100vh-6rem)] overflow-y-auto">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Edit lesson</DialogTitle>
|
||||
<DialogDescription>Update lesson metadata stored in the linked question set.</DialogDescription>
|
||||
|
|
@ -2815,7 +2815,7 @@ export function HumanLanguagePage() {
|
|||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<ul className="max-h-[min(28rem,calc(100vh-16rem))] space-y-3 overflow-y-auto pr-1 [scrollbar-gutter:stable]">
|
||||
<ul className="space-y-3 pr-1 [scrollbar-gutter:stable]">
|
||||
{lessonFetch.questions.map((q, qIdx) => {
|
||||
const qType = String(q.question_type ?? "—")
|
||||
const embeddedUrls = extractUrls(q.question_text || "")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user