Refresh lesson card after edit
Made-with: Cursor
This commit is contained in:
parent
beb0e32dde
commit
5a2c36e276
|
|
@ -631,8 +631,12 @@ export const getHumanLanguageLessonsByCourse = (courseId: number, cefr_level: st
|
|||
params: { cefr_level },
|
||||
})
|
||||
|
||||
export const getHumanLanguageHierarchy = () =>
|
||||
withSingleRetry(() => http.get<GetHumanLanguageHierarchyResponse>("/course-management/hierarchy")).then(async (res) => {
|
||||
export const getHumanLanguageHierarchy = (options?: { cacheBust?: boolean }) =>
|
||||
withSingleRetry(() =>
|
||||
http.get<GetHumanLanguageHierarchyResponse>("/course-management/hierarchy", {
|
||||
params: options?.cacheBust ? { _t: Date.now() } : undefined,
|
||||
}),
|
||||
).then(async (res) => {
|
||||
const payload = res.data?.data as unknown
|
||||
if (payload && typeof payload === "object" && !Array.isArray(payload) && "sub_categories" in payload) {
|
||||
return res
|
||||
|
|
|
|||
|
|
@ -426,10 +426,10 @@ export function HumanLanguagePage() {
|
|||
label?: string,
|
||||
) => <MediaPreviewCard urlRaw={urlRaw} hint={hint} className={className} label={label} />
|
||||
|
||||
const loadHierarchy = async (showLoading = true) => {
|
||||
const loadHierarchy = async (showLoading = true, forceRefresh = false) => {
|
||||
if (showLoading) setLoading(true)
|
||||
try {
|
||||
const res = await getHumanLanguageHierarchy()
|
||||
const res = await getHumanLanguageHierarchy({ cacheBust: forceRefresh })
|
||||
const data = res.data?.data
|
||||
setCategoryId(data?.category_id ?? null)
|
||||
const nextSubCategories = data?.sub_categories ?? []
|
||||
|
|
@ -1078,7 +1078,7 @@ export function HumanLanguagePage() {
|
|||
})
|
||||
toast.success("Lesson updated")
|
||||
setLessonDialog({ open: false })
|
||||
await loadHierarchy(false)
|
||||
await loadHierarchy(false, true)
|
||||
} catch (error) {
|
||||
console.error("Failed to update lesson:", error)
|
||||
toast.error("Failed to update lesson")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user