refactored more error code

This commit is contained in:
2025-09-26 21:10:19 +02:00
parent e3b735bb7b
commit 2463f92b1c
23 changed files with 111 additions and 173 deletions

View File

@@ -3,12 +3,12 @@
import { useTinyRouter } from 'svelte-tiny-router';
import { api } from '../../urls.svelte.js';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte.js';
let content = $state(null);
let doc = $state(null);
let email = $state(null);
let error = $state(null);
const router = useTinyRouter();
let subject = $state(null);
let { id } = $props();
@@ -20,9 +20,9 @@
doc = await resp.json();
email = doc.customer.email;
subject = t('new_document_from',{type:t(doc.type),sender:doc.company.name,number:doc.number}),
error = null;
yikes();
} else {
error = await resp.text();
error(resp);
return;
}
url = api(`document/${id}/settings`);
@@ -31,7 +31,7 @@
const settings = await resp.json();
content = settings.content;
} else {
error = await resp.text();
error(resp);
}
}
@@ -46,17 +46,13 @@
if (resp.ok){
router.navigate(`/document?company_id=${doc.company.id}`);
} else {
error = await resp.text();
error(resp);
}
}
onMount(loadDoc);
</script>
{#if error}
<span class="error">{error}</span>
{/if}
<fieldset>
<legend>{t('customer_email')} / {t('subject')}</legend>
<input type="text" bind:value={email} />