zwischenstand: bug delete tatort
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import Folder from '$lib/icons/Folder.svelte';
|
||||
import EditableItem from '$lib/components/EditableItem.svelte';
|
||||
import { invalidate } from '$app/navigation';
|
||||
|
||||
interface ListItem {
|
||||
name: string;
|
||||
@@ -16,9 +17,6 @@
|
||||
let names: string[] = $state(caseList.map((l) => l.name));
|
||||
let editedName: string = $state('');
|
||||
|
||||
function getNameById(list: ListItem[], id: number) {
|
||||
return list[id].name;
|
||||
}
|
||||
async function delete_item(ev: Event) {
|
||||
let delete_item = window.confirm('Bist du sicher?');
|
||||
|
||||
@@ -71,23 +69,28 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(name: string) {
|
||||
async function handleDelete(vorgang: string) {
|
||||
let url = `/api/list/${vorgang}`;
|
||||
try {
|
||||
const res = await fetch(`/api/list/${name}`, {
|
||||
const res = await fetch(url, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ name })
|
||||
body: JSON.stringify({ vorgang })
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const msg = await res.text();
|
||||
console.error('❌ Fehler beim Löschen:', msg);
|
||||
} else {
|
||||
console.log('🗑️ Erfolgreich gelöscht:', name);
|
||||
// Optional: Lokale Liste aktualisieren
|
||||
//S items = items.filter((item) => item.name !== name);
|
||||
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);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
//Kann komplett gelöscht werden
|
||||
import Alert from '$lib/components/Alert.svelte';
|
||||
import Button from '$lib/components/Button.svelte';
|
||||
import Modal from '$lib/components/Modal/Modal.svelte';
|
||||
@@ -75,19 +76,14 @@
|
||||
</div>
|
||||
|
||||
<label for="code">
|
||||
<span >Zugangscode (optional) </span>
|
||||
<span>Zugangscode (optional) </span>
|
||||
</label>
|
||||
|
||||
<div class="mt-2">
|
||||
<div
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
id="code"
|
||||
/>
|
||||
<div>
|
||||
<input type="text" id="code" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user