From d789c5b42d1f720bf95d68ff7d0a6e97426da663 Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Sun, 15 Jan 2023 11:51:45 +0100 Subject: [PATCH] feat: link account notification --- .../checkbox/AccountLinkCheckBox.svelte | 81 ++++++++++++++++++ frontend/src/lib/stores/candidate.ts | 7 +- .../(authenticated)/register/+page.svelte | 83 +++++++++++++++---- 3 files changed, 156 insertions(+), 15 deletions(-) create mode 100644 frontend/src/lib/components/checkbox/AccountLinkCheckBox.svelte diff --git a/frontend/src/lib/components/checkbox/AccountLinkCheckBox.svelte b/frontend/src/lib/components/checkbox/AccountLinkCheckBox.svelte new file mode 100644 index 0000000..465e731 --- /dev/null +++ b/frontend/src/lib/components/checkbox/AccountLinkCheckBox.svelte @@ -0,0 +1,81 @@ + + +
+ switchSelection(0)} + class:error + on:change + type="checkbox" + id="linkOk" + checked={linkOk} + class="peer hidden" + /> + +
+
+ switchSelection(1)} + on:change + type="checkbox" + id="linkError" + checked={linkError} + class="peer hidden" + /> + +
+ + diff --git a/frontend/src/lib/stores/candidate.ts b/frontend/src/lib/stores/candidate.ts index 3199fe6..2f2e1b9 100644 --- a/frontend/src/lib/stores/candidate.ts +++ b/frontend/src/lib/stores/candidate.ts @@ -42,8 +42,11 @@ export interface CreateCandidate { } export interface BaseCandidate { + currentApplication: number; applications: Array; personalIdNumber: string; + detailsFilled: boolean; + encryptedBy?: number; } export interface CreateCandidateLogin extends CreateCandidate { @@ -51,8 +54,10 @@ export interface CreateCandidateLogin extends CreateCandidate { } export const baseCandidateData = writable({ + currentApplication: 0, applications: [], - personalIdNumber: '' + personalIdNumber: '', + detailsFilled: false }); export const candidateData = writable({ diff --git a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte index 2004550..2661533 100644 --- a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte +++ b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte @@ -20,10 +20,11 @@ import type { Writable } from 'svelte/store'; import * as yup from 'yup'; import type { CandidateData } from '$lib/stores/candidate'; + import AccountLinkCheckBox from '$lib/components/checkbox/AccountLinkCheckBox.svelte'; - const pageCount = 5; + const pageCount = 6; let pageIndex = 0; - let pagesFilled = [false, false, false, false, false]; + let pagesFilled = [false, false, false, false, false, false]; let pageTexts = [ 'Zpracování osobních údajů', 'Registrace', @@ -35,9 +36,15 @@ export let data: PageData; let details = data.candidate; + let baseCandidateDetails = data.whoami; + + let detailsFilledByAnotherAccount = baseCandidateDetails.encryptedBy !== null && + baseCandidateDetails.currentApplication !== baseCandidateDetails.encryptedBy; const formInitialValues = { gdpr: false, + linkOk: false, + linkError: false, candidate: { name: '', surname: '', @@ -75,6 +82,8 @@ const formValidationSchema = yup.object().shape({ gdpr: yup.boolean().oneOf([true]), + linkOk: yup.boolean().oneOf([true]), + linkError: yup.boolean().oneOf([false]), candidate: yup.object().shape({ name: yup.string().required(), surname: yup.string().required(), @@ -265,11 +274,16 @@ const isPageInvalid = (index: number): boolean => { switch (index) { case 0: - if ($typedErrors['gdpr']) { + if ($typedErrors['linkOk'] || $typedErrors['linkError']) { return true; } break; case 1: + if ($typedErrors['gdpr']) { + return true; + } + break; + case 2: if ( $typedErrors['candidate']['name'] || $typedErrors['candidate']['surname'] || @@ -280,7 +294,7 @@ } break; - case 2: + case 3: if ( $typedErrors['candidate']['birthplace'] || $typedErrors['candidate']['birthdate'] || @@ -293,7 +307,7 @@ return true; } break; - case 3: + case 4: if ( $typedErrors['parents'][0]['name'] || $typedErrors['parents'][0]['surname'] || @@ -303,7 +317,7 @@ return true; } break; - case 4: + case 5: if ( $typedErrors['parents'][1]['name'] || $typedErrors['parents'][1]['surname'] || @@ -313,7 +327,7 @@ return true; } break; - case 5: + case 6: if ( $typedErrors['candidate']['citizenship'] || $typedErrors['candidate']['personalIdNumber'] || @@ -343,6 +357,8 @@ ); form.set({ gdpr: true, + linkOk: true, + linkError: false, candidate: { ...details.candidate, street: details.candidate.address.split(',')[0].split(' ')[0], @@ -364,8 +380,8 @@ } ] }); - pageIndex = 1; // skip gdpr page - pageTexts[1] = 'Úprava osobních údajů'; + pageIndex = 2; // skip gdpr page + pageTexts[2] = 'Úprava osobních údajů'; } @@ -378,6 +394,45 @@ + {:else} +
+

Údaje již vyplněny

+

+ Vaše osobní údaje již byly vyplněny přes Váš druhý účet ({baseCandidateDetails.encryptedBy}). + Vaše údaje byly zaznamenány a Vaše přihlášky byly propojeny. +

+
+ +
+
+ {/if} + {:else if pageIndex === 1}

{pageTexts[0]}

@@ -394,7 +449,7 @@ />

- {:else if pageIndex === 1} + {:else if pageIndex === 2}

{pageTexts[1]}

@@ -429,7 +484,7 @@

- {:else if pageIndex === 2} + {:else if pageIndex === 3}

{pageTexts[2]}

Pro registraci je potřeba vyplnit několik údajů o Vás. Tyto údaje budou použity pro @@ -505,7 +560,7 @@ /> - {:else if pageIndex === 3} + {:else if pageIndex === 4}

{pageTexts[3]}

Sběr dat o zákonném zástupci je klíčový pro získání důležitých kontaktů a informací. @@ -537,7 +592,7 @@ /> - {:else if pageIndex === 4} + {:else if pageIndex === 5}

{pageTexts[4]}

Zde můžete zadat údaje o druhém zákonném zástupci. Škole tím umožníte lépe komunikovat. @@ -569,7 +624,7 @@ /> - {:else if pageIndex === 5} + {:else if pageIndex === 6}

{pageTexts[5]}

Zadejte prosím své občanství, rodné číslo, či jeho alternativu Vaší země a obor na který