This commit is contained in:
@@ -18,7 +18,7 @@ export const currentMe = {
|
||||
lastName: 'محمدی',
|
||||
fullName: 'سجاد محمدی',
|
||||
phoneNumber: '09123456789',
|
||||
nationalCode: '0079827498',
|
||||
nationalCode: '0079827497',
|
||||
status: 'approved',
|
||||
address: {
|
||||
address: 'خیابان آزادی، پلاک ۱۲',
|
||||
|
||||
@@ -4,6 +4,7 @@ import { endpoints } from '@/services/api/endpoints'
|
||||
import { currentMe } from '@/services/mock/fixtures/me'
|
||||
|
||||
const fakeToken = 'mock-token-1234567890'
|
||||
let registerData = {}
|
||||
|
||||
register('POST', endpoints.login, () => ({
|
||||
data: { user: currentMe, token: fakeToken },
|
||||
@@ -86,6 +87,13 @@ register('POST', endpoints.completeProfile, ({ data }) => ({
|
||||
data: { user: { ...currentMe, ...data } },
|
||||
}))
|
||||
|
||||
register('GET', endpoints.registerData, () => ({ data: registerData }))
|
||||
|
||||
register('POST', endpoints.registerData, ({ data }) => {
|
||||
registerData = { ...registerData, ...data?.data }
|
||||
return { data: registerData }
|
||||
})
|
||||
|
||||
register('GET', endpoints.getRegistrationQuestionVideo, () => ({
|
||||
data: { url: '', id: 0 },
|
||||
}))
|
||||
|
||||
@@ -60,10 +60,21 @@ export const useCompleteProfileMutation = () => useMutation({ mutationFn: apiCom
|
||||
|
||||
export const useUpdateProfileMutation = () => useMutation({ mutationFn: apiUpdateProfile })
|
||||
|
||||
const getRegistrationVideoIfAvailable = async () => {
|
||||
try {
|
||||
return await apiGetRegistrationQuestionVideo()
|
||||
} catch (error) {
|
||||
// The migrated backend does not expose this optional content endpoint yet.
|
||||
// Treat a missing route as "no tutorial uploaded" so registration remains usable.
|
||||
if (error?.response?.status === 404) return {}
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
export const useGetRegistrationVideoQuery = (options = {}) =>
|
||||
useQuery({
|
||||
queryKey: authKeys.registrationVideo(),
|
||||
queryFn: () => apiGetRegistrationQuestionVideo(),
|
||||
queryFn: getRegistrationVideoIfAvailable,
|
||||
select: (response) => response?.data ?? response,
|
||||
...options,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user