@@ -9,7 +9,9 @@ import { endpoints } from '@/services/api/endpoints'
|
||||
|
||||
export const apiLogin = (payload) => http.post(endpoints.login, payload)
|
||||
|
||||
export const apiLoginWithCode = (payload) => http.post(endpoints.loginWithCode2Step, 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)
|
||||
|
||||
|
||||
@@ -8,15 +8,16 @@ export const endpoints = {
|
||||
updateProfile: '/me',
|
||||
registerData: '/me/register-data',
|
||||
|
||||
// FE-only — NOT in backend Postman doc; kept so existing UI/mock layer works.
|
||||
requestLoginOtp: '/auth/login/otp/request',
|
||||
verifyLoginOtp: '/auth/login/otp/verify',
|
||||
forgotPassword: '/auth/password/forgot',
|
||||
verifyForgotPasswordCode: '/auth/password/verify-otp',
|
||||
resetPassword: '/auth/password/reset',
|
||||
|
||||
resendVerificationCodeForRegister: '/resend-verification-code',
|
||||
verifyCode: '/verify-code',
|
||||
completeProfile: '/complete-profile',
|
||||
getRegistrationQuestionVideo: '/verification-registration-media',
|
||||
loginWithCode2Step: '/login-with-code',
|
||||
forgotPassword: '/forgot-password',
|
||||
verifyForgotPasswordCode: '/verify-forgot-password-code',
|
||||
resetPassword: '/reset-password',
|
||||
|
||||
// ─── Geo ───────────────────────────────────────────────────────────────────
|
||||
provinceList: '/provinces',
|
||||
|
||||
@@ -6,7 +6,7 @@ const pick = (arr, i) => arr[i % arr.length]
|
||||
const makeStudent = (i) => {
|
||||
const firstName = pick(firstNames, i)
|
||||
const lastName = pick(lastNames, i + 2)
|
||||
const status = i % 3 === 0 ? 'rejected' : 'pending'
|
||||
const status = i % 3 === 0 ? 'rejected' : 'verified'
|
||||
const submittedAt = new Date(Date.now() - i * 86_400_000).toISOString()
|
||||
return {
|
||||
id: 500 + i,
|
||||
|
||||
@@ -86,7 +86,7 @@ const makeUser = (i, overrides = {}) => {
|
||||
fullName: `${firstName} ${lastName}`,
|
||||
phoneNumber,
|
||||
nationalCode: String(1_000_000_000 + i * 7).padStart(10, '0'),
|
||||
status: i % 5 === 0 ? 'pending' : 'approved',
|
||||
status: i % 5 === 0 ? 'pending' : i % 3 === 0 ? 'verified' : 'approved',
|
||||
roleId: roles.find((r) => r.name === role)?.id,
|
||||
address: {
|
||||
address: 'آدرس نمونه',
|
||||
|
||||
@@ -21,6 +21,7 @@ register('GET', endpoints.getApprovedUsers, ({ query }) => {
|
||||
nationalCode: 'includes',
|
||||
phoneNumber: 'includes',
|
||||
roleId: (item, v) => String(item.roleId) === String(v),
|
||||
status: (item, v) => String(item.status) === String(v),
|
||||
})
|
||||
list = filterDateRange(list, query)
|
||||
const { data: items, meta } = paginate(list, query)
|
||||
|
||||
@@ -9,7 +9,13 @@ register('POST', endpoints.login, () => ({
|
||||
data: { user: currentMe, token: fakeToken },
|
||||
}))
|
||||
|
||||
register('POST', endpoints.loginWithCode2Step, () => ({
|
||||
register('POST', endpoints.requestLoginOtp, () => ({
|
||||
success: true,
|
||||
message: 'If the phone is registered, a code has been sent.',
|
||||
data: null,
|
||||
}))
|
||||
|
||||
register('POST', endpoints.verifyLoginOtp, () => ({
|
||||
data: { user: currentMe, token: fakeToken },
|
||||
}))
|
||||
|
||||
@@ -26,15 +32,19 @@ register('POST', endpoints.resendVerificationCodeForRegister, () => ({
|
||||
}))
|
||||
|
||||
register('POST', endpoints.forgotPassword, () => ({
|
||||
data: { message: 'کد بازیابی ارسال شد' },
|
||||
success: true,
|
||||
message: 'If the phone is registered, a code has been sent.',
|
||||
data: null,
|
||||
}))
|
||||
|
||||
register('POST', endpoints.verifyForgotPasswordCode, () => ({
|
||||
data: { token: fakeToken },
|
||||
data: { reset_token: fakeToken },
|
||||
}))
|
||||
|
||||
register('POST', endpoints.resetPassword, () => ({
|
||||
data: { message: 'رمز عبور با موفقیت تغییر کرد' },
|
||||
success: true,
|
||||
message: 'Password updated.',
|
||||
data: null,
|
||||
}))
|
||||
|
||||
register('POST', endpoints.logout, () => ({ data: { message: 'خروج موفق' } }))
|
||||
|
||||
@@ -7,7 +7,8 @@ import {
|
||||
apiGetRegisterData,
|
||||
apiGetRegistrationQuestionVideo,
|
||||
apiLogin,
|
||||
apiLoginWithCode,
|
||||
apiRequestLoginOtp,
|
||||
apiVerifyLoginOtp,
|
||||
apiLogout,
|
||||
apiRegister,
|
||||
apiResendVerificationCode,
|
||||
@@ -27,7 +28,9 @@ export const authKeys = {
|
||||
|
||||
export const useLoginMutation = () => useMutation({ mutationFn: apiLogin })
|
||||
|
||||
export const useLoginWithCodeMutation = () => useMutation({ mutationFn: apiLoginWithCode })
|
||||
export const useRequestLoginOtpMutation = () => useMutation({ mutationFn: apiRequestLoginOtp })
|
||||
|
||||
export const useVerifyLoginOtpMutation = () => useMutation({ mutationFn: apiVerifyLoginOtp })
|
||||
|
||||
export const useRegisterMutation = () => useMutation({ mutationFn: apiRegister })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user