implemented state update after sending document, returning to document list

This commit is contained in:
2025-07-17 21:16:37 +02:00
parent 6a58087ace
commit 763e5b447b
8 changed files with 43 additions and 13 deletions

View File

@@ -4,11 +4,14 @@
import { t } from '../../translations.svelte.js';
import TypeSelector from './TypeSelector.svelte';
let error = null;
let companies = {};
let documents = null;
let selected_company = null;
let router = useTinyRouter();
let company_id = +router.query.company_id;
let docType = 0;
async function loadCompanies(){
@@ -19,9 +22,20 @@
} else {
error = await resp.text();
}
if (company_id) {
for (var comp of companies){
if (comp.id == company_id){
load(comp);
break;
}
}
}
}
async function load(company){
router.navigate(`/document?company_id=${company.id}`);
selected_company = company;
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/list`;
const resp = await fetch(url,{

View File

@@ -37,13 +37,13 @@
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 resp = fetch(url,{
const resp = await fetch(url,{
credentials:'include',
method: 'POST',
body: JSON.stringify(data)
});
if (resp.ok){
router.navigate('/document');
router.navigate(`/document?company_id=${doc.company.id}`);
} else {
error = await resp.text();
}