refactored more error code
This commit is contained in:
@@ -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} />
|
||||
|
||||
Reference in New Issue
Block a user