preparing document display
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
32
frontend/src/routes/document/View.svelte
Normal file
32
frontend/src/routes/document/View.svelte
Normal file
@@ -0,0 +1,32 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
|
||||
let { id } = $props();
|
||||
let error = null;
|
||||
let doc = $state(null);
|
||||
|
||||
async function loadDoc(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${id}`;
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok){
|
||||
doc = await resp.json();
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
onMount(loadDoc);
|
||||
</script>
|
||||
|
||||
|
||||
<fieldset>
|
||||
{#if error}
|
||||
<span class="error">{error}</span>
|
||||
{/if}
|
||||
{#if doc}
|
||||
<legend>{t('document.type_'+doc.type)} {doc.number}</legend>
|
||||
|
||||
{/if}
|
||||
</fieldset>
|
||||
Reference in New Issue
Block a user