fix
Deploy banu-front / deploy (push) Successful in 1m27s

This commit is contained in:
sajjadtalkhabi
2026-07-07 17:36:43 +03:30
parent b9ef684b51
commit 38a396ba21
89 changed files with 1815 additions and 478 deletions
+18 -16
View File
@@ -10,7 +10,7 @@ const emptyState = () => ({
avatar: null,
avatarId: '',
name: '',
birthDate: '',
birthday: '',
nationalCode: '',
maritalStatus: '',
gender: '',
@@ -75,7 +75,7 @@ const SECTION_FIELDS = {
'avatar',
'avatarId',
'name',
'birthDate',
'birthday',
'nationalCode',
'maritalStatus',
'gender',
@@ -115,15 +115,16 @@ const FIELD_TO_SECTION = Object.entries(SECTION_FIELDS).reduce((acc, [section, f
return acc
}, {})
export const toKeyValueList = (obj = {}) =>
Object.entries(obj).map(([key, value]) => ({ key, value }))
export const fromKeyValueList = (list = []) => {
if (!Array.isArray(list)) return {}
return list.reduce((acc, item) => {
if (item && typeof item === 'object' && 'key' in item) acc[item.key] = item.value
return acc
}, {})
// Register-data travels as a flat `{ field: value }` object. Legacy payloads
// were a `[{ key, value }]` list — tolerate both when reading.
export const toRegisterDataObject = (input) => {
if (Array.isArray(input)) {
return input.reduce((acc, item) => {
if (item && typeof item === 'object' && 'key' in item) acc[item.key] = item.value
return acc
}, {})
}
return input && typeof input === 'object' ? input : {}
}
const readPersisted = () => {
@@ -241,10 +242,11 @@ export const useStudentRegistrationStore = defineStore('studentRegistration', ()
: personal.value.avatarId,
})
// Take the flat `{key,value}` list from GET /me/register-data and slot each
// value into the right section ref, leaving anything we don't recognise alone.
const hydrateFromKeyValueList = (list) => {
const flat = fromKeyValueList(list)
// Take the flat `{ field: value }` map from GET /me/register-data and slot
// each value into the right section ref, leaving anything we don't
// recognise alone.
const hydrateFromRegisterData = (input) => {
const flat = toRegisterDataObject(input)
const buckets = {}
Object.entries(flat).forEach(([key, value]) => {
const section = FIELD_TO_SECTION[key]
@@ -301,7 +303,7 @@ export const useStudentRegistrationStore = defineStore('studentRegistration', ()
goToPrevStep,
canGoToStep,
buildCompletePayload,
hydrateFromKeyValueList,
hydrateFromRegisterData,
reset,
}
})