From 6de8f3f0cbef64e79125e98a4342218eb29bda54 Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Fri, 24 Feb 2023 14:53:29 +0100 Subject: [PATCH 1/5] fix: missing letterAddress --- .../lib/components/textfield/TextField.svelte | 3 +- .../(authenticated)/register/+page.svelte | 67 +++++++++++-------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/frontend/src/lib/components/textfield/TextField.svelte b/frontend/src/lib/components/textfield/TextField.svelte index 86d21cc..cca1313 100644 --- a/frontend/src/lib/components/textfield/TextField.svelte +++ b/frontend/src/lib/components/textfield/TextField.svelte @@ -24,7 +24,8 @@ content: helperText, placement: 'top', showOnCreate: false, - delay: tooltipDelay + delay: tooltipDelay, + allowHTML: true, }} > { if ($form.candidate.citizenship !== 'Česká republika') return true; if (!_val) return false; - if (isPersonalIdMatchingBirthdate( - data.whoami.personalIdNumber, - _val - )) { + if (isPersonalIdMatchingBirthdate(data.whoami.personalIdNumber, _val)) { return true; } else { - pushErrorText("Datum narození a rodné číslo se neshodují.") + pushErrorText('Datum narození a rodné číslo se neshodují.'); return false; } }), @@ -151,6 +148,7 @@ .matches(/^[0-9]+(\/[0-9]+)?$/), city: yup.string().required(), zip: yup.string().required(), + letterAddress: yup.string(), citizenship: yup.string().required(), personalIdNumber: yup.string(), schoolName: yup.string().required(), @@ -346,7 +344,8 @@ $typedErrors['candidate']['city'] || $typedErrors['candidate']['street'] || $typedErrors['candidate']['houseNumber'] || - $typedErrors['candidate']['zip'] + $typedErrors['candidate']['zip'] || + $typedErrors['candidate']['letterAddress'] ) { return true; } @@ -410,24 +409,6 @@ 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) { details.candidate.birthdate = details.candidate.birthdate.split('-').reverse().join('.'); @@ -468,6 +449,25 @@ pageIndex = editModePageIndex; // skip gdpr page 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}).` + ); + } + } + } @@ -485,9 +485,11 @@ {/if}
-
- -
+ {#if pageIndex !== 3} +
+ +
+ {/if}
+
+ + + +
{:else if pageIndex === 4} From d1de6dc3a10e74e1661cbabd171648a01ff323db Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Fri, 24 Feb 2023 15:07:14 +0100 Subject: [PATCH 2/5] fix: streetnames with spaces --- .../components/textfield/AddressField.svelte | 49 +++++++++++++++++++ .../(authenticated)/register/+page.svelte | 15 +++--- 2 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 frontend/src/lib/components/textfield/AddressField.svelte diff --git a/frontend/src/lib/components/textfield/AddressField.svelte b/frontend/src/lib/components/textfield/AddressField.svelte new file mode 100644 index 0000000..d93299e --- /dev/null +++ b/frontend/src/lib/components/textfield/AddressField.svelte @@ -0,0 +1,49 @@ + + + + + diff --git a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte index 36107e0..ab8b45b 100644 --- a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte +++ b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte @@ -9,7 +9,7 @@ import SplitLayout from '$lib/components/layout/SplitLayout.svelte'; import SelectField from '$lib/components/select/SelectField.svelte'; import EmailField from '$lib/components/textfield/EmailField.svelte'; - import IdField from '$lib/components/textfield/IdField.svelte'; + import AddressField from '$lib/components/textfield/AddressField.svelte'; import NameField from '$lib/components/textfield/NameField.svelte'; import TelephoneField from '$lib/components/textfield/TelephoneField.svelte'; import TextField from '$lib/components/textfield/TextField.svelte'; @@ -290,6 +290,7 @@ values.candidate.zip ]; values.candidate.address = addressArray.map((x) => x.replaceAll(',', '').trim()).join(','); + console.log(values.candidate.address) // @ts-ignore delete values.candidate.street; // @ts-ignore @@ -417,6 +418,8 @@ (x) => (x.telephone = x.telephone != '' ? formatTelephone(x.telephone) : '') ); + const addressArray = details.candidate.address.split(','); + const streetHouseNumber = addressArray[0].split(' '); form.set({ gdpr: true, linkOk: true, @@ -425,8 +428,8 @@ personalIdErr: false, candidate: { ...details.candidate, - street: details.candidate.address.split(',')[0].split(' ')[0], - houseNumber: details.candidate.address.split(',')[0].split(' ')[1], + street: streetHouseNumber.slice(0, streetHouseNumber.length - 1).join(' ').trim(), + houseNumber: streetHouseNumber[streetHouseNumber.length - 1], city: details.candidate.address.split(',')[1], zip: details.candidate.address.split(',')[2], // @ts-ignore @@ -578,11 +581,11 @@
- From 101f8b1929d5b7c20ec7f2ea29176a3867193be2 Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Fri, 24 Feb 2023 15:09:07 +0100 Subject: [PATCH 3/5] refactor: console.log() cleanup --- frontend/src/lib/components/textfield/AddressField.svelte | 2 -- .../routes/(candidate)/(authenticated)/register/+page.svelte | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/frontend/src/lib/components/textfield/AddressField.svelte b/frontend/src/lib/components/textfield/AddressField.svelte index d93299e..b269916 100644 --- a/frontend/src/lib/components/textfield/AddressField.svelte +++ b/frontend/src/lib/components/textfield/AddressField.svelte @@ -10,7 +10,6 @@ let value: string = ''; - console.log(valueLeft, valueRight); if (valueLeft && valueRight) { value = `${valueLeft} ${valueRight}`; } else if (valueLeft) { @@ -23,7 +22,6 @@ if (parsed.length >= 2) { valueLeft = parsed.slice(0, parsed.length - 1).join(' '); valueRight = parsed[parsed.length - 1]; - console.log(valueLeft, valueRight); } else { valueLeft = parsed[0]; valueRight = ''; diff --git a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte index ab8b45b..9f44d6f 100644 --- a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte +++ b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte @@ -290,7 +290,6 @@ values.candidate.zip ]; values.candidate.address = addressArray.map((x) => x.replaceAll(',', '').trim()).join(','); - console.log(values.candidate.address) // @ts-ignore delete values.candidate.street; // @ts-ignore @@ -306,7 +305,7 @@ } catch (e) { values = oldValues; $form = oldValues; - console.error('error while submitting data: ' + e); + pushErrorText('Neznámá chyba při odesílání dat.'); } } }; @@ -455,7 +454,6 @@ let lastCitizenshipSelected = $form.candidate.citizenship; $: if ($form.candidate.citizenship !== lastCitizenshipSelected) { - console.log('citizenship changed'); lastCitizenshipSelected = $form.candidate.citizenship; $form.candidate.birthdate = ''; $form.candidate.sex = ''; From aa99419d9d4d9dbdc04e50a4aa9d77445f1acb29 Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Fri, 24 Feb 2023 15:12:59 +0100 Subject: [PATCH 4/5] fix: accountLinkCheckBox text typo --- frontend/src/translations/cs/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/translations/cs/index.ts b/frontend/src/translations/cs/index.ts index fc140a6..0ee328c 100644 --- a/frontend/src/translations/cs/index.ts +++ b/frontend/src/translations/cs/index.ts @@ -115,7 +115,7 @@ const cs: BaseTranslation = { }, single: { title: 'Ano, přihlášku na SSPŠaG jsem podával/a jen jednu ({first:number})', - title2: 'Ne, přihlášku na SSPŠaG jsem podával více přihlášek' + title2: 'Ne, na SSPŠaG jsem podával více přihlášek' } }, personalIdConfirmCheckBox: { From 1095a0c90a886d569a1caa65740a4c3de33833ac Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Fri, 24 Feb 2023 15:27:51 +0100 Subject: [PATCH 5/5] fix: default address helper text --- frontend/src/lib/components/textfield/AddressField.svelte | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/lib/components/textfield/AddressField.svelte b/frontend/src/lib/components/textfield/AddressField.svelte index b269916..555ac30 100644 --- a/frontend/src/lib/components/textfield/AddressField.svelte +++ b/frontend/src/lib/components/textfield/AddressField.svelte @@ -1,8 +1,7 @@