fix
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import { findOrThrow, paginate } from '@/services/mock/helpers'
|
||||
import { studentTerms } from '@/services/mock/fixtures/student-terms'
|
||||
|
||||
const CURRENT_STATUSES = new Set(['watching', 'waitForExam'])
|
||||
const ENDED_STATUSES = new Set(['completed', 'failed'])
|
||||
|
||||
register('GET', endpoints.getStudentTerms, ({ query }) => {
|
||||
let list = [...studentTerms]
|
||||
if (query.status === 'current') {
|
||||
list = list.filter((t) => CURRENT_STATUSES.has(t.status))
|
||||
} else if (query.status === 'ended') {
|
||||
list = list.filter((t) => ENDED_STATUSES.has(t.status))
|
||||
}
|
||||
return paginate(list, query)
|
||||
})
|
||||
|
||||
register('GET', endpoints.showStudentTerm, ({ params }) => ({
|
||||
data: findOrThrow(studentTerms, params.id),
|
||||
}))
|
||||
Reference in New Issue
Block a user