From 9932ce87b7bf0b0dcc6856c5df16873bdf904e8f Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Sat, 4 Feb 2023 15:11:00 +0100 Subject: [PATCH 01/22] feat: more tolerant schoolselect search --- .../select/SchoolSelect/SchoolSelect.svelte | 13 +++++- .../(authenticated)/register/+page.svelte | 43 +++++++++++++++++-- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/frontend/src/lib/components/select/SchoolSelect/SchoolSelect.svelte b/frontend/src/lib/components/select/SchoolSelect/SchoolSelect.svelte index 220fcd8..8ba52e1 100644 --- a/frontend/src/lib/components/select/SchoolSelect/SchoolSelect.svelte +++ b/frontend/src/lib/components/select/SchoolSelect/SchoolSelect.svelte @@ -13,7 +13,18 @@ let storageArr: Array = []; if (schoolNameInputValue) { schoolList.forEach((school) => { - if (school.toLowerCase().startsWith(schoolNameInputValue.toLowerCase())) { + if ( + school + .toLowerCase() + .normalize('NFD') + .replace(/[\u0300-\u036f]/g, '') + .includes( + schoolNameInputValue + .toLowerCase() + .normalize('NFD') + .replace(/[\u0300-\u036f]/g, '') + ) + ) { storageArr = [...storageArr, makeMatchBold(school)]; } }); diff --git a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte index b37a10f..e139b50 100644 --- a/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte +++ b/frontend/src/routes/(candidate)/(authenticated)/register/+page.svelte @@ -27,6 +27,7 @@ import PersonalIdErrorModal from '$lib/components/modal/PersonalIdErrorModal.svelte'; import LinkErrorModal from '$lib/components/modal/LinkErrorModal.svelte'; import type { Writable } from 'svelte/store'; + import schoollistString from '$lib/assets/schoollist.txt?raw'; let pageIndex = 0; let pagesFilled = [false, false, false, false, false, false, false, false]; @@ -146,11 +147,23 @@ ) .required(), firstSchool: yup.object().shape({ - name: yup.string().required(), + name: yup + .string() + .required() + .test((_val) => { + if (!_val) return false; + return schoollistString.split(';').includes(_val); + }), field: yup.string().required() }), secondSchool: yup.object().shape({ - name: yup.string().required(), + name: yup + .string() + .required() + .test((_val) => { + if (!_val) return false; + return schoollistString.split(';').includes(_val); + }), field: yup.string().required() }), testLanguage: yup.string().required() @@ -442,7 +455,10 @@ personalIdNumber={baseCandidateDetails.personalIdNumber} /> {:else if visibleModals.linkErrorModal} - (visibleModals.linkErrorModal = false)} /> + (visibleModals.linkErrorModal = false)} + /> {/if}
@@ -720,18 +736,37 @@
{:else if pageIndex === 7}

{pageTexts[5]}

-

+

{$LL.candidate.register.seventh.description()}

+

+ První škola - termín JPZ: 13. 4. 2023 +

+ + + + + +

+ Druhá škola - termín JPZ: 14. 4. 2023 +

Date: Sat, 4 Feb 2023 15:17:57 +0100 Subject: [PATCH 02/22] feat: schoolist splits only once --- .../lib/components/select/SchoolSelect/SchoolSelect.svelte | 3 +-- .../(candidate)/(authenticated)/register/+page.svelte | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib/components/select/SchoolSelect/SchoolSelect.svelte b/frontend/src/lib/components/select/SchoolSelect/SchoolSelect.svelte index 8ba52e1..f83bd7a 100644 --- a/frontend/src/lib/components/select/SchoolSelect/SchoolSelect.svelte +++ b/frontend/src/lib/components/select/SchoolSelect/SchoolSelect.svelte @@ -1,11 +1,10 @@ +
diff --git a/frontend/src/lib/components/dashboard/DashboardInfoCard.svelte b/frontend/src/lib/components/dashboard/DashboardInfoCard.svelte index c51376d..b23d645 100644 --- a/frontend/src/lib/components/dashboard/DashboardInfoCard.svelte +++ b/frontend/src/lib/components/dashboard/DashboardInfoCard.svelte @@ -15,6 +15,7 @@ import { baseCandidateData, candidateData } from '$lib/stores/candidate'; import tippy, { sticky } from 'tippy.js'; import { goto } from '$app/navigation'; + import { pushErrorText } from '$lib/utils/toast'; export let title: string; export let status: Status; @@ -62,7 +63,7 @@ document.body.appendChild(link); link.click(); } catch (e) { - console.log(e); + pushErrorText("Chyba při stahování portfolia"); } }; diff --git a/frontend/src/lib/components/dashboard/DashboardUploadCard.svelte b/frontend/src/lib/components/dashboard/DashboardUploadCard.svelte index b1aefa8..07aa9f1 100644 --- a/frontend/src/lib/components/dashboard/DashboardUploadCard.svelte +++ b/frontend/src/lib/components/dashboard/DashboardUploadCard.svelte @@ -31,12 +31,10 @@ $: if ($submissionProgress) { status = getStatus(); - // console.log('type' + fileType + ' status: ' + status); fileDropped = status === 'uploaded' || status === 'submitted'; } const getStatus = (): Status => { - console.log($submissionProgress); switch ($submissionProgress.status) { case UploadStatus.None: return 'missing'; @@ -71,7 +69,6 @@ }; const onFileDrop = (dropped: Files) => { - console.log(dropped); if (dropped.accepted.length > 0) { fileDropped = true; const file = dropped.accepted[0]; @@ -79,7 +76,6 @@ dispatch('filedrop', { file: file, callback: (progressEvent: AxiosProgressEvent) => { - console.log(progressEvent.bytes); progress = progressEvent.progress!; bytesTotal = progressEvent.total ?? 0; } diff --git a/frontend/src/lib/components/textfield/TelephoneField.svelte b/frontend/src/lib/components/textfield/TelephoneField.svelte index ed5c28c..c4a9873 100644 --- a/frontend/src/lib/components/textfield/TelephoneField.svelte +++ b/frontend/src/lib/components/textfield/TelephoneField.svelte @@ -20,7 +20,6 @@ if (number !== null && number !== undefined) { country = number.country!; } - // console.log(country); } // Validity diff --git a/frontend/src/lib/utils/countries.ts b/frontend/src/lib/utils/countries.ts new file mode 100644 index 0000000..2ea26c4 --- /dev/null +++ b/frontend/src/lib/utils/countries.ts @@ -0,0 +1 @@ +export const countries = ["Afghanistan","Albania","Algeria","Andorra","Angola","Anguilla","Antigua & Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia & Herzegovina","Botswana","Brazil","British Virgin Islands","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Cape Verde","Cayman Islands","Chad","Chile","China","Colombia","Congo","Cook Islands","Costa Rica","Cote D Ivoire","Croatia","Cruise Ship","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea","Estonia","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Polynesia","French West Indies","Gabon","Gambia","Georgia","Germany","Ghana","Gibraltar","Greece","Greenland","Grenada","Guam","Guatemala","Guernsey","Guinea","Guinea Bissau","Guyana","Haiti","Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Isle of Man","Israel","Italy","Jamaica","Japan","Jersey","Jordan","Kazakhstan","Kenya","Kuwait","Kyrgyz Republic","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macau","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Mauritania","Mauritius","Mexico","Moldova","Monaco","Mongolia","Montenegro","Montserrat","Morocco","Mozambique","Namibia","Nepal","Netherlands","Netherlands Antilles","New Caledonia","New Zealand","Nicaragua","Niger","Nigeria","Norway","Oman","Pakistan","Palestine","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Puerto Rico","Qatar","Reunion","Romania","Russia","Rwanda","Saint Pierre & Miquelon","Samoa","San Marino","Satellite","Saudi Arabia","Senegal","Serbia","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","South Africa","South Korea","Spain","Sri Lanka","St Kitts & Nevis","St Lucia","St Vincent","St. Lucia","Sudan","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Timor L'Este","Togo","Tonga","Trinidad & Tobago","Tunisia","Turkey","Turkmenistan","Turks & Caicos","Uganda","Ukraine","United Arab Emirates","United Kingdom","Uruguay","Uzbekistan","Venezuela","Vietnam","Virgin Islands (US)","Yemen","Zambia","Zimbabwe"]; \ No newline at end of file diff --git a/frontend/src/lib/utils/toast.ts b/frontend/src/lib/utils/toast.ts new file mode 100644 index 0000000..096af11 --- /dev/null +++ b/frontend/src/lib/utils/toast.ts @@ -0,0 +1,11 @@ +import { toast } from "@zerodevx/svelte-toast"; + +export const pushErrorText = (text: string) => { + toast.push(text, { + theme: { + '--toastColor': 'mintcream', + '--toastBackground': '#b91c1c', + '--toastBarBackground': '#7f1d1d' + } + }); +}; \ No newline at end of file diff --git a/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte b/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte index 9738767..ba4f391 100644 --- a/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte +++ b/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte @@ -11,6 +11,8 @@ import bacgkround from '$lib/assets/background.jpg'; import Logout from '$lib/components/icons/Logout.svelte'; import { goto } from '$app/navigation'; + import { pushErrorText } from '$lib/utils/toast'; + import { SvelteToast } from '@zerodevx/svelte-toast'; export let data: PageServerData; @@ -20,7 +22,7 @@ try { candidates = await apiListCandidates(undefined, activeFilter.filter); } catch { - console.log('error'); + pushErrorText('Nepodařilo se načíst uchazeče'); } }; @@ -93,7 +95,7 @@ link.setAttribute('download', 'UCHAZECI' + '.csv'); link.click(); } catch (e) { - console.log(e); + pushErrorText('Nepodařilo se stáhnout CSV'); } }; @@ -110,6 +112,7 @@ {/if}
+
Background
diff --git a/frontend/src/routes/(admin)/admin/auth/login/+page.svelte b/frontend/src/routes/(admin)/admin/auth/login/+page.svelte index ce16af7..c9af6e9 100644 --- a/frontend/src/routes/(admin)/admin/auth/login/+page.svelte +++ b/frontend/src/routes/(admin)/admin/auth/login/+page.svelte @@ -10,6 +10,8 @@ import { goto } from '$app/navigation'; import Submit from '$lib/components/button/Submit.svelte'; import PasswordField from '$lib/components/textfield/PasswordField.svelte'; + import { SvelteToast } from '@zerodevx/svelte-toast'; + import { pushErrorText } from '$lib/utils/toast'; let adminIdValue = ''; let adminPasswordValue = ''; @@ -19,11 +21,12 @@ await apiLogin({ adminId: Number(adminIdValue), password: adminPasswordValue }); goto('/admin/dashboard'); } catch (e) { - console.log(e); + pushErrorText('Neplatné heslo nebo ID!'); } }; +
{ - console.log('submit button clicked'); - console.log(pagesFilled.map((_, i) => !isPageInvalid(i))); - if (pageIndex === pageCount) { - console.log('submitting'); // clone values to oldValues let oldValues = JSON.parse(JSON.stringify(values)); try { @@ -793,11 +790,9 @@ { if (pageIndex === 4) { - console.log('validating personal id'); validatePersonalId(); } await handleSubmit(e); - console.log(pagesFilled.map((_, i) => !isPageInvalid(i))); if (isPageInvalid(pageIndex)) return; if (pageIndex !== pageCount) { pagesFilled[pageIndex] = true; diff --git a/frontend/src/routes/(candidate)/auth/login/[code=application]/+page.svelte b/frontend/src/routes/(candidate)/auth/login/[code=application]/+page.svelte index 278dde8..cdf9d40 100644 --- a/frontend/src/routes/(candidate)/auth/login/[code=application]/+page.svelte +++ b/frontend/src/routes/(candidate)/auth/login/[code=application]/+page.svelte @@ -47,7 +47,6 @@ } const submit = async () => { - console.log('submitting: ', codeValueArray); try { await apiLogin({ applicationId, password: codeValueMobile }); goto('/dashboard'); From bcc8d38f09cd786a374fe99ec791cd358222d0c0 Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Sat, 4 Feb 2023 15:47:25 +0100 Subject: [PATCH 05/22] feat: ignore submit enter on page with SchoolSelect --- .../src/lib/components/button/Submit.svelte | 3 ++- .../(authenticated)/register/+page.svelte | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib/components/button/Submit.svelte b/frontend/src/lib/components/button/Submit.svelte index 4c51767..c46e834 100644 --- a/frontend/src/lib/components/button/Submit.svelte +++ b/frontend/src/lib/components/button/Submit.svelte @@ -1,12 +1,13 @@
@@ -25,6 +32,23 @@ {/each} + +