d4dc4a76f8
SessionFormPage now passes { formData, onUploadProgress } to mutateAsync
for progress tracking. Update uploadMediaMutationFn to destructure the
object and forward onUploadProgress to apiUploadMedia; update apiUploadMedia
to accept and pass the callback to axios.
[batch-1-hotfix]
56 lines
2.5 KiB
JavaScript
56 lines
2.5 KiB
JavaScript
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 apiRequestLoginOtp = (payload) => http.post(endpoints.requestLoginOtp, payload)
|
|
|
|
export const apiVerifyLoginOtp = (payload) => http.post(endpoints.verifyLoginOtp, payload)
|
|
|
|
export const apiRegister = (payload) => http.post(endpoints.register, payload)
|
|
|
|
export const apiVerifyCode = (payload) => http.post(endpoints.verifyCode, payload)
|
|
|
|
export const apiResendVerificationCode = (payload) =>
|
|
http.post(endpoints.resendVerificationCodeForRegister, payload)
|
|
|
|
export const apiForgotPassword = (payload) => http.post(endpoints.forgotPassword, payload)
|
|
|
|
export const apiVerifyForgotPasswordCode = (payload) =>
|
|
http.post(endpoints.verifyForgotPasswordCode, payload)
|
|
|
|
export const apiResetPassword = (payload) => http.post(endpoints.resetPassword, payload)
|
|
|
|
export const apiLogout = () => http.post(endpoints.logout)
|
|
|
|
export const apiGetMe = () => http.get(endpoints.me)
|
|
|
|
export const apiCompleteProfile = (payload) => http.post(endpoints.completeProfile, 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)
|
|
|
|
// Media uploads (especially course videos) can legitimately take several
|
|
// minutes on slower connections. Keep the normal API timeout short, but give
|
|
// this endpoint enough time to complete the backend's 300 MB upload contract.
|
|
// `onUploadProgress` is optional and forwarded straight to axios so callers
|
|
// can render an upload progress bar (e.g. XHR progress events).
|
|
export const apiUploadMedia = (formData, onUploadProgress) =>
|
|
http.post(endpoints.uploadMedia, formData, {
|
|
timeout: 10 * 60 * 1000,
|
|
...(onUploadProgress ? { onUploadProgress } : {}),
|
|
})
|