preparing times list

This commit is contained in:
2025-07-14 17:51:08 +02:00
parent 9c7f152fb9
commit 65b5dded01
2 changed files with 30 additions and 1 deletions

View File

@@ -17,6 +17,10 @@
onSelect({item:item});
close();
}
function timeSelected(time){
console.log({timeSelected:time});
}
</script>
<style>
@@ -48,6 +52,6 @@
{:else if select == 1}
<EstimateList company_id={doc.company.id} onSelect={estimateSelected} />
{:else}
<TimeList />
<TimeList company_id={doc.company.id} onSelect={timeSelected} />
{/if}
</div>

View File

@@ -1,7 +1,32 @@
<script>
import { t } from '../../translations.svelte.js';
import { onMount } from 'svelte';
let { company_id, onSelect = (time) => {} } = $props();
let times = $state(null);
let error = $state(null);
async function loadTimes(){
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/times/list`;
let data = { company_id: company_id };
const resp = await fetch(url,{
credentials:'include',
method: 'POST',
body: JSON.stringify(data)
});
if (resp.ok){
times = await resp.json();
} else {
error = await resp.body();
}
}
onMount(loadTimes);
</script>
<div>
<h1>Times</h1>
{#if times}
{/if}
</div>