@@ -41,11 +41,11 @@
|
||||
|
||||
<div class="edit-profile__cell edit-profile__cell--third">
|
||||
<DatePickerField
|
||||
v-model="form.birthDate"
|
||||
name="birthDate"
|
||||
v-model="form.birthday"
|
||||
name="birthday"
|
||||
label="تاریخ تولد"
|
||||
:max="todayIso"
|
||||
:error="errors.birthDate"
|
||||
:error="errors.birthday"
|
||||
/>
|
||||
</div>
|
||||
<div class="edit-profile__cell edit-profile__cell--third">
|
||||
@@ -253,7 +253,7 @@ const initialPhoneNumber = ref('')
|
||||
|
||||
const form = ref({
|
||||
name: '',
|
||||
birthDate: '',
|
||||
birthday: '',
|
||||
nationalCode: '',
|
||||
marriageStatus: '',
|
||||
gender: '',
|
||||
@@ -298,34 +298,38 @@ const onProvinceChange = () => {
|
||||
|
||||
const { data: profile } = useGetMeQuery()
|
||||
|
||||
watch(profile, (user) => {
|
||||
if (!user) return
|
||||
const fullName =
|
||||
user.name || [user.firstName, user.lastName].filter(Boolean).join(' ').trim() || ''
|
||||
const phone = user.phone || user.phoneNumber || ''
|
||||
form.value = {
|
||||
...form.value,
|
||||
name: fullName,
|
||||
birthDate: user.profile?.birthDate || '',
|
||||
nationalCode: user.nationalCode || '',
|
||||
marriageStatus: user.profile?.marriageStatus || '',
|
||||
gender: user.profile?.gender || '',
|
||||
phone,
|
||||
provinceId: user?.province?.id || '',
|
||||
cityId: user?.city?.id || '',
|
||||
address: user?.address || '',
|
||||
avatarMediaId: user.profile?.avatarMediaId || null,
|
||||
}
|
||||
initialNationalCode.value = user.nationalCode || ''
|
||||
initialPhoneNumber.value = phone
|
||||
if (user.avatarUrl) avatar.value = { url: user.avatarUrl }
|
||||
})
|
||||
watch(
|
||||
profile,
|
||||
(user) => {
|
||||
if (!user) return
|
||||
const fullName =
|
||||
user.name || [user.firstName, user.lastName].filter(Boolean).join(' ').trim() || ''
|
||||
const phone = user.phone || user.phoneNumber || ''
|
||||
form.value = {
|
||||
...form.value,
|
||||
name: fullName,
|
||||
birthday: user?.birthday || '',
|
||||
nationalCode: user.nationalCode || '',
|
||||
marriageStatus: user?.marriageStatus || '',
|
||||
gender: user?.gender || '',
|
||||
phone,
|
||||
provinceId: user?.province?.id || '',
|
||||
cityId: user?.city?.id || '',
|
||||
address: user?.address || '',
|
||||
avatarMediaId: user?.avatarMediaId || null,
|
||||
}
|
||||
initialNationalCode.value = user.nationalCode || ''
|
||||
initialPhoneNumber.value = phone
|
||||
if (user.avatarUrl) avatar.value = { url: user.avatarUrl }
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const uploadMutation = useUploadMediaMutation()
|
||||
|
||||
const onAvatarCropped = async (file) => {
|
||||
try {
|
||||
const formData = objectToFormData({ file, subType: 'avatar', context: 'user' })
|
||||
const formData = objectToFormData({ file, purpose: 'avatar', context: 'user' })
|
||||
const response = await uploadMutation.mutateAsync(formData)
|
||||
const payload = response?.data ?? response
|
||||
avatar.value = { url: payload?.url, uploadId: payload?.uploadId, ...payload }
|
||||
@@ -344,7 +348,7 @@ const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
// Backend PATCH /me accepts: name, email, phone, avatar_media_id.
|
||||
// Other UI-only fields (province/city/address/birthDate/…) are not in
|
||||
// Other UI-only fields (province/city/address/birthday/…) are not in
|
||||
// the backend Postman doc and are dropped here. Password is handled
|
||||
// separately via POST /reset-password.
|
||||
const body = {
|
||||
@@ -471,7 +475,7 @@ const onCancel = () => router.push({ name: 'student-dashboard' })
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.625rem;
|
||||
justify-content: space-between;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user