mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-24 12:35:31 +00:00
feat: school selection PoC
This commit is contained in:
parent
6b07e2c629
commit
df6a496888
4 changed files with 63 additions and 11 deletions
|
|
@ -0,0 +1,4 @@
|
|||
<script lang="ts">
|
||||
export let title;
|
||||
export let description;
|
||||
</script>
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<script lang="ts">
|
||||
import type { School } from '$lib/stores/candidate';
|
||||
import AutoComplete from 'simple-svelte-autocomplete';
|
||||
import { onMount } from 'svelte';
|
||||
// import schoollistString from '$lib/assets/schoollist.txt';
|
||||
|
|
@ -11,8 +12,21 @@ onMount(async () => {
|
|||
.then((text) => text.split(';'));
|
||||
});
|
||||
|
||||
export let selectedSchool: string = '';
|
||||
export let selectedSchool: School;
|
||||
export let schoolName: string = selectedSchool.name;
|
||||
$: selectedSchool.name = schoolName;
|
||||
|
||||
</script>
|
||||
|
||||
Selected color: {selectedSchool}
|
||||
<AutoComplete items={schools} bind:selectedItem={selectedSchool} />
|
||||
<div class="flex flex-row">
|
||||
<div>
|
||||
<span>
|
||||
Selected school: {selectedSchool.name}
|
||||
</span>
|
||||
<AutoComplete items={schools} bind:selectedItem={schoolName} />
|
||||
</div>
|
||||
<div class="flex">
|
||||
<span>Obor: </span>
|
||||
<input type="text" bind:value={selectedSchool.field} />
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
import type { GradeBackend } from '$lib/components/grades/GradesTable.svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
|
||||
export interface School {
|
||||
name: string;
|
||||
field: string;
|
||||
}
|
||||
export interface CandidateData {
|
||||
candidate: {
|
||||
name: string;
|
||||
|
|
@ -18,8 +23,8 @@ export interface CandidateData {
|
|||
schoolName: string;
|
||||
healthInsurance: string;
|
||||
grades: Array<GradeBackend>;
|
||||
firstSchool: string;
|
||||
secondSchool: string;
|
||||
firstSchool: School;
|
||||
secondSchool: School;
|
||||
testLanguage: string;
|
||||
};
|
||||
parents: Array<{
|
||||
|
|
@ -83,8 +88,8 @@ export const candidateData = writable<CandidateData>({
|
|||
schoolName: '',
|
||||
healthInsurance: '',
|
||||
grades: [],
|
||||
firstSchool: '',
|
||||
secondSchool: '',
|
||||
firstSchool: {name: '', field: ''},
|
||||
secondSchool: {name: '', field: ''},
|
||||
testLanguage: ''
|
||||
},
|
||||
parents: []
|
||||
|
|
|
|||
|
|
@ -22,9 +22,10 @@
|
|||
import type { CandidateData } from '$lib/stores/candidate';
|
||||
import AccountLinkCheckBox from '$lib/components/checkbox/AccountLinkCheckBox.svelte';
|
||||
import GradesTable from '$lib/components/grades/GradesTable.svelte';
|
||||
import SchoolSelect from '$lib/components/select/SchoolSelect.svelte';
|
||||
|
||||
let pageIndex = 0;
|
||||
let pagesFilled = [false, false, false, false, false, false];
|
||||
let pagesFilled = [false, false, false, false, false, false, false];
|
||||
const pageCount = pagesFilled.length;
|
||||
let pageTexts = [
|
||||
'Zpracování osobních údajů',
|
||||
|
|
@ -64,8 +65,8 @@
|
|||
schoolName: '',
|
||||
healthInsurance: '',
|
||||
grades: [],
|
||||
firstSchool: '',
|
||||
secondSchool: '',
|
||||
firstSchool: {name: '', field: ''},
|
||||
secondSchool: {name: '', field: ''},
|
||||
testLanguage: '',
|
||||
},
|
||||
parents: [
|
||||
|
|
@ -127,6 +128,14 @@
|
|||
})
|
||||
.required()
|
||||
).required(),
|
||||
firstSchool: yup.object().shape({
|
||||
name: yup.string().required(),
|
||||
field: yup.string().required(),
|
||||
}),
|
||||
secondSchool: yup.object().shape({
|
||||
name: yup.string().required(),
|
||||
field: yup.string().required(),
|
||||
}),
|
||||
testLanguage: yup.string().required(),
|
||||
}),
|
||||
parents: yup.array().of(
|
||||
|
|
@ -228,7 +237,7 @@
|
|||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$: console.log($typedErrors);
|
||||
const onSubmit = async (values: CandidateData) => {
|
||||
if (pageIndex === 3) {
|
||||
if (values.candidate.citizenship === 'Česká republika') {
|
||||
|
|
@ -252,6 +261,7 @@
|
|||
personalIdBirthdateMatch = true;
|
||||
}
|
||||
if (pageIndex === pageCount) {
|
||||
console.log('submitting');
|
||||
// clone values to oldValues
|
||||
let oldValues = JSON.parse(JSON.stringify(values));
|
||||
try {
|
||||
|
|
@ -368,6 +378,15 @@
|
|||
}
|
||||
break;
|
||||
case 6:
|
||||
// @ts-ignore
|
||||
if ($typedErrors["candidate"]["firstSchool"].name || $typedErrors["candidate"]["firstSchool"].field ||
|
||||
// @ts-ignore
|
||||
$typedErrors["candidate"]["secondSchool"].name || $typedErrors["candidate"]["secondSchool"].field
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if ($typedErrors["candidate"]["grades"].length > 0) return true;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -688,6 +707,16 @@
|
|||
</span>
|
||||
</div>
|
||||
{:else if pageIndex === 6}
|
||||
<h1 class="title mt-8">Přihlášky na školy</h1>
|
||||
<div class="flex flex-col justify-between h-full">
|
||||
<span>
|
||||
<SchoolSelect bind:selectedSchool={$form.candidate.firstSchool}></SchoolSelect>
|
||||
</span>
|
||||
<span class="mt-10 w-full">
|
||||
<SchoolSelect bind:selectedSchool={$form.candidate.secondSchool}></SchoolSelect>
|
||||
</span>
|
||||
</div>
|
||||
{:else if pageIndex === 7}
|
||||
<h1 class="title mt-8">{pageTexts[5]}</h1>
|
||||
<p class="description mt-8 block text-center">
|
||||
Přidejte prosím přepis Vaších známek z posledních dvou let studia
|
||||
|
|
|
|||
Loading…
Reference in a new issue