working on project creation

This commit is contained in:
2025-07-18 15:35:37 +02:00
parent f5f08f244f
commit 9626d91ccb
12 changed files with 207 additions and 20 deletions

View File

@@ -0,0 +1,37 @@
<script>
import {onMount} from 'svelte';
import {t} from '../translations.svelte.js';
let { caption, onselect = (company) => console.log('selected '+company.name) } = $props();
let message = t('loading');
let companies = $state(null);
let value = 0;
async function loadCompanies(){
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/company/list`;
var resp = await fetch(url,{ credentials: 'include'});
if (resp.ok){
companies = await resp.json();
} else {
message = await resp.text();
}
}
function select(){
onselect(companies[value]);
}
onMount(loadCompanies)
</script>
{#if companies}
<select onchange={select} bind:value>
<option value={0}>{caption}</option>
{#each companies as company,idx}
<option value={idx}>{company.name}</option>
{/each}
</select>
{:else}
<span>{message}</span>
{/if}