fix
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { paginate } from '@/services/mock/helpers'
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import { studentCertificates } from '@/services/mock/fixtures/student-certificates'
|
||||
|
||||
register('GET', endpoints.getStudentCertificates, ({ query }) =>
|
||||
paginate(studentCertificates, query)
|
||||
)
|
||||
|
||||
register('GET', endpoints.downloadStudentCertificate, ({ params, query }) => {
|
||||
const cert = studentCertificates.find((c) => String(c.id) === String(params.id))
|
||||
const format = query?.format === 'jpg' ? 'jpg' : 'pdf'
|
||||
const url = format === 'jpg' ? cert?.jpgUrl : cert?.pdfUrl
|
||||
return { data: { id: params.id, format, url: url || '#' } }
|
||||
})
|
||||
@@ -0,0 +1,29 @@
|
||||
import { paginate } from '@/services/mock/helpers'
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import {
|
||||
studentConsultantTitles,
|
||||
studentConsultants,
|
||||
} from '@/services/mock/fixtures/student-consultants'
|
||||
|
||||
register('GET', endpoints.getStudentConsultants, ({ query }) => paginate(studentConsultants, query))
|
||||
|
||||
register('POST', endpoints.createStudentConsultant, ({ data }) => {
|
||||
const id = `c-${studentConsultants.length + 1}`
|
||||
const next = {
|
||||
id,
|
||||
requestNumber: 500 + studentConsultants.length + 1,
|
||||
title: 'درخواست مشاوره',
|
||||
topicLabel:
|
||||
studentConsultantTitles.find((t) => t.value === data?.title)?.label || data?.title || '—',
|
||||
status: 'pending',
|
||||
statusLabel: 'در حال بررسی',
|
||||
description: data?.description || '',
|
||||
timeLabel: '12:00',
|
||||
dateLabel: '1404/06/12',
|
||||
}
|
||||
studentConsultants.unshift(next)
|
||||
return { data: next }
|
||||
})
|
||||
|
||||
register('GET', endpoints.getStudentConsultantTitles, () => ({ data: studentConsultantTitles }))
|
||||
@@ -0,0 +1,27 @@
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import { studentExams } from '@/services/mock/fixtures/student-exams'
|
||||
|
||||
register('GET', endpoints.showStudentExam, ({ params }) => {
|
||||
const exam = studentExams.find((e) => String(e.id) === String(params.id))
|
||||
if (exam) return { data: exam }
|
||||
const fallback = studentExams[1]
|
||||
return { data: { ...fallback, id: params.id } }
|
||||
})
|
||||
|
||||
register('POST', endpoints.startStudentExamAttempt, ({ params }) => ({
|
||||
data: { id: params.id, status: 'started', message: 'آزمون آغاز شد' },
|
||||
}))
|
||||
|
||||
register('POST', endpoints.submitStudentExamAttempt, ({ params, data }) => {
|
||||
const answers = data?.answers || {}
|
||||
const total = Object.keys(answers).length
|
||||
return {
|
||||
data: {
|
||||
id: params.id,
|
||||
submitted: true,
|
||||
score: total > 0 ? (12 + Math.random() * 6).toFixed(2) : 0,
|
||||
message: 'پاسخهای شما با موفقیت ثبت شد.',
|
||||
},
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,11 @@
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import { studentLessons } from '@/services/mock/fixtures/student-lessons'
|
||||
|
||||
register('GET', endpoints.showStudentLesson, ({ params }) => {
|
||||
const lesson = studentLessons.find((l) => String(l.id) === String(params.id))
|
||||
if (lesson) return { data: lesson }
|
||||
// fallback so any term/lesson combo resolves
|
||||
const fallback = studentLessons[0]
|
||||
return { data: { ...fallback, id: params.id } }
|
||||
})
|
||||
@@ -0,0 +1,21 @@
|
||||
import { paginate } from '@/services/mock/helpers'
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import {
|
||||
missionaryDispatches,
|
||||
missionaryNarratives,
|
||||
missionaryProfile,
|
||||
missionaryRequests,
|
||||
} from '@/services/mock/fixtures/student-missionary'
|
||||
|
||||
register('GET', endpoints.getMissionaryProfile, () => ({ data: missionaryProfile }))
|
||||
|
||||
register('GET', endpoints.getMissionaryRequests, ({ query }) => paginate(missionaryRequests, query))
|
||||
|
||||
register('GET', endpoints.getMissionaryDispatches, ({ query }) =>
|
||||
paginate(missionaryDispatches, query)
|
||||
)
|
||||
|
||||
register('GET', endpoints.getMissionaryNarratives, ({ query }) =>
|
||||
paginate(missionaryNarratives, query)
|
||||
)
|
||||
@@ -0,0 +1,33 @@
|
||||
import { paginate } from '@/services/mock/helpers'
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import {
|
||||
studentServiceTitlesByType,
|
||||
studentServiceTypes,
|
||||
studentServices,
|
||||
} from '@/services/mock/fixtures/student-services'
|
||||
|
||||
register('GET', endpoints.getStudentServices, ({ query }) => paginate(studentServices, query))
|
||||
|
||||
register('POST', endpoints.createStudentService, ({ data }) => {
|
||||
const id = `s-${studentServices.length + 1}`
|
||||
const next = {
|
||||
id,
|
||||
requestNumber: 500 + studentServices.length + 1,
|
||||
title: data?.title || '—',
|
||||
typeKey: data?.typeKey || 'other',
|
||||
typeLabel: studentServiceTypes.find((t) => t.value === data?.typeKey)?.label || 'سایر',
|
||||
status: 'pending',
|
||||
statusLabel: 'در انتظار بررسی',
|
||||
description: data?.description || '',
|
||||
createdAt: '1404/06/12',
|
||||
}
|
||||
studentServices.unshift(next)
|
||||
return { data: next }
|
||||
})
|
||||
|
||||
register('GET', endpoints.getStudentServiceTypes, () => ({ data: studentServiceTypes }))
|
||||
|
||||
register('GET', endpoints.getStudentServiceTitles, ({ query }) => ({
|
||||
data: studentServiceTitlesByType[query.type] || [],
|
||||
}))
|
||||
@@ -0,0 +1,14 @@
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import { studentSessions } from '@/services/mock/fixtures/student-sessions'
|
||||
|
||||
register('GET', endpoints.showStudentSession, ({ params }) => {
|
||||
const session = studentSessions.find((s) => String(s.id) === String(params.id))
|
||||
if (session) return { data: session }
|
||||
const fallback = studentSessions[0]
|
||||
return { data: { ...fallback, id: params.id } }
|
||||
})
|
||||
|
||||
register('POST', endpoints.submitStudentSessionHomework, ({ params }) => ({
|
||||
data: { id: params.id, status: 'submitted', message: 'تکلیف با موفقیت ارسال شد' },
|
||||
}))
|
||||
@@ -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