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