Portfolio/frontend/src/lib/components/select/SchoolSelect.svelte
2023-01-22 19:17:31 +01:00

32 lines
No EOL
876 B
Svelte

<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';
let schools: string[] = [];
onMount(async () => {
schools = await fetch('/schoollist.txt')
.then((response) => response.text())
.then((text) => text.split(';'));
});
export let selectedSchool: School;
export let schoolName: string = selectedSchool.name;
$: selectedSchool.name = schoolName;
</script>
<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>