From afe2b08eacd2b8f27a752c338c070758c6f4d512 Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Fri, 13 Jan 2023 18:49:45 +0100 Subject: [PATCH 1/5] feat: address formatting --- .../routes/(candidate)/(authenticated)/register/+page.svelte | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte index 53eaa15..4934821 100644 --- a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte +++ b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte @@ -83,7 +83,10 @@ .required() .matches(/^([0-3]?[0-9])\.(0?[1-9]|1[0-2])\.[0-9]{4}$/), sex: yup.string(), - address: yup.string().required(), + address: yup + .string() + .required() + .matches(/^[A-zÀ-ú]+\s[0-9]+,\s?[A-zÀ-ú]+,\s?[0-9]{3}\s[0-9]{2}$/), citizenship: yup.string().required(), personalIdNumber: yup.string().required(), study: yup.string().required() From 0e3efa32f7a28e9e473c3079dac792961c72ed4b Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Fri, 13 Jan 2023 19:45:25 +0100 Subject: [PATCH 2/5] feat: split address input to multiple html inputs --- .../lib/components/textfield/NameField.svelte | 2 +- .../(authenticated)/register/+page.svelte | 91 ++++++++++++++++--- 2 files changed, 78 insertions(+), 15 deletions(-) diff --git a/frontend/src/lib/components/textfield/NameField.svelte b/frontend/src/lib/components/textfield/NameField.svelte index 9d29811..dd185ea 100644 --- a/frontend/src/lib/components/textfield/NameField.svelte +++ b/frontend/src/lib/components/textfield/NameField.svelte @@ -2,7 +2,7 @@ import { onMount } from 'svelte'; import TextField from './TextField.svelte'; - let helperText: string = 'Zadejte jméno a příjmení. Například Radko Sáblík'; + export let helperText: string = 'Zadejte jméno a příjmení. Například Radko Sáblík'; export let placeholder: string = ''; export let valueName: string = ''; diff --git a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte index 4934821..b7370af 100644 --- a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte +++ b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte @@ -47,6 +47,10 @@ birthdate: '', sex: '', address: '', + street: '', + houseNumber: '', + city: '', + zip: '', citizenship: '', personalIdNumber: '', study: '' @@ -83,10 +87,11 @@ .required() .matches(/^([0-3]?[0-9])\.(0?[1-9]|1[0-2])\.[0-9]{4}$/), sex: yup.string(), - address: yup - .string() - .required() - .matches(/^[A-zÀ-ú]+\s[0-9]+,\s?[A-zÀ-ú]+,\s?[0-9]{3}\s[0-9]{2}$/), + address: yup.string(), + street: yup.string().required(), + houseNumber: yup.number().required(), + city: yup.string().required(), + zip: yup.string().required(), citizenship: yup.string().required(), personalIdNumber: yup.string().required(), study: yup.string().required() @@ -192,10 +197,12 @@ }; const onSubmit = async (values: CandidateData) => { + console.log('submit clicked') if (pageIndex === pageCount) { // clone values to oldValues let oldValues = JSON.parse(JSON.stringify(values)); try { + console.log('submitting values', values); if (values.candidate.citizenship === 'Česká republika') { if ( !isPersonalIdNumberWithBirthdateValid( @@ -228,6 +235,11 @@ values.parents = values.parents.filter( (x) => x.name !== '' && x.surname !== '' && x.email !== '' && x.telephone !== '' ); + // @ts-ignore + let addressArray: Array = [values.candidate.street + ' ' + values.candidate.houseNumber, values.candidate.city, values.candidate.zip]; + values.candidate.address = addressArray.map((x) => x.replaceAll(',', '').trim()).join(','); + // @ts-ignore + delete values.candidate.street;delete values.candidate.houseNumber;delete values.candidate.city;delete values.candidate.zip; await apiFillDetails(values); goto('/dashboard'); @@ -267,7 +279,11 @@ if ( $typedErrors['candidate']['birthplace'] || $typedErrors['candidate']['birthdate'] || - $typedErrors['candidate']['address'] + $typedErrors['candidate']['street'] || + $typedErrors['candidate']['houseNumber'] || + $typedErrors['candidate']['city'] || + $typedErrors['candidate']['zip'] + // $typedErrors['candidate']['address'] ) { return true; } @@ -321,7 +337,11 @@ form.set({ gdpr: true, candidate: { - ...details.candidate + ...details.candidate, + street: details.candidate.address.split(',')[0].split(' ')[0], + houseNumber: details.candidate.address.split(',')[0].split(' ')[1], + city: details.candidate.address.split(',')[1], + zip: details.candidate.address.split(',')[2] }, parents: [ { @@ -408,18 +428,61 @@ Pro registraci je potřeba vyplnit několik údajů o Vás. Tyto údaje budou použity pro přijímací řízení. Všechny údaje jsou důležité.

-
- - + + + - + + + + +
+
+ + + + Date: Fri, 13 Jan 2023 23:36:42 +0100 Subject: [PATCH 3/5] refactor: change city form helperText --- .../routes/(candidate)/(authenticated)/register/+page.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte index b7370af..03678bc 100644 --- a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte +++ b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte @@ -479,7 +479,7 @@ bind:value={$form.candidate.city} type="text" placeholder="Město" - helperText="Město" + helperText="Uveďte město" /> From 6b7abb5eedf73e35e4a81b641dcd5af6cbb56f2d Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Fri, 13 Jan 2023 23:39:52 +0100 Subject: [PATCH 4/5] fix: support houseNumbers with '/' --- .../routes/(candidate)/(authenticated)/register/+page.svelte | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte index 03678bc..015c489 100644 --- a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte +++ b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte @@ -89,7 +89,10 @@ sex: yup.string(), address: yup.string(), street: yup.string().required(), - houseNumber: yup.number().required(), + houseNumber: yup + .string() + .required() + .matches(/^[0-9]+(\/[0-9]+)?$/), city: yup.string().required(), zip: yup.string().required(), citizenship: yup.string().required(), From 8ff4881a0876f3b1ec72783f7f9418ac9b785476 Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Fri, 13 Jan 2023 23:42:59 +0100 Subject: [PATCH 5/5] refactor: code cleanup --- .../(authenticated)/register/+page.svelte | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte index 015c489..6b7b045 100644 --- a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte +++ b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte @@ -200,12 +200,10 @@ }; const onSubmit = async (values: CandidateData) => { - console.log('submit clicked') if (pageIndex === pageCount) { // clone values to oldValues let oldValues = JSON.parse(JSON.stringify(values)); try { - console.log('submitting values', values); if (values.candidate.citizenship === 'Česká republika') { if ( !isPersonalIdNumberWithBirthdateValid( @@ -432,16 +430,6 @@ přijímací řízení. Všechny údaje jsou důležité.

- -