fix: admin courses
This commit is contained in:
@@ -10,5 +10,6 @@ export const apiShowAdminConsultation = (id) =>
|
||||
export const apiSendAdminConsultationMessage = (id, payload) =>
|
||||
http.post(buildUrl(endpoints.sendConsultationMessage, { id }), payload)
|
||||
|
||||
// Backend uses PATCH (not POST).
|
||||
export const apiChangeAdminConsultationStatus = (id, payload) =>
|
||||
http.post(buildUrl(endpoints.changeConsultationStatus, { id }), payload)
|
||||
http.patch(buildUrl(endpoints.changeConsultationStatus, { id }), payload)
|
||||
|
||||
@@ -15,6 +15,9 @@ export const apiDeleteAdminCourse = (id) => http.delete(buildUrl(endpoints.delet
|
||||
export const apiGetAdminCourseStudents = (courseId, params) =>
|
||||
http.get(buildUrl(endpoints.listCourseStudents, { courseId }), { params })
|
||||
|
||||
export const apiGetCourseAttendees = (courseId, params) =>
|
||||
http.get(buildUrl(endpoints.getCourseAttendees, { courseId }), { params })
|
||||
|
||||
export const apiAddAdminCourseStudent = (courseId, payload) =>
|
||||
http.post(buildUrl(endpoints.addCourseStudent, { courseId }), payload)
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ export const apiCloneAdminTerm = (id) => http.post(buildUrl(endpoints.cloneTerm,
|
||||
export const apiGetAdminTermStudents = (termId, params) =>
|
||||
http.get(buildUrl(endpoints.listUserTerm, { termId }), { params })
|
||||
|
||||
export const apiGetTermAttendees = (termId, params) =>
|
||||
http.get(buildUrl(endpoints.getTermAttendees, { termId }), { params })
|
||||
|
||||
export const apiAddAdminTermStudents = (termId, payload) =>
|
||||
http.post(buildUrl(endpoints.addUserTerm, { termId }), payload)
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { http } from '@/services/api/http'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
|
||||
// Backend (Postman: Auth) is the source of truth. Payloads use the backend's
|
||||
// field names — `name`, `phone`, `password`, `password_confirmation`,
|
||||
// `device_name`, `avatar_media_id` — and responses are passed through unchanged.
|
||||
// Callers (forms / store) are responsible for translating UI-local field names
|
||||
// (firstName/lastName/phoneNumber) into this shape.
|
||||
|
||||
export const apiLogin = (payload) => http.post(endpoints.login, payload)
|
||||
|
||||
export const apiLoginWithCode = (payload) => http.post(endpoints.loginWithCode2Step, payload)
|
||||
@@ -25,7 +31,12 @@ export const apiGetMe = () => http.get(endpoints.me)
|
||||
|
||||
export const apiCompleteProfile = (payload) => http.post(endpoints.completeProfile, payload)
|
||||
|
||||
export const apiUpdateProfile = (payload) => http.put(endpoints.updateProfile, payload)
|
||||
export const apiUpdateProfile = (payload) => http.patch(endpoints.updateProfile, payload)
|
||||
|
||||
// `data` is an array of `{ key, value }` entries. The backend echoes whatever
|
||||
// we POST back from the GET, so this is effectively a free-form key/value bag.
|
||||
export const apiGetRegisterData = () => http.get(endpoints.registerData)
|
||||
export const apiSaveRegisterData = (data) => http.post(endpoints.registerData, { data })
|
||||
|
||||
export const apiGetRegistrationQuestionVideo = () =>
|
||||
http.get(endpoints.getRegistrationQuestionVideo)
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
export const endpoints = {
|
||||
// ─── Auth & profile ────────────────────────────────────────────────────────
|
||||
register: '/register',
|
||||
// Backend-aligned (Postman: Auth collection)
|
||||
register: '/auth/register',
|
||||
login: '/auth/login',
|
||||
logout: '/auth/logout',
|
||||
me: '/auth/me',
|
||||
updateProfile: '/me',
|
||||
registerData: '/me/register-data',
|
||||
|
||||
// FE-only — NOT in backend Postman doc; kept so existing UI/mock layer works.
|
||||
resendVerificationCodeForRegister: '/resend-verification-code',
|
||||
verifyCode: '/verify-code',
|
||||
completeProfile: '/complete-profile',
|
||||
getRegistrationQuestionVideo: '/verification-registration-media',
|
||||
login: '/login',
|
||||
loginWithCode2Step: '/login-with-code',
|
||||
forgotPassword: '/forgot-password',
|
||||
verifyForgotPasswordCode: '/verify-forgot-password-code',
|
||||
resetPassword: '/reset-password',
|
||||
logout: '/logout',
|
||||
me: '/auth/me',
|
||||
updateProfile: '/profile',
|
||||
|
||||
// ─── Geo ───────────────────────────────────────────────────────────────────
|
||||
provinceList: '/provinces',
|
||||
@@ -67,6 +71,7 @@ export const endpoints = {
|
||||
showTerm: '/terms/:id',
|
||||
updateTerm: '/terms/:id',
|
||||
deleteTerm: '/terms/:id',
|
||||
getTermAttendees: '/terms/:termId/attendees',
|
||||
|
||||
// ─── Backend-aligned: Courses ──────────────────────────────────────────────
|
||||
getCoursesList: '/courses',
|
||||
@@ -74,6 +79,7 @@ export const endpoints = {
|
||||
showCourse: '/courses/:id',
|
||||
updateCourse: '/courses/:id',
|
||||
deleteCourse: '/courses/:id',
|
||||
getCourseAttendees: '/courses/:courseId/attendees',
|
||||
|
||||
// ─── Backend-aligned: Sessions ─────────────────────────────────────────────
|
||||
getSessionsList: '/sessions',
|
||||
@@ -146,16 +152,19 @@ export const endpoints = {
|
||||
getAssignmentSubmissions: '/homeworks/:homeworkId/submissions',
|
||||
showAssignmentSubmission: '/homework-submissions/:submissionId',
|
||||
|
||||
// ─── Tickets / Consultations (out of scope of Terms/Courses backend doc) ───
|
||||
// ─── Backend-aligned: Tickets ─────────────────────────────────────────────
|
||||
// Admin "messages" UI talks to /admin/tickets.
|
||||
// Admin "consultations" UI talks to /counselor/tickets (same schema; the
|
||||
// counselor scope is the consultation pool).
|
||||
getTicketsList: '/admin/tickets',
|
||||
showTicket: '/admin/tickets/:id',
|
||||
sendTicketMessage: '/admin/tickets/:id/messages',
|
||||
changeTicketStatus: '/admin/tickets/:id/status',
|
||||
|
||||
getConsultationsList: '/admin/consultations',
|
||||
showConsultation: '/admin/consultations/:id',
|
||||
sendConsultationMessage: '/admin/consultations/:id/messages',
|
||||
changeConsultationStatus: '/admin/consultations/:id/status',
|
||||
getConsultationsList: '/counselor/tickets',
|
||||
showConsultation: '/counselor/tickets/:id',
|
||||
sendConsultationMessage: '/counselor/tickets/:id/messages',
|
||||
changeConsultationStatus: '/counselor/tickets/:id/status',
|
||||
}
|
||||
|
||||
export const buildUrl = (template, params = {}) =>
|
||||
|
||||
@@ -89,7 +89,7 @@ const createInstance = (baseUrl, { headers = {}, ...configs } = {}) => {
|
||||
addResponseUnwrapInterceptor(instance)
|
||||
addCamelizeInterceptor(instance)
|
||||
addSnakizeInterceptor(instance)
|
||||
addUnauthorizeInterceptor(instance)
|
||||
// addUnauthorizeInterceptor(instance)
|
||||
return instance
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user