made data in IDTable reloadable

This commit is contained in:
Djeeberjr 2025-05-20 13:20:21 +02:00
parent ea9ad2b995
commit f84b09bfd1

View File

@ -3,6 +3,12 @@
import type { IDMapping } from "./IDMapping"; import type { IDMapping } from "./IDMapping";
let data: IDMapping | undefined = $state(); let data: IDMapping | undefined = $state();
export async function reloadData() {
let res = await fetch("/api/mapping");
data = await res.json();
}
let rows = $derived( let rows = $derived(
data data
? Object.entries(data.id_map).map(([id, value]) => ({ ? Object.entries(data.id_map).map(([id, value]) => ({
@ -37,10 +43,9 @@
} }
onMount(async () => { onMount(async () => {
let res = await fetch("/api/mapping"); await reloadData();
data = await res.json();
}); });
</script> </script>
{#if data == null} {#if data == null}