überarbeitung edit tatort funktioniert, edit vorgang bis api auch, aber dann hakt es
Some checks failed
InnoHub Processor/tatort/pipeline/head This commit was not built
InnoHub Processor/tatort/pipeline/pr-development There was a failure building this commit

This commit is contained in:
2025-07-10 10:24:57 +02:00
parent 7ad52618fb
commit 0b4d189439
12 changed files with 270 additions and 121 deletions

View File

@@ -1,10 +0,0 @@
import { getListOfVorgänge } from '$lib/server/vorgangService';
import type { PageServerLoad } from '../../(token-based)/view/$types';
export const load: PageServerLoad = async () => {
const caseList = await getListOfVorgänge();
return {
caseList
};
};

View File

@@ -11,11 +11,12 @@
let { data } = $props();
const caseList: ListItem[] = data.caseList;
const caseList: ListItem[] = $state(data.caseList);
//Variabeln für EditableItem
let names: string[] = $state(caseList.map((l) => l.name));
let editedName: string = $state('');
let currentName: string = $state('');
async function delete_item(ev: Event) {
let delete_item = window.confirm('Bist du sicher?');
@@ -47,7 +48,7 @@
}
}
async function handleSave(newName: string, oldName: string) {
async function handleUpdateCase(newName: string, oldName: string) {
console.log('Eltern, speichern erfolgreich', newName, oldName);
try {
const res = await fetch(`/api/list/${oldName}`, {
@@ -60,9 +61,11 @@
if (!res.ok) {
const msg = await res.text();
console.error('❌ Fehler beim Speichern:', msg);
console.error('❌ Fehler beim Speichern Update:', msg);
} else {
console.log('✅ Erfolgreich gespeichert:', newName);
await invalidate('');
currentName = newName;
}
} catch (err) {
console.error('⚠️ Netzwerkfehler:', err);
@@ -84,13 +87,7 @@
const msg = await res.text();
console.error('❌ Fehler beim Löschen:', msg);
} else {
setTimeout(() => {
window.location.reload();
}, 500);
//await invalidate('/api/list');
console.log('🗑️ Erfolgreich gelöscht:', vorgang);
await invalidate('/api/list'); // funktioniert nicht vernünftig
}
} catch (err) {
console.error('⚠️ Netzwerkfehler beim Löschen:', err);
@@ -109,24 +106,26 @@
<div class="flex gap-x-4">
<!-- Ordner -->
<a
href="/list/{item.name}?token={item.token}"
class="bg-red-500 flex justify-between gap-x-6 py-5"
href="/list/{currentName}?token={item.token}"
class=" flex justify-between gap-x-6 py-5"
>
<Folder />
</a>
<div class="min-w-0 flex-auto">
<EditableItem
list={caseList}
bind:editedName={names[i]}
currentName={item.name}
onSave={handleSave}
onDelete={handleDelete}
></EditableItem>
</div>
<div class="hidden sm:flex sm:flex-col sm:items-end">
<p class="text-sm leading-6 text-gray-900">Vorgang</p>
</div>
{#if data.user.admin}
<div class="min-w-0 flex-auto">
<EditableItem
list={caseList}
bind:editedName={names[i]}
currentName={item.name}
onSave={handleUpdateCase}
onDelete={handleDelete}
></EditableItem>
</div>
{:else}
<div class="hidden sm:flex sm:flex-col sm:items-end">
<p class="text-sm leading-6 text-gray-900">Vorgang</p>
</div>
{/if}
</div>
</li>
{/each}

View File

@@ -0,0 +1,24 @@
export async function load({ fetch, url }) {
//const caseToken = url.searchParams.get('token');
const adminRes = await fetch(`/api/user`)
const user = await adminRes.json()
console.log("load Vorgang; ", user);
const res = await fetch(`/api/list`, {
/* headers: {
Authorization: `Bearer ${caseToken}`
} */
});
const data = await res.json();
const caseList = data.caseList
console.log("load Vorgang; ", caseList, user);
return {
caseList,
user
};
};