add delete to admin panel
All checks were successful
deploy / build-and-deploy (push) Successful in 21s

This commit is contained in:
2025-05-21 20:53:53 +02:00
parent e47268111a
commit 45f984e4da
16 changed files with 207 additions and 50 deletions

24
src/util/state.ts Normal file
View File

@ -0,0 +1,24 @@
import type { Writable } from 'svelte/store';
export function addToWritableArray<T>(writable: Writable<T[]>, t: T) {
writable.update((old) => {
old.push(t);
return old;
});
}
export function updateWritableArray<T>(writable: Writable<T[]>, t: T, cmp: (t: T) => boolean) {
writable.update((old) => {
const index = old.findIndex(cmp);
old[index] = t;
return old;
});
}
export function deleteFromWritableArray<T>(writable: Writable<T[]>, cmp: (t: T) => boolean) {
writable.update((old) => {
const index = old.findIndex(cmp);
old.splice(index, 1);
return old;
});
}