From 4536bceef65406bf05e6284eb67371668c390f17 Mon Sep 17 00:00:00 2001 From: Raj Nandan Sharma Date: Mon, 15 Jun 2026 23:22:25 +0530 Subject: [PATCH] refactor: improve incident management page structure and enhance data fetching logic --- .../manage/app/incidents/+page.svelte | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/routes/(manage)/manage/app/incidents/+page.svelte b/src/routes/(manage)/manage/app/incidents/+page.svelte index f1191965..07b1cc40 100644 --- a/src/routes/(manage)/manage/app/incidents/+page.svelte +++ b/src/routes/(manage)/manage/app/incidents/+page.svelte @@ -2,16 +2,18 @@ import { Button } from "$lib/components/ui/button/index.js"; import { Spinner } from "$lib/components/ui/spinner/index.js"; import { Badge } from "$lib/components/ui/badge/index.js"; + import * as Card from "$lib/components/ui/card/index.js"; import * as Select from "$lib/components/ui/select/index.js"; + import * as Breadcrumb from "$lib/components/ui/breadcrumb/index.js"; import * as Table from "$lib/components/ui/table/index.js"; import * as Tooltip from "$lib/components/ui/tooltip/index.js"; import PlusIcon from "@lucide/svelte/icons/plus"; import ChevronLeftIcon from "@lucide/svelte/icons/chevron-left"; import ChevronRightIcon from "@lucide/svelte/icons/chevron-right"; + import ExternalLinkIcon from "@lucide/svelte/icons/external-link"; import PencilIcon from "@lucide/svelte/icons/pencil"; import SirenIcon from "@lucide/svelte/icons/siren"; import { goto } from "$app/navigation"; - import { onMount } from "svelte"; import { format, formatDistanceToNow } from "date-fns"; import GC from "$lib/global-constants"; import { resolve } from "$app/paths"; @@ -102,12 +104,12 @@ // Navigate to incident function openIncident(id: number) { - goto(resolve(`/manage/app/incidents/${id}`)); + goto(clientResolver(resolve, `/manage/app/incidents/${id}`)); } // Create new incident function createNewIncident() { - goto(resolve("/manage/app/incidents/new")); + goto(clientResolver(resolve, "/manage/app/incidents/new")); } // Handle state filter change @@ -125,7 +127,7 @@ fetchData(); } - onMount(() => { + $effect(() => { fetchData(); }); @@ -140,7 +142,7 @@ {stateOptions.find((o) => o.value === stateFilter)?.label || "All States"} - {#each stateOptions as option (option.value)} + {#each stateOptions as option} {option.label} {/each} @@ -164,7 +166,6 @@ ID Title - Started Duration State Affects @@ -174,10 +175,10 @@ {#if incidents.length === 0 && !loading} - No incidents found + No incidents found {:else} - {#each incidents as incident (incident.id)} + {#each incidents as incident} openIncident(incident.id)}> {incident.id} @@ -190,11 +191,6 @@ - - - {format(new Date(incident.start_date_time * 1000), "yyyy-MM-dd HH:mm")} - - @@ -231,7 +227,7 @@
- {#each incident.monitors as monitor (monitor.tag || monitor.monitor_tag)} + {#each incident.monitors as monitor}
{monitor.tag || monitor.monitor_tag}
{#if totalPages <= 7} - {#each Array.from({ length: totalPages }, (_, i) => i + 1) as page (page)} + {#each Array.from({ length: totalPages }, (_, i) => i + 1) as page} @@ -292,7 +288,7 @@ {/if} - {#each Array.from({ length: 3 }, (_, i) => pageNo - 1 + i).filter((p) => p > 1 && p < totalPages) as page (page)} + {#each Array.from({ length: 3 }, (_, i) => pageNo - 1 + i).filter((p) => p > 1 && p < totalPages) as page}