sort report initially
All checks were successful
deploy / build-and-deploy (push) Successful in 18s

This commit is contained in:
2025-12-27 17:27:05 +01:00
parent 01f2a04daa
commit 46e0ad1fc6

View File

@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import BottomBar from '@app/admin/reports/BottomBar.svelte'; import BottomBar from '@app/admin/reports/BottomBar.svelte';
import { onMount } from 'svelte'; import { onMount, untrack } from 'svelte';
import DataTable from '@components/admin/table/DataTable.svelte'; import DataTable from '@components/admin/table/DataTable.svelte';
import { type StrikeReasons, getStrikeReasons, reports } from '@app/admin/reports/reports.ts'; import { type StrikeReasons, getStrikeReasons, reports } from '@app/admin/reports/reports.ts';
@@ -21,6 +21,18 @@
onMount(() => { onMount(() => {
getStrikeReasons().then((data) => (strikeReasons = data ?? [])); getStrikeReasons().then((data) => (strikeReasons = data ?? []));
}); });
let initialSort = false;
$effect(() => {
if ($reports.length == 0 || initialSort) return;
initialSort = true;
$reports = $reports.toSorted(
(a, b) =>
['open', 'closed', null].indexOf(a.status?.status ?? null) -
['open', 'closed', null].indexOf(b.status?.status ?? null)
);
});
</script> </script>
{#snippet date(value: string)} {#snippet date(value: string)}