preparing times list
This commit is contained in:
@@ -17,6 +17,10 @@
|
|||||||
onSelect({item:item});
|
onSelect({item:item});
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function timeSelected(time){
|
||||||
|
console.log({timeSelected:time});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -48,6 +52,6 @@
|
|||||||
{:else if select == 1}
|
{:else if select == 1}
|
||||||
<EstimateList company_id={doc.company.id} onSelect={estimateSelected} />
|
<EstimateList company_id={doc.company.id} onSelect={estimateSelected} />
|
||||||
{:else}
|
{:else}
|
||||||
<TimeList />
|
<TimeList company_id={doc.company.id} onSelect={timeSelected} />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -1,7 +1,32 @@
|
|||||||
<script>
|
<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>
|
</script>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h1>Times</h1>
|
<h1>Times</h1>
|
||||||
|
{#if times}
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
Reference in New Issue
Block a user