code cleanup

This commit is contained in:
2025-07-30 09:03:47 +02:00
parent a77efb4e41
commit 631a527a5d
18 changed files with 257 additions and 184 deletions

View File

@@ -1,34 +1,35 @@
<script>
import { onMount } from 'svelte';
import { t } from '../../translations.svelte.js';
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
const router = useTinyRouter();
import { api } from '../../urls.svelte.js';
import { t } from '../../translations.svelte.js';
let { id } = $props();
let error = $state(null);
let doc = $state(null);
let email = $state(null);
let content = $state(null);
let subject = $state(null);
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();
async function loadDoc(){
let url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${id}`;
let url = api(`document/${id}`);
let resp = await fetch(url,{credentials:'include'});
if (resp.ok){
doc = await resp.json();
email = doc.customer.email;
doc = await resp.json();
email = doc.customer.email;
subject = t('new_document_from',t(doc.type),doc.company.name,doc.number),
error = null;
error = null;
} else {
error = await resp.text();
return;
}
url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${id}/settings`;
url = api(`document/${id}/settings`);
resp = await fetch(url,{credentials:'include'});
if (resp.ok){
const settings = await resp.json();
content = settings.content;
content = settings.content;
} else {
error = await resp.text();
}
@@ -36,11 +37,11 @@
async function doSend(){
var data = {email:email,subject:subject,content:content};
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${id}/send`;
const url = api(`document/${id}/send`);
const resp = await fetch(url,{
credentials:'include',
method: 'POST',
body: JSON.stringify(data)
credentials : 'include',
method : 'POST',
body : JSON.stringify(data)
});
if (resp.ok){
router.navigate(`/document?company_id=${doc.company.id}`);