preparing times list
This commit is contained in:
@@ -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>
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user