feat: ignore submit enter on page with SchoolSelect

This commit is contained in:
Sebastian Pravda 2023-02-04 15:47:25 +01:00
parent cc5fa60c62
commit bcc8d38f09
No known key found for this signature in database
GPG key ID: F3BC84F08EFA3F57
2 changed files with 17 additions and 4 deletions

View file

@ -1,12 +1,13 @@
<script lang="ts"> <script lang="ts">
import { createEventDispatcher } from 'svelte'; import { createEventDispatcher } from 'svelte';
export let enterAllowed: boolean;
export let value: string; export let value: string;
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
const handleKeyDown = (e: KeyboardEvent) => { const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Enter') { if (enterAllowed && e.key === 'Enter') {
dispatch('click'); dispatch('click');
} }
}; };

View file

@ -28,7 +28,7 @@
import LinkErrorModal from '$lib/components/modal/LinkErrorModal.svelte'; import LinkErrorModal from '$lib/components/modal/LinkErrorModal.svelte';
import type { Writable } from 'svelte/store'; import type { Writable } from 'svelte/store';
import schoollistString from '$lib/assets/schoollist.txt?raw'; import schoollistString from '$lib/assets/schoollist.txt?raw';
import { countries } from '$lib/utils/countries'; import { pushErrorText } from '$lib/utils/toast';
let pageIndex = 0; let pageIndex = 0;
let pagesFilled = [false, false, false, false, false, false, false, false]; let pagesFilled = [false, false, false, false, false, false, false, false];
@ -154,7 +154,12 @@
.required() .required()
.test((_val) => { .test((_val) => {
if (!_val) return false; if (!_val) return false;
return schoolList.includes(_val); if (schoolList.includes(_val)) {
return true;
} else {
pushErrorText("Vyberte prosím školu ze seznamu.");
return false;
}
}), }),
field: yup.string().required() field: yup.string().required()
}), }),
@ -164,7 +169,13 @@
.required() .required()
.test((_val) => { .test((_val) => {
if (!_val) return false; if (!_val) return false;
return schoolList.includes(_val); if (!_val) return false;
if (schoolList.includes(_val)) {
return true;
} else {
pushErrorText("Vyberte prosím školu ze seznamu.");
return false;
}
}), }),
field: yup.string().required() field: yup.string().required()
}), }),
@ -788,6 +799,7 @@
<div class="bottom-1/24 absolute w-full"> <div class="bottom-1/24 absolute w-full">
<div class="field"> <div class="field">
<Submit <Submit
enterAllowed={pageIndex !== 7}
on:click={async (e) => { on:click={async (e) => {
if (pageIndex === 4) { if (pageIndex === 4) {
validatePersonalId(); validatePersonalId();