Files
Umbrella/frontend/src/routes/accounting/index.svelte
T
StephanRichter 170a551169 adding title tag
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-04-25 20:15:05 +02:00

55 lines
1.1 KiB
Svelte
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script>
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { t } from '../../translations.svelte';
import { api, get } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
const router = useTinyRouter();
let accounts = [];
async function load(){
let url = api('accounting');
let res = await get(url);
if (res.ok){
yikes();
accounts = await res.json();
} else error(res);
}
function newAccount(){
router.navigate('/accounting/new');
}
function onclick(e){
e.preventDefault();
let href = e.target.getAttribute('href');
if (href) router.navigate(href);
return false;
}
onMount(load);
</script>
<svelte:head>
<title>Umbrella {t('accounts')}</title>
</svelte:head>
<fieldset>
<span></span>
<span>
<button onclick={newAccount}>{t('create_new_object',{'object':t('account')})}</button>
</span>
<ul>
{#each accounts as account (account.id)}
<li>
<a {onclick} href="/account/{account.id}">{account.name} ({account.id})</a>
</li>
{/each}
</ul>
<legend>{t('accounts')}</legend>
</fieldset>