mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-07 16:50:13 +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">
|
<script lang="ts">
|
||||||
|
import type { School } from '$lib/stores/candidate';
|
||||||
import AutoComplete from 'simple-svelte-autocomplete';
|
import AutoComplete from 'simple-svelte-autocomplete';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
// import schoollistString from '$lib/assets/schoollist.txt';
|
// import schoollistString from '$lib/assets/schoollist.txt';
|
||||||
|
|
@ -11,8 +12,21 @@ onMount(async () => {
|
||||||
.then((text) => text.split(';'));
|
.then((text) => text.split(';'));
|
||||||
});
|
});
|
||||||
|
|
||||||
export let selectedSchool: string = '';
|
export let selectedSchool: School;
|
||||||
|
export let schoolName: string = selectedSchool.name;
|
||||||
|
$: selectedSchool.name = schoolName;
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
Selected color: {selectedSchool}
|
<div class="flex flex-row">
|
||||||
<AutoComplete items={schools} bind:selectedItem={selectedSchool} />
|
<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 type { GradeBackend } from '$lib/components/grades/GradesTable.svelte';
|
||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
|
|
||||||
|
export interface School {
|
||||||
|
name: string;
|
||||||
|
field: string;
|
||||||
|
}
|
||||||
export interface CandidateData {
|
export interface CandidateData {
|
||||||
candidate: {
|
candidate: {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
@ -18,8 +23,8 @@ export interface CandidateData {
|
||||||
schoolName: string;
|
schoolName: string;
|
||||||
healthInsurance: string;
|
healthInsurance: string;
|
||||||
grades: Array<GradeBackend>;
|
grades: Array<GradeBackend>;
|
||||||
firstSchool: string;
|
firstSchool: School;
|
||||||
secondSchool: string;
|
secondSchool: School;
|
||||||
testLanguage: string;
|
testLanguage: string;
|
||||||
};
|
};
|
||||||
parents: Array<{
|
parents: Array<{
|
||||||
|
|
@ -83,8 +88,8 @@ export const candidateData = writable<CandidateData>({
|
||||||
schoolName: '',
|
schoolName: '',
|
||||||
healthInsurance: '',
|
healthInsurance: '',
|
||||||
grades: [],
|
grades: [],
|
||||||
firstSchool: '',
|
firstSchool: {name: '', field: ''},
|
||||||
secondSchool: '',
|
secondSchool: {name: '', field: ''},
|
||||||
testLanguage: ''
|
testLanguage: ''
|
||||||
},
|
},
|
||||||
parents: []
|
parents: []
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,10 @@
|
||||||
import type { CandidateData } from '$lib/stores/candidate';
|
import type { CandidateData } from '$lib/stores/candidate';
|
||||||
import AccountLinkCheckBox from '$lib/components/checkbox/AccountLinkCheckBox.svelte';
|
import AccountLinkCheckBox from '$lib/components/checkbox/AccountLinkCheckBox.svelte';
|
||||||
import GradesTable from '$lib/components/grades/GradesTable.svelte';
|
import GradesTable from '$lib/components/grades/GradesTable.svelte';
|
||||||
|
import SchoolSelect from '$lib/components/select/SchoolSelect.svelte';
|
||||||
|
|
||||||
let pageIndex = 0;
|
let pageIndex = 0;
|
||||||
let pagesFilled = [false, false, false, false, false, false];
|
let pagesFilled = [false, false, false, false, false, false, false];
|
||||||
const pageCount = pagesFilled.length;
|
const pageCount = pagesFilled.length;
|
||||||
let pageTexts = [
|
let pageTexts = [
|
||||||
'Zpracování osobních údajů',
|
'Zpracování osobních údajů',
|
||||||
|
|
@ -64,8 +65,8 @@
|
||||||
schoolName: '',
|
schoolName: '',
|
||||||
healthInsurance: '',
|
healthInsurance: '',
|
||||||
grades: [],
|
grades: [],
|
||||||
firstSchool: '',
|
firstSchool: {name: '', field: ''},
|
||||||
secondSchool: '',
|
secondSchool: {name: '', field: ''},
|
||||||
testLanguage: '',
|
testLanguage: '',
|
||||||
},
|
},
|
||||||
parents: [
|
parents: [
|
||||||
|
|
@ -127,6 +128,14 @@
|
||||||
})
|
})
|
||||||
.required()
|
.required()
|
||||||
).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(),
|
testLanguage: yup.string().required(),
|
||||||
}),
|
}),
|
||||||
parents: yup.array().of(
|
parents: yup.array().of(
|
||||||
|
|
@ -228,7 +237,7 @@
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
$: console.log($typedErrors);
|
||||||
const onSubmit = async (values: CandidateData) => {
|
const onSubmit = async (values: CandidateData) => {
|
||||||
if (pageIndex === 3) {
|
if (pageIndex === 3) {
|
||||||
if (values.candidate.citizenship === 'Česká republika') {
|
if (values.candidate.citizenship === 'Česká republika') {
|
||||||
|
|
@ -252,6 +261,7 @@
|
||||||
personalIdBirthdateMatch = true;
|
personalIdBirthdateMatch = true;
|
||||||
}
|
}
|
||||||
if (pageIndex === pageCount) {
|
if (pageIndex === pageCount) {
|
||||||
|
console.log('submitting');
|
||||||
// clone values to oldValues
|
// clone values to oldValues
|
||||||
let oldValues = JSON.parse(JSON.stringify(values));
|
let oldValues = JSON.parse(JSON.stringify(values));
|
||||||
try {
|
try {
|
||||||
|
|
@ -368,6 +378,15 @@
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 6:
|
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;
|
if ($typedErrors["candidate"]["grades"].length > 0) return true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -688,6 +707,16 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{:else if pageIndex === 6}
|
{: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>
|
<h1 class="title mt-8">{pageTexts[5]}</h1>
|
||||||
<p class="description mt-8 block text-center">
|
<p class="description mt-8 block text-center">
|
||||||
Přidejte prosím přepis Vaších známek z posledních dvou let studia
|
Přidejte prosím přepis Vaších známek z posledních dvou let studia
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue