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

@@ -2,6 +2,7 @@
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api } from '../../urls.svelte.js';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte.js';
import { timetrack } from '../../user.svelte.js';
import { display } from '../../time.svelte.js';
@@ -10,7 +11,6 @@
import TimeEditor from '../../Components/TimeRecordEditor.svelte';
let docLinks = $state(null);
let error = $state(null);
let router = useTinyRouter();
let times = $state(null);
let tasks = {};
@@ -38,7 +38,7 @@
const track = await resp.json();
timetrack.running = track;
} else {
error = await resp.text();
error(resp);
}
}
@@ -87,13 +87,13 @@
body : `${id1}+${id2}`
});
if (res.ok){
error = null;
yikes();
let json = await res.json();
delete times[id1];
delete times[id2];
times[json.id] = json;
} else {
error = await res.text();
error(res);
}
return false;
}
@@ -108,7 +108,7 @@
projects = json.projects;
docLinks = json.documents;
} else {
error = await resp.text();
error(resp);
}
}
@@ -132,9 +132,9 @@
});
if (res.ok){
delete times[time_id];
error = false;
yikes();
} else {
error = await res.text();
error(res);
}
}
@@ -178,10 +178,10 @@
let id = json.id;
for (let key of Object.keys(json)) times[id][key] = json[key];
detail = null;
error = null;
yikes();
return true;
} else {
error = await res.text();
error(res);
return false;
}
}
@@ -194,9 +194,6 @@
</svelte:head>
<h1>{t('timetracking')}</h1>
{#if error}
<span class="error">{error}</span>
{/if}
{#if times}
{#if selectionSum}
<div class="timetracks sum">