fix: course and bath category filter issue
This commit is contained in:
@@ -130,7 +130,6 @@
|
||||
import {
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
call,
|
||||
createListResource,
|
||||
Dropdown,
|
||||
FormControl,
|
||||
@@ -185,24 +184,27 @@ const batches = createListResource({
|
||||
cache: ['batches', user.data?.name],
|
||||
pageLength: pageLength.value,
|
||||
start: start.value,
|
||||
onSuccess(data) {
|
||||
let allCategories = data.map((batch) => batch.category)
|
||||
allCategories = allCategories.filter(
|
||||
(category, index) => allCategories.indexOf(category) === index && category
|
||||
)
|
||||
if (categories.value.length <= allCategories.length) {
|
||||
updateCategories(data)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const setCategories = (data) => {
|
||||
let allCategories = data.map((batch) => batch.category)
|
||||
allCategories = allCategories.filter(
|
||||
(category, index) => allCategories.indexOf(category) === index && category
|
||||
)
|
||||
if (categories.value.length <= allCategories.length) {
|
||||
updateCategories(data)
|
||||
}
|
||||
}
|
||||
|
||||
const updateBatches = () => {
|
||||
updateFilters()
|
||||
batches.update({
|
||||
filters: filters.value,
|
||||
orderBy: orderBy.value,
|
||||
})
|
||||
batches.reload()
|
||||
batches.reload().then((data) => {
|
||||
setCategories(data)
|
||||
})
|
||||
}
|
||||
|
||||
const updateFilters = () => {
|
||||
|
||||
@@ -168,9 +168,6 @@ const courses = createListResource({
|
||||
cache: ['courses', user.data?.name],
|
||||
pageLength: pageLength.value,
|
||||
start: start.value,
|
||||
onSuccess(data) {
|
||||
setCategories(data)
|
||||
},
|
||||
})
|
||||
|
||||
const setCategories = (data) => {
|
||||
@@ -219,7 +216,9 @@ const updateCourses = () => {
|
||||
courses.update({
|
||||
filters: filters.value,
|
||||
})
|
||||
courses.reload()
|
||||
courses.reload().then((data) => {
|
||||
setCategories(data)
|
||||
})
|
||||
}
|
||||
|
||||
const updateFilters = () => {
|
||||
|
||||
Reference in New Issue
Block a user