@@ -41,19 +41,19 @@
|
||||
<SvgIcon name="arrow-left" :size="22" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<div class="login-form__links">
|
||||
<div class="login-form__link">
|
||||
<SvgIcon name="user" :size="12" color="#A7A7A7" />
|
||||
<span>حساب کاربری ندارم</span>
|
||||
<RouterLink :to="{ name: 'signup' }">ثبت نام</RouterLink>
|
||||
</div>
|
||||
<div class="login-form__link">
|
||||
<SvgIcon name="check" :size="12" color="#A7A7A7" />
|
||||
<button type="button" class="login-form__link-btn" @click="goLoginWithCode">
|
||||
ورود با کد تایید
|
||||
</button>
|
||||
</div>
|
||||
<div class="login-form__links">
|
||||
<div class="login-form__link">
|
||||
<SvgIcon name="user" :size="12" color="#A7A7A7" />
|
||||
<span>حساب کاربری ندارم</span>
|
||||
<RouterLink :to="{ name: 'signup' }">ثبت نام</RouterLink>
|
||||
</div>
|
||||
<div class="login-form__link">
|
||||
<SvgIcon name="check" :size="12" color="#A7A7A7" />
|
||||
<button type="button" class="login-form__link-btn" @click="goLoginWithCode">
|
||||
ورود با کد تایید
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -110,26 +110,30 @@ const goForgotPassword = () => emit('next', { mode: 'forgotPassword' })
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-grow: 1;
|
||||
|
||||
&__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
padding: 1rem 0;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
flex-grow: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
&__footer {
|
||||
margin-top: auto;
|
||||
margin-bottom: 1rem;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,16 +166,12 @@ const goForgotPassword = () => emit('next', { mode: 'forgotPassword' })
|
||||
}
|
||||
|
||||
.login-form__links {
|
||||
margin-top: 1.5rem;
|
||||
margin: 0.5rem 0;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
margin-top: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.login-form__link {
|
||||
|
||||
@@ -34,12 +34,12 @@
|
||||
<SvgIcon name="arrow-left" :size="22" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<div class="login-otp__links">
|
||||
<button type="button" class="login-otp__back" @click="emit('back')">
|
||||
بازگشت به ورود با رمز عبور
|
||||
</button>
|
||||
</div>
|
||||
<div class="login-otp__links">
|
||||
<button type="button" class="login-otp__back" @click="emit('back')">
|
||||
بازگشت به ورود با رمز عبور
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="auth-form__footer">
|
||||
@@ -98,26 +98,30 @@ const onSubmit = async () => {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-grow: 1;
|
||||
|
||||
&__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
padding: 1rem 0;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
flex-grow: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
&__footer {
|
||||
margin-top: auto;
|
||||
margin-bottom: 1rem;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,14 +131,10 @@ const onSubmit = async () => {
|
||||
}
|
||||
|
||||
.login-otp__links {
|
||||
margin-top: 1.5rem;
|
||||
margin: 0.5rem 0;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
margin-top: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.login-otp__back {
|
||||
|
||||
@@ -67,12 +67,12 @@
|
||||
<SvgIcon name="arrow-left" :size="22" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<div class="signup-form__login-link">
|
||||
<SvgIcon name="user" :size="12" color="#A7A7A7" />
|
||||
<span>حساب کاربری دارم</span>
|
||||
<RouterLink :to="{ name: 'login' }">ورود</RouterLink>
|
||||
</div>
|
||||
<div class="signup-form__login-link">
|
||||
<SvgIcon name="user" :size="12" color="#A7A7A7" />
|
||||
<span>حساب کاربری دارم</span>
|
||||
<RouterLink :to="{ name: 'login' }">ورود</RouterLink>
|
||||
</div>
|
||||
|
||||
<div class="auth-form__footer">
|
||||
@@ -131,26 +131,30 @@ const onSubmit = async () => {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-grow: 1;
|
||||
|
||||
&__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
padding: 1rem 0;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
flex-grow: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
&__footer {
|
||||
margin-top: auto;
|
||||
margin-bottom: 1rem;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +164,7 @@ const onSubmit = async () => {
|
||||
}
|
||||
|
||||
.signup-form__login-link {
|
||||
margin-top: 1.5rem;
|
||||
margin: 0.5rem 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
@@ -168,10 +172,6 @@ const onSubmit = async () => {
|
||||
font-size: 0.75rem;
|
||||
color: #a7a7a7;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--color-sec-gray);
|
||||
text-decoration: underline;
|
||||
|
||||
@@ -28,20 +28,20 @@
|
||||
<SvgIcon name="arrow-left" :size="22" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<div class="verify__links">
|
||||
<div class="verify__link">
|
||||
<SvgIcon name="user" :size="12" color="#A7A7A7" />
|
||||
<button type="button" class="verify__link-btn" @click="emit('password-login')">
|
||||
ورود با رمز عبور
|
||||
</button>
|
||||
</div>
|
||||
<div class="verify__link">
|
||||
<SvgIcon name="phone" :size="12" color="#A7A7A7" />
|
||||
<button type="button" class="verify__link-btn" @click="emit('back')">
|
||||
تغییر شماره تلفن همراه
|
||||
</button>
|
||||
</div>
|
||||
<div class="verify__links">
|
||||
<div class="verify__link">
|
||||
<SvgIcon name="user" :size="12" color="#A7A7A7" />
|
||||
<button type="button" class="verify__link-btn" @click="emit('password-login')">
|
||||
ورود با رمز عبور
|
||||
</button>
|
||||
</div>
|
||||
<div class="verify__link">
|
||||
<SvgIcon name="phone" :size="12" color="#A7A7A7" />
|
||||
<button type="button" class="verify__link-btn" @click="emit('back')">
|
||||
تغییر شماره تلفن همراه
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -137,7 +137,6 @@ const onSubmit = async () => {
|
||||
const response = await verifySignupMutation.mutateAsync({ phone: props.phoneNumber, code })
|
||||
applySession(response?.data ?? response)
|
||||
emit('verified', { phone: props.phoneNumber, code })
|
||||
redirectAfterLogin()
|
||||
}
|
||||
|
||||
const onResend = async () => {
|
||||
@@ -154,26 +153,30 @@ const onResend = async () => {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-grow: 1;
|
||||
|
||||
&__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
padding: 1rem 0;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
flex-grow: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
&__footer {
|
||||
margin-top: auto;
|
||||
margin-bottom: 1rem;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,16 +204,12 @@ const onResend = async () => {
|
||||
}
|
||||
|
||||
.verify__links {
|
||||
margin-top: 1.5rem;
|
||||
margin: 0.5rem 0;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
margin-top: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.verify__link {
|
||||
|
||||
@@ -111,11 +111,8 @@ import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||
import { educationalInformationSchema } from '@/features/auth/schema/student-register'
|
||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||
import { EDUCATION_STATUS, SEMINARY_LEVEL, STUDENT_REGISTRATION, UNIVERSITY_LEVEL } from '@/enums'
|
||||
import {
|
||||
toKeyValueList,
|
||||
useStudentRegistrationStore,
|
||||
} from '@/features/auth/store/student-registration'
|
||||
|
||||
const store = useStudentRegistrationStore()
|
||||
|
||||
@@ -148,7 +145,7 @@ const saveRegisterMutation = useSaveRegisterDataMutation()
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
await saveRegisterMutation.mutateAsync(toKeyValueList(payload))
|
||||
await saveRegisterMutation.mutateAsync(payload)
|
||||
store.educational = { ...store.educational, ...payload }
|
||||
store.markStepAsCompleted(STUDENT_REGISTRATION.EDUCATIONAL_INFORMATION)
|
||||
store.goToNextStep()
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
</div>
|
||||
<div class="personal-info__cell">
|
||||
<DatePickerField
|
||||
v-model="form.birthDate"
|
||||
name="birthDate"
|
||||
v-model="form.birthday"
|
||||
name="birthday"
|
||||
label="تاریخ تولد"
|
||||
:max="maxBirthDate"
|
||||
:error="errors.birthDate"
|
||||
:error="errors.birthday"
|
||||
/>
|
||||
</div>
|
||||
<div class="personal-info__cell">
|
||||
@@ -198,21 +198,25 @@ const maxBirthDate = computed(() => {
|
||||
const initialPhone = ref(user.value?.phone || store.personal.phone || '')
|
||||
const initialNationalCode = ref(user.value?.nationalCode || store.personal.nationalCode || '')
|
||||
|
||||
const initialAvatar =
|
||||
store.personal.avatar || (user.value?.avatarUrl ? { url: user.value.avatarUrl } : null)
|
||||
|
||||
const form = ref({
|
||||
name: user.value?.name || store.personal.name || '',
|
||||
birthDate: store.personal.birthDate || '',
|
||||
birthday: user.value?.birthday || store.personal.birthday || '',
|
||||
nationalCode: initialNationalCode.value,
|
||||
maritalStatus: store.personal.maritalStatus || '',
|
||||
gender: store.personal.gender || '',
|
||||
maritalStatus: user.value?.marriageStatus || store.personal.maritalStatus || '',
|
||||
gender: user.value?.gender || store.personal.gender || '',
|
||||
phone: initialPhone.value,
|
||||
provinceId: store.personal.provinceId || null,
|
||||
cityId: store.personal.cityId || null,
|
||||
address: store.personal.address || '',
|
||||
avatar: store.personal.avatar || null,
|
||||
provinceId: user.value?.provinceId || store.personal.provinceId || null,
|
||||
cityId: user.value?.cityId || store.personal.cityId || null,
|
||||
address:
|
||||
(typeof user.value?.address === 'string' && user.value.address) || store.personal.address || '',
|
||||
avatar: initialAvatar,
|
||||
avatarId: store.personal.avatarId || '',
|
||||
})
|
||||
|
||||
const avatar = ref(store.personal.avatar || null)
|
||||
const avatar = ref(initialAvatar)
|
||||
|
||||
const { validate, validateAt, errors } = useYup(personalInformationSchema)
|
||||
|
||||
@@ -263,7 +267,7 @@ const onSubmit = async () => {
|
||||
// (http auto-converts camelCase → snake_case: birthday, national_code, …)
|
||||
const body = {
|
||||
name: payload.name,
|
||||
birthday: payload.birthDate,
|
||||
birthday: payload.birthday,
|
||||
nationalCode: payload.nationalCode,
|
||||
marriageStatus: payload.maritalStatus,
|
||||
gender: payload.gender,
|
||||
|
||||
@@ -117,10 +117,7 @@ import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||
import { PROPAGATION_PLATFORM, STUDENT_REGISTRATION } from '@/enums'
|
||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||
import { professionalInformationSchema } from '@/features/auth/schema/student-register'
|
||||
import {
|
||||
toKeyValueList,
|
||||
useStudentRegistrationStore,
|
||||
} from '@/features/auth/store/student-registration'
|
||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||
|
||||
const store = useStudentRegistrationStore()
|
||||
|
||||
@@ -193,7 +190,7 @@ const onSubmit = async () => {
|
||||
specializedTopics: payload.specializedTopics,
|
||||
propagationPlatforms,
|
||||
}
|
||||
await saveRegisterMutation.mutateAsync(toKeyValueList(next))
|
||||
await saveRegisterMutation.mutateAsync(next)
|
||||
store.professional = next
|
||||
store.markStepAsCompleted(STUDENT_REGISTRATION.PROFESSIONAL_INFORMATION)
|
||||
store.goToNextStep()
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<SvgIcon :name="tab.icon" :size="22" color="#fff" />
|
||||
</li>
|
||||
</ul>
|
||||
<SidebarLogout color="#fff" stacked />
|
||||
</div>
|
||||
</aside>
|
||||
</template>
|
||||
@@ -25,6 +26,7 @@
|
||||
<script setup>
|
||||
import { gallery } from '@/utils/gallery'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import SidebarLogout from '@/layouts/sidebars/SidebarLogout.vue'
|
||||
|
||||
defineProps({
|
||||
tabs: { type: Array, required: true },
|
||||
|
||||
@@ -42,10 +42,7 @@ import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||
import { skillAssessmentPart6Schema } from '@/features/auth/schema/student-register'
|
||||
import MediaRecorder from '@/features/auth/components/studentRegister/MediaRecorder.vue'
|
||||
import {
|
||||
toKeyValueList,
|
||||
useStudentRegistrationStore,
|
||||
} from '@/features/auth/store/student-registration'
|
||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||
|
||||
const store = useStudentRegistrationStore()
|
||||
|
||||
@@ -70,7 +67,7 @@ const saveRegisterMutation = useSaveRegisterDataMutation()
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
await saveRegisterMutation.mutateAsync(toKeyValueList(payload))
|
||||
await saveRegisterMutation.mutateAsync(payload)
|
||||
store.skill6 = { ...store.skill6, ...payload }
|
||||
store.markStepAsCompleted(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_6)
|
||||
store.goToNextStep()
|
||||
|
||||
@@ -46,10 +46,7 @@ import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||
import { skillAssessmentPart7Schema } from '@/features/auth/schema/student-register'
|
||||
import MediaRecorder from '@/features/auth/components/studentRegister/MediaRecorder.vue'
|
||||
import {
|
||||
toKeyValueList,
|
||||
useStudentRegistrationStore,
|
||||
} from '@/features/auth/store/student-registration'
|
||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||
|
||||
const store = useStudentRegistrationStore()
|
||||
|
||||
@@ -75,7 +72,7 @@ const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
try {
|
||||
await saveRegisterMutation.mutateAsync(toKeyValueList(payload))
|
||||
await saveRegisterMutation.mutateAsync(payload)
|
||||
store.skill7 = { ...store.skill7, ...payload }
|
||||
store.markStepAsCompleted(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_7)
|
||||
store.isProfileCompleted = true
|
||||
|
||||
@@ -46,10 +46,7 @@ import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||
import {
|
||||
toKeyValueList,
|
||||
useStudentRegistrationStore,
|
||||
} from '@/features/auth/store/student-registration'
|
||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||
|
||||
const props = defineProps({
|
||||
step: { type: Number, required: true },
|
||||
@@ -89,7 +86,7 @@ const saveRegisterMutation = useSaveRegisterDataMutation()
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
await saveRegisterMutation.mutateAsync(toKeyValueList(payload))
|
||||
await saveRegisterMutation.mutateAsync(payload)
|
||||
store[props.storeKey] = { ...store[props.storeKey], ...payload }
|
||||
store.markStepAsCompleted(props.step)
|
||||
store.goToNextStep()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ROLE_HOME_ROUTES } from '@/enums'
|
||||
import { useAuthStore } from '@/store/auth'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
@@ -12,8 +13,7 @@ export const useRedirectAfterLogin = () => {
|
||||
router.push(redirect).catch(() => router.push('/'))
|
||||
return
|
||||
}
|
||||
const target =
|
||||
auth.role === 'admin' ? { name: 'admin-dashboard' } : { name: 'student-dashboard' }
|
||||
const target = { name: ROLE_HOME_ROUTES[auth.role] || 'student-dashboard' }
|
||||
router.push(target).catch(() => router.push('/'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ const { isModal, openModal } = useModal()
|
||||
const { data: registerData } = useGetRegisterDataQuery()
|
||||
watch(
|
||||
registerData,
|
||||
(list) => {
|
||||
if (Array.isArray(list) && list.length > 0) store.hydrateFromKeyValueList(list)
|
||||
(value) => {
|
||||
if (value && Object.keys(value).length > 0) store.hydrateFromRegisterData(value)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ export const personalInformationSchema = object().shape({
|
||||
avatar: mixed().notRequired(),
|
||||
avatarId: mixed().notRequired(),
|
||||
name: requiredString(3),
|
||||
birthDate: string().required(),
|
||||
birthday: string().required(),
|
||||
nationalCode: nationalCodeRule,
|
||||
maritalStatus: string().required(),
|
||||
gender: string().required(),
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user