diff --git a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte index 7d1d74d..6ed6e52 100644 --- a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte +++ b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte @@ -18,7 +18,7 @@ import type { Writable } from 'svelte/store'; import * as yup from 'yup'; - const pageCount = 3; + const pageCount = 4; let pageIndex = 0; let pagesFilled = 0; @@ -34,9 +34,15 @@ address: '', citizenship: '', personalIdNumber: '', - study: '', + study: '' }, parents: [ + { + name: '', + surname: '', + email: '', + telephone: '' + }, { name: '', surname: '', @@ -66,20 +72,37 @@ personalIdNumber: yup.string().required(), study: yup.string().required() }), - parents: yup - .array() - .of( - yup.object().shape({ - name: yup.string().required(), - surname: yup.string().required(), - email: yup.string().email().required(), - telephone: yup - .string() - .required() - .matches(/^\+\d{1,3} \d{3} \d{3} \d{3}$/) + parents: yup.array().of( + yup.object().shape({ + name: yup.string().test((_val, context) => { + if (context.path.includes('parents[1]')) { + return true; + } + return _val !== ''; + }), + surname: yup.string().test((_val, context) => { + if (context.path.includes('parents[1]')) { + return true; + } + return _val !== ''; + }), + email: yup + .string() + .email() + .test((_val, context) => { + if (context.path.includes('parents[1]')) { + return true; + } + return _val !== ''; + }), + telephone: yup.string().test((_val, context) => { + if (context.path.includes('parents[1]')) { + return true; + } + return _val?.match(/^\+\d{1,3} \d{3} \d{3} \d{3}$/) !== null; }) - ) - .required() + }) + ) }); const { form, errors, handleSubmit, handleChange } = createForm({ @@ -145,14 +168,16 @@ case 1: if ( /* $typedErrors.birthdurname || */ $typedErrors['candidate']['birthplace'] || - $typedErrors['candidate']['birthdate'] /* || $typedErrors.sex */ + $typedErrors['candidate']['birthdate'] || + $typedErrors['candidate']['address'] /* || $typedErrors.sex */ ) { return true; } break; case 2: if ( - $typedErrors['candidate']['address'] || + $typedErrors['parents'][0]['name'] || + $typedErrors['parents'][0]['surname'] || $typedErrors['parents'][0]['email'] || $typedErrors['parents'][0]['telephone'] ) { @@ -160,6 +185,16 @@ } break; case 3: + if ( + $typedErrors['parents'][1]['name'] || + $typedErrors['parents'][1]['surname'] || + $typedErrors['parents'][1]['email'] || + $typedErrors['parents'][1]['telephone'] + ) { + return true; + } + break; + case 4: if ( $typedErrors['candidate']['citizenship'] || $typedErrors['candidate']['personalIdNumber'] || @@ -224,12 +259,12 @@
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Fusce suscipit libero eget elit.
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Fusce suscipit libero eget elit.