stabilize flows course selection by strict category match
Filter course options by exact selected category_id in flows to prevent first-load course mismatch that changed module counts after refresh. Made-with: Cursor
This commit is contained in:
parent
5b1d3903e0
commit
814a6a54e8
|
|
@ -257,7 +257,9 @@ export function CourseFlowBuilderPage() {
|
||||||
setLoadingCourses(true)
|
setLoadingCourses(true)
|
||||||
try {
|
try {
|
||||||
const res = await getCoursesByCategory(selectedCategoryId)
|
const res = await getCoursesByCategory(selectedCategoryId)
|
||||||
const items = sortByDisplayOrder(res.data.data.courses ?? [])
|
const items = sortByDisplayOrder(
|
||||||
|
(res.data.data.courses ?? []).filter((course) => Number(course.category_id) === Number(selectedCategoryId)),
|
||||||
|
)
|
||||||
setCoursesByCategory((prev) => ({ ...prev, [selectedCategoryId]: items }))
|
setCoursesByCategory((prev) => ({ ...prev, [selectedCategoryId]: items }))
|
||||||
setSelectedCourseId(items[0]?.id ?? null)
|
setSelectedCourseId(items[0]?.id ?? null)
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user