first commit
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import { currentProfile } from '@/services/mock/fixtures/profile'
|
||||
import { makeId } from '@/services/mock/helpers'
|
||||
|
||||
const fakeToken = 'mock-token-1234567890'
|
||||
|
||||
register('POST', endpoints.login, () => ({
|
||||
data: { user: currentProfile, token: fakeToken },
|
||||
}))
|
||||
|
||||
register('POST', endpoints.loginWithCode2Step, () => ({
|
||||
data: { user: currentProfile, token: fakeToken },
|
||||
}))
|
||||
|
||||
register('POST', endpoints.verifyCode, () => ({
|
||||
data: { user: currentProfile, token: fakeToken },
|
||||
}))
|
||||
|
||||
register('POST', endpoints.register, ({ data }) => ({
|
||||
data: { user: { ...currentProfile, ...data }, token: fakeToken },
|
||||
}))
|
||||
|
||||
register('POST', endpoints.resendVerificationCodeForRegister, () => ({
|
||||
data: { message: 'کد جدید ارسال شد' },
|
||||
}))
|
||||
|
||||
register('POST', endpoints.forgotPassword, () => ({
|
||||
data: { message: 'کد بازیابی ارسال شد' },
|
||||
}))
|
||||
|
||||
register('POST', endpoints.verifyForgotPasswordCode, () => ({
|
||||
data: { token: fakeToken },
|
||||
}))
|
||||
|
||||
register('POST', endpoints.resetPassword, () => ({
|
||||
data: { message: 'رمز عبور با موفقیت تغییر کرد' },
|
||||
}))
|
||||
|
||||
register('POST', endpoints.logout, () => ({ data: { message: 'خروج موفق' } }))
|
||||
|
||||
register('GET', endpoints.getProfile, () => ({ data: currentProfile }))
|
||||
|
||||
register('PUT', endpoints.updateProfile, ({ data }) => {
|
||||
Object.assign(currentProfile, {
|
||||
firstName: data.firstName ?? currentProfile.firstName,
|
||||
lastName: data.lastName ?? currentProfile.lastName,
|
||||
phoneNumber: data.phoneNumber ?? currentProfile.phoneNumber,
|
||||
nationalCode: data.nationalCode ?? currentProfile.nationalCode,
|
||||
})
|
||||
if (data.provinceId) {
|
||||
currentProfile.address = currentProfile.address || {}
|
||||
currentProfile.address.province = { id: data.provinceId, name: '' }
|
||||
}
|
||||
if (data.cityId) {
|
||||
currentProfile.address = currentProfile.address || {}
|
||||
currentProfile.address.city = { id: data.cityId, name: '' }
|
||||
}
|
||||
if (data.address) {
|
||||
currentProfile.address = { ...currentProfile.address, address: data.address }
|
||||
}
|
||||
currentProfile.profile = {
|
||||
...currentProfile.profile,
|
||||
bio: data.bio ?? currentProfile.profile?.bio,
|
||||
birthDate: data.birthDate ?? currentProfile.profile?.birthDate,
|
||||
maritalStatus: data.maritalStatus ?? currentProfile.profile?.maritalStatus,
|
||||
gender: data.gender ?? currentProfile.profile?.gender,
|
||||
}
|
||||
return { data: currentProfile }
|
||||
})
|
||||
|
||||
register('POST', endpoints.completeProfile, ({ data }) => ({
|
||||
data: { user: { ...currentProfile, ...data } },
|
||||
}))
|
||||
|
||||
register('GET', endpoints.getRegistrationQuestionVideo, () => ({
|
||||
data: { url: '', id: 0 },
|
||||
}))
|
||||
|
||||
register('POST', endpoints.uploadMediaTemporary, () => {
|
||||
const id = makeId()
|
||||
return {
|
||||
data: {
|
||||
id,
|
||||
uploadId: id,
|
||||
url: `https://picsum.photos/seed/${id}/240/240`,
|
||||
},
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user