wire up incidents table

This commit is contained in:
Alex Holliday committed 2026-01-31 00:41:03 +00:00
1 parent 87255071f4
commit 6b67f4977f
3 files changed
+71 -13

No files matched your search

+6 -2
View File
@@ -16,6 +16,8 @@ export const DialogInput = ({
confirmColor = "primary", confirmColor = "primary",
cancelColor = "error", cancelColor = "error",
loading = false, loading = false,
cancelText,
confirmText,
}: { }: {
open: boolean; open: boolean;
title?: string; title?: string;
@@ -25,6 +27,8 @@ export const DialogInput = ({
confirmColor?: "error" | "primary"; confirmColor?: "error" | "primary";
cancelColor?: "error" | "primary"; cancelColor?: "error" | "primary";
loading?: boolean; loading?: boolean;
cancelText?: string;
confirmText?: string;
}) => { }) => {
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
@@ -40,7 +44,7 @@ export const DialogInput = ({
color={cancelColor} color={cancelColor}
onClick={onCancel} onClick={onCancel}
> >
{t("common.buttons.cancel")} {cancelText ?? t("common.buttons.cancel")}
</Button> </Button>
<Button <Button
loading={loading} loading={loading}
@@ -48,7 +52,7 @@ export const DialogInput = ({
color={confirmColor} color={confirmColor}
onClick={onConfirm} onClick={onConfirm}
> >
{t("common.buttons.confirm")} {confirmText ?? t("common.buttons.confirm")}
</Button> </Button>
</DialogActions> </DialogActions>
</Dialog> </Dialog>
@@ -1,4 +1,5 @@
import { Table } from "@/Components/v2/design-elements"; import { Table } from "@/Components/v2/design-elements";
import { Pagination } from "@/Components/v2/design-elements/Table";
import type { Header } from "@/Components/v2/design-elements/Table"; import type { Header } from "@/Components/v2/design-elements/Table";
import { StatusLabel, ValueLabel } from "@/Components/v2/design-elements"; import { StatusLabel, ValueLabel } from "@/Components/v2/design-elements";
import type { ValueType } from "@/Components/v2/design-elements/StatusLabel"; import type { ValueType } from "@/Components/v2/design-elements/StatusLabel";
@@ -14,10 +15,16 @@ import { useSelector } from "react-redux";
import type { RootState } from "@/Types/state"; import type { RootState } from "@/Types/state";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import { useTheme } from "@mui/material/styles"; import { useTheme } from "@mui/material/styles";
import Box from "@mui/material/Box";
interface IncidentsTableProps { interface IncidentsTableProps {
incidents?: Incident[]; incidents?: Incident[];
monitors?: Monitor[]; monitors?: Monitor[];
incidentsCount: number;
page: number;
setPage: (page: number) => void;
rowsPerPage: number;
setRowsPerPage: (rowsPerPage: number) => void;
onOpenDetails?: (incidentId: string) => void; onOpenDetails?: (incidentId: string) => void;
onResolve?: (incidentId: string) => void; onResolve?: (incidentId: string) => void;
} }
@@ -25,6 +32,11 @@ interface IncidentsTableProps {
export const IncidentsTable = ({ export const IncidentsTable = ({
incidents, incidents,
monitors, monitors,
incidentsCount,
page,
setPage,
rowsPerPage,
setRowsPerPage,
onOpenDetails, onOpenDetails,
onResolve, onResolve,
}: IncidentsTableProps) => { }: IncidentsTableProps) => {
@@ -162,13 +174,41 @@ export const IncidentsTable = ({
]; ];
}; };
const handlePageChange = (
_e: React.MouseEvent<HTMLButtonElement> | null,
newPage: number
) => {
setPage(newPage);
};
const handleRowsPerPageChange = (
e: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>
) => {
const value = Number(e.target.value);
setPage(0);
setRowsPerPage(value);
};
if (!incidents || !monitors) { if (!incidents || !monitors) {
return null; return null;
} }
void getHeaders; return (
void Table; <Box>
<Table
// Headers: Monitor name, status, start time, end time, resolution type, status code, message, actions headers={getHeaders()}
return "Table here"; data={incidents}
onRowClick={(row) => onOpenDetails?.(row.id)}
emptyViewText={t("common.table.empty")}
/>
<Pagination
component="div"
count={incidentsCount}
page={page}
rowsPerPage={rowsPerPage}
onPageChange={handlePageChange}
onRowsPerPageChange={handleRowsPerPageChange}
/>
</Box>
);
}; };
+20 -6
View File
@@ -5,6 +5,7 @@ import {
SummaryCardLatestIncidents, SummaryCardLatestIncidents,
SummaryCardStats, SummaryCardStats,
} from "@/Pages/Incidents/Components/SummaryCard"; } from "@/Pages/Incidents/Components/SummaryCard";
import { IncidentsTable } from "@/Pages/Incidents/Components/IncidentTable";
import { useGet } from "@/Hooks/UseApi"; import { useGet } from "@/Hooks/UseApi";
import { useState, useEffect, useMemo } from "react"; import { useState, useEffect, useMemo } from "react";
@@ -96,21 +97,23 @@ const IncidentsPage = () => {
void setFilter; void setFilter;
void dateRange; void dateRange;
void setDateRange; void setDateRange;
void page;
void setPage;
void rowsPerPage;
void setRowsPerPage;
void isLoadingIncidents; void isLoadingIncidents;
void isLoadingMonitors; void isLoadingMonitors;
void isLoadingSummary; void isLoadingSummary;
void refetchIncidents; void refetchIncidents;
void refetchSummary; void refetchSummary;
void monitorLookup; void monitorLookup;
void incidents;
void incidentsCount;
void summaryData; void summaryData;
void networkError; void networkError;
const handleOpenDetails = (incidentId: string) => {
console.log("Open details for incident:", incidentId);
};
const handleResolve = (incidentId: string) => {
console.log("Resolve incident:", incidentId);
};
return ( return (
<BasePage> <BasePage>
<Stack <Stack
@@ -124,6 +127,17 @@ const IncidentsPage = () => {
/> />
<SummaryCardStats summary={summaryData} /> <SummaryCardStats summary={summaryData} />
</Stack> </Stack>
<IncidentsTable
incidents={incidents}
monitors={monitorsData ?? undefined}
incidentsCount={incidentsCount}
page={page}
setPage={setPage}
rowsPerPage={rowsPerPage}
setRowsPerPage={setRowsPerPage}
onOpenDetails={handleOpenDetails}
onResolve={handleResolve}
/>
</BasePage> </BasePage>
); );
}; };