From d1fc6374b1d90910bfc56c2bf49bd2b5c707d532 Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Sat, 21 Jan 2023 18:21:24 +0100 Subject: [PATCH] feat: bigger register views --- .../lib/components/layout/SplitLayout.svelte | 4 +- frontend/src/lib/stores/candidate.ts | 8 + .../[code=application]/+page.server.ts | 4 + .../(authenticated)/register/+page.svelte | 352 +++++++++--------- 4 files changed, 190 insertions(+), 178 deletions(-) diff --git a/frontend/src/lib/components/layout/SplitLayout.svelte b/frontend/src/lib/components/layout/SplitLayout.svelte index eeb618b..5726f5c 100644 --- a/frontend/src/lib/components/layout/SplitLayout.svelte +++ b/frontend/src/lib/components/layout/SplitLayout.svelte @@ -49,8 +49,8 @@ } .view { @apply z-10; - @apply absolute top-0 right-0 bottom-0 left-0 m-auto md:top-auto md:bottom-auto md:left-auto md:m-0; - @apply md:h-screen md:w-[50vw]; + @apply absolute top-0 right-0 bottom-0 m-auto md:top-auto md:bottom-auto md:left-auto md:m-0; + @apply md:h-screen md:w-[75vw]; @apply md:my-auto; @apply bg-white; } diff --git a/frontend/src/lib/stores/candidate.ts b/frontend/src/lib/stores/candidate.ts index 9b94cf8..7b22dc7 100644 --- a/frontend/src/lib/stores/candidate.ts +++ b/frontend/src/lib/stores/candidate.ts @@ -5,9 +5,11 @@ export interface CandidateData { candidate: { name: string; surname: string; + birthSurname: string; birthplace: string; birthdate: string; address: string; + letterAddress: string; telephone: string; citizenship: string; email: string; @@ -16,6 +18,8 @@ export interface CandidateData { schoolName: string; healthInsurance: string; grades: Array; + firstSchool: string; + secondSchool: string; testLanguage: string; }; parents: Array<{ @@ -66,9 +70,11 @@ export const candidateData = writable({ candidate: { name: '', surname: '', + birthSurname: '', birthplace: '', birthdate: '', address: '', + letterAddress: '', telephone: '', citizenship: '', email: '', @@ -77,6 +83,8 @@ export const candidateData = writable({ schoolName: '', healthInsurance: '', grades: [], + firstSchool: '', + secondSchool: '', testLanguage: '' }, parents: [] diff --git a/frontend/src/routes/(admin)/admin/(authenticated)/candidate/[code=application]/+page.server.ts b/frontend/src/routes/(admin)/admin/(authenticated)/candidate/[code=application]/+page.server.ts index 5088c69..ad436d9 100644 --- a/frontend/src/routes/(admin)/admin/(authenticated)/candidate/[code=application]/+page.server.ts +++ b/frontend/src/routes/(admin)/admin/(authenticated)/candidate/[code=application]/+page.server.ts @@ -10,9 +10,11 @@ export const load: PageServerLoad = async ({ fetch, params }) => { candidate: { name: '', surname: '', + birthSurname: '', birthplace: '', birthdate: '', address: '', + letterAddress: '', telephone: '', citizenship: '', email: '', @@ -21,6 +23,8 @@ export const load: PageServerLoad = async ({ fetch, params }) => { schoolName: '', healthInsurance: '', grades: [], + firstSchool: '', + secondSchool: '', testLanguage: '' }, parents: [] diff --git a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte index f57d9b6..a27e294 100644 --- a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte +++ b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte @@ -23,9 +23,9 @@ import AccountLinkCheckBox from '$lib/components/checkbox/AccountLinkCheckBox.svelte'; import GradesTable from '$lib/components/grades/GradesTable.svelte'; - const pageCount = 7; let pageIndex = 0; - let pagesFilled = [false, false, false, false, false, false, false]; + let pagesFilled = [false, false, false, false, false, false]; + const pageCount = pagesFilled.length; let pageTexts = [ 'Zpracování osobních údajů', 'Registrace', @@ -39,6 +39,7 @@ let details = data.candidate; let baseCandidateDetails = data.whoami; + let personalIdBirthdateMatch = true; const formInitialValues = { gdpr: false, linkOk: false, @@ -46,12 +47,14 @@ candidate: { name: '', surname: '', + birthSurname: '', email: '', telephone: '', birthplace: '', birthdate: '', sex: '', address: '', + letterAddress: '', street: '', houseNumber: '', city: '', @@ -61,6 +64,8 @@ schoolName: '', healthInsurance: '', grades: [], + firstSchool: '', + secondSchool: '', testLanguage: '', }, parents: [ @@ -225,28 +230,31 @@ }; const onSubmit = async (values: CandidateData) => { + if (pageIndex === 3) { + if (values.candidate.citizenship === 'Česká republika') { + if ( + !isPersonalIdNumberWithBirthdateValid( + values.candidate.personalIdNumber, + values.candidate.birthdate + ) + ) { + toast.push('Rodné číslo neodpovídá oficiální specifikaci či datumu narození', { + theme: { + '--toastColor': 'mintcream', + '--toastBackground': '#b91c1c', + '--toastBarBackground': '#7f1d1d' + } + }); + personalIdBirthdateMatch = false; + throw new Error('Rodné číslo neodpovídá datumu narození'); + } + } + personalIdBirthdateMatch = true; + } if (pageIndex === pageCount) { // clone values to oldValues let oldValues = JSON.parse(JSON.stringify(values)); try { - if (values.candidate.citizenship === 'Česká republika') { - if ( - !isPersonalIdNumberWithBirthdateValid( - values.candidate.personalIdNumber, - values.candidate.birthdate - ) - ) { - // alert('Rodné číslo neodpovídá oficiální specifikaci či datumu narození'); // TODO: alerts - toast.push('Rodné číslo neodpovídá oficiální specifikaci či datumu narození', { - theme: { - '--toastColor': 'mintcream', - '--toastBackground': '#b91c1c', - '--toastBarBackground': '#7f1d1d' - } - }); - throw new Error('Rodné číslo neodpovídá datumu narození'); - } - } // @ts-ignore // love javascript delete values.undefined; // convert birthdate from dd.mm.yyyy to yyyy-mm-dd @@ -314,7 +322,11 @@ $typedErrors['candidate']['name'] || $typedErrors['candidate']['surname'] || $typedErrors['candidate']['email'] || - $typedErrors['candidate']['telephone'] + $typedErrors['candidate']['telephone'] || + $typedErrors['candidate']['city'] || + $typedErrors['candidate']['street'] || + $typedErrors['candidate']['houseNumber'] || + $typedErrors['candidate']['zip'] ) { return true; } @@ -322,13 +334,15 @@ case 3: if ( - $typedErrors['candidate']['birthplace'] || + $typedErrors['candidate']['citizenship'] || + $typedErrors['candidate']['personalIdNumber'] || + $typedErrors['candidate']['schoolName'] || + $typedErrors['candidate']['healthInsurance'] || $typedErrors['candidate']['birthdate'] || - $typedErrors['candidate']['street'] || - $typedErrors['candidate']['houseNumber'] || - $typedErrors['candidate']['city'] || - $typedErrors['candidate']['zip'] - // $typedErrors['candidate']['address'] + $typedErrors['candidate']['birthplace'] || + $typedErrors['candidate']['personalIdNumber'] || + $typedErrors['candidate']['testLanguage'] || + !personalIdBirthdateMatch ) { return true; } @@ -354,16 +368,6 @@ } break; case 6: - if ( - $typedErrors['candidate']['citizenship'] || - $typedErrors['candidate']['personalIdNumber'] || - $typedErrors['candidate']['schoolName'] || - $typedErrors['candidate']['healthInsurance'] - ) { - return true; - } - break; - case 7: if ($typedErrors["candidate"]["grades"].length > 0) return true; break; default: @@ -417,11 +421,11 @@ -
-
+
+
{#if pageIndex !== 0 && pageIndex !== 7} -
+
{/if} @@ -465,29 +469,72 @@ V rámci usnadnění přijímacího řízení jsme připravili online formulář, který Vám pomůže s vyplněním potřebných údajů.

-
- - - - - - - - - +
+
+
+ + + + + + +
+
+ + + + + + +
+ + + +
+
+ + + + + + +
{:else if pageIndex === 3} @@ -496,53 +543,24 @@ 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é.

-
- - + + - - +
-
- - - - - -
- -
-
-
-
-
+ +
+
+ {#if $form.candidate.citizenship === 'Česká republika' || !$form.candidate.citizenship} + + {:else} + + {/if}
+
+ + {#if $form.candidate.citizenship === 'Česká republika' || !$form.candidate.citizenship} + + {:else} + + {/if} + + + + + +
+ {:else if pageIndex === 4}

{pageTexts[3]}

@@ -619,75 +688,6 @@

{:else if pageIndex === 6} -

{pageTexts[5]}

-

- Zadejte prosím své občanství, rodné číslo, či jeho alternativu Vaší země a obor na který - se hlásíte. -

-
-
- - - - - - -
-
- - {#if $form.candidate.citizenship === 'Česká republika' || !$form.candidate.citizenship} - - {:else} - - {/if} - - - - - -
-
-
- {#if $form.candidate.citizenship === 'Česká republika' || !$form.candidate.citizenship} - - {:else} - - {/if} -
- {:else if pageIndex === 7}

{pageTexts[5]}

Přidejte prosím přepis Vaších známek z posledních dvou let studia @@ -698,7 +698,7 @@ /> {/if}

-
+
{ @@ -716,7 +716,7 @@ />
-
+
{#each Array(pageCount + 1) as _, i}