fix: missing letterAddress

This commit is contained in:
Sebastian Pravda 2023-02-24 14:53:29 +01:00
parent 527dd9fc68
commit 6de8f3f0cb
No known key found for this signature in database
GPG key ID: F3BC84F08EFA3F57
2 changed files with 42 additions and 28 deletions

View file

@ -24,7 +24,8 @@
content: helperText, content: helperText,
placement: 'top', placement: 'top',
showOnCreate: false, showOnCreate: false,
delay: tooltipDelay delay: tooltipDelay,
allowHTML: true,
}} }}
> >
<input <input

View file

@ -131,13 +131,10 @@
.test((_val) => { .test((_val) => {
if ($form.candidate.citizenship !== 'Česká republika') return true; if ($form.candidate.citizenship !== 'Česká republika') return true;
if (!_val) return false; if (!_val) return false;
if (isPersonalIdMatchingBirthdate( if (isPersonalIdMatchingBirthdate(data.whoami.personalIdNumber, _val)) {
data.whoami.personalIdNumber,
_val
)) {
return true; return true;
} else { } else {
pushErrorText("Datum narození a rodné číslo se neshodují.") pushErrorText('Datum narození a rodné číslo se neshodují.');
return false; return false;
} }
}), }),
@ -151,6 +148,7 @@
.matches(/^[0-9]+(\/[0-9]+)?$/), .matches(/^[0-9]+(\/[0-9]+)?$/),
city: yup.string().required(), city: yup.string().required(),
zip: yup.string().required(), zip: yup.string().required(),
letterAddress: yup.string(),
citizenship: yup.string().required(), citizenship: yup.string().required(),
personalIdNumber: yup.string(), personalIdNumber: yup.string(),
schoolName: yup.string().required(), schoolName: yup.string().required(),
@ -346,7 +344,8 @@
$typedErrors['candidate']['city'] || $typedErrors['candidate']['city'] ||
$typedErrors['candidate']['street'] || $typedErrors['candidate']['street'] ||
$typedErrors['candidate']['houseNumber'] || $typedErrors['candidate']['houseNumber'] ||
$typedErrors['candidate']['zip'] $typedErrors['candidate']['zip'] ||
$typedErrors['candidate']['letterAddress']
) { ) {
return true; return true;
} }
@ -410,24 +409,6 @@
return '+' + telephone.match(/[0-9]{1,3}/g)!.join(' '); return '+' + telephone.match(/[0-9]{1,3}/g)!.join(' ');
}; };
let lastCitizenshipSelected = $form.candidate.citizenship;
$: if ($form.candidate.citizenship !== lastCitizenshipSelected) {
lastCitizenshipSelected = $form.candidate.citizenship;
$form.candidate.birthdate = '';
$form.candidate.sex = '';
if ($form.candidate.citizenship === 'Česká republika') {
let [birthdate, sex] = parseBirthdateSexFromPersonalId(data.whoami.personalIdNumber);
$form.candidate.birthdate = birthdate;
$form.candidate.sex = sex;
if (pageIndex === 4) {
pushSuccessText(
`Datum narození a pohlaví bylo vyplněno automaticky podle Vašeho rodného čísla (${data.whoami.personalIdNumber}).`
);
}
}
}
if (details !== undefined) { if (details !== undefined) {
details.candidate.birthdate = details.candidate.birthdate.split('-').reverse().join('.'); details.candidate.birthdate = details.candidate.birthdate.split('-').reverse().join('.');
@ -468,6 +449,25 @@
pageIndex = editModePageIndex; // skip gdpr page pageIndex = editModePageIndex; // skip gdpr page
pageTexts[2] = $LL.candidate.register.fourth.titleEdit(); pageTexts[2] = $LL.candidate.register.fourth.titleEdit();
} }
let lastCitizenshipSelected = $form.candidate.citizenship;
$: if ($form.candidate.citizenship !== lastCitizenshipSelected) {
console.log('citizenship changed');
lastCitizenshipSelected = $form.candidate.citizenship;
$form.candidate.birthdate = '';
$form.candidate.sex = '';
if ($form.candidate.citizenship === 'Česká republika') {
let [birthdate, sex] = parseBirthdateSexFromPersonalId(data.whoami.personalIdNumber);
$form.candidate.birthdate = birthdate;
$form.candidate.sex = sex;
if (pageIndex === 4) {
pushSuccessText(
`Datum narození a pohlaví bylo vyplněno automaticky podle Vašeho rodného čísla (${data.whoami.personalIdNumber}).`
);
}
}
}
</script> </script>
<SplitLayout> <SplitLayout>
@ -485,9 +485,11 @@
{/if} {/if}
<div class="form relative bg-center"> <div class="form relative bg-center">
<div class="bottom-5/24 absolute flex w-full flex-col md:h-auto"> <div class="bottom-5/24 absolute flex w-full flex-col md:h-auto">
<div class="<md:hidden self-center"> {#if pageIndex !== 3}
<SchoolBadge /> <div class="<md:hidden self-center">
</div> <SchoolBadge />
</div>
{/if}
<form on:submit={handleSubmit} id="triggerForm" class="invisible hidden" /> <form on:submit={handleSubmit} id="triggerForm" class="invisible hidden" />
{#if pageIndex === 0} {#if pageIndex === 0}
<form on:submit={handleSubmit}> <form on:submit={handleSubmit}>
@ -595,6 +597,17 @@
/> />
</span> </span>
</div> </div>
<div class="flex w-full flex-col">
<span class="field">
<TextField
error={$typedErrors['candidate']['letterAddress']}
bind:value={$form.candidate.letterAddress}
type="text"
placeholder={'Adresa pro doručování písemností (pokud odlišná)'}
helperText="Uveďte adresu pro doručování písemností. Musí obsahovat <strong>ulici a č.p., PSČ, Okres</strong> <br />(např. Preslova 72/25, 150 21, Praha 5)"
/>
</span>
</div>
</div> </div>
</form> </form>
{:else if pageIndex === 4} {:else if pageIndex === 4}