diff --git a/src/views/ApplyFormView.vue b/src/views/ApplyFormView.vue index 664250f..26fe910 100644 --- a/src/views/ApplyFormView.vue +++ b/src/views/ApplyFormView.vue @@ -1163,28 +1163,25 @@ function applyServerPayload(d: { location_city?: string oversea_country?: string intro?: string + recommend?: string | null promise_signed_at?: string | null promise_signature?: string | null submitted_at?: string | null files?: { id: number; kind: string; original_name: string; size: number; url: string }[] -}) { +} & Record) { applicationStatus.value = (d.status as 'draft' | 'submitted') || 'draft' submittedAt.value = typeof d.submitted_at === 'string' ? d.submitted_at : '' participantMayEdit.value = d.participant_may_edit !== false - formModel.player_name = d.player_name || '' - formModel.school = d.school || '' - formModel.degree = d.degree || '' - formModel.contact_email = d.contact_email || '' - formModel.contact_mobile = d.contact_mobile || '' - formModel.entry_group = d.entry_group || '' - formModel.company_name = d.company_name || '' - formModel.project_name = d.project_name || '' - formModel.track = d.track || '' - formModel.location_country = d.location_country || '' - formModel.location_province = d.location_province || '' - formModel.location_city = d.location_city || '' - formModel.oversea_country = d.oversea_country || '' - formModel.intro = d.intro || '' + for (const f of schemaFields.value) { + if (f.type === 'file') continue + if (f.key === 'commitment_accepted' || f.key === 'promise_signature') continue + const raw = Object.prototype.hasOwnProperty.call(d, f.key) ? d[f.key] : undefined + if (f.type === 'checkbox') { + formModel[f.key] = raw ? '1' : '' + } else { + formModel[f.key] = raw != null ? String(raw) : '' + } + } const hasSignaturePayload = Object.prototype.hasOwnProperty.call(d, 'promise_signature') const sig = hasSignaturePayload ? typeof d.promise_signature === 'string'