This commit is contained in:
Alex Holliday committed 2026-01-29 18:18:52 +00:00
1 parent 6ffa5ac648
commit c1258d3cdf
2 files changed
+27 -4

No files matched your search

@@ -27,7 +27,7 @@ export const NotificationsTable = ({
id: 1, id: 1,
label: t("pages.common.monitors.actions.configure"), label: t("pages.common.monitors.actions.configure"),
action: () => { action: () => {
navigate(`/notification-channels/${channel.id}/configure`); navigate(`/notifications/${channel.id}`);
}, },
closeMenu: true, closeMenu: true,
}, },
@@ -89,7 +89,7 @@ export const NotificationsTable = ({
headers={headers} headers={headers}
data={notifications} data={notifications}
onRowClick={(row) => { onRowClick={(row) => {
navigate(`/notification-channels/${row.id}/configure`); navigate(`/notifications/${row.id}`);
}} }}
/> />
); );
+25 -2
View File
@@ -1,8 +1,9 @@
import { BasePageWithStates } from "@/Components/v2/design-elements"; import { BasePageWithStates } from "@/Components/v2/design-elements";
import { NotificationsTable } from "@/Pages/Notifications/components/NotificationsTable"; import { NotificationsTable } from "@/Pages/Notifications/components/NotificationsTable";
import { Dialog } from "@/Components/v2/inputs";
import { useState } from "react"; import { useState } from "react";
import { useGet } from "@/Hooks/UseApi"; import { useGet, useDelete } from "@/Hooks/UseApi";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import type { Notification } from "@/Types/Notification"; import type { Notification } from "@/Types/Notification";
@@ -10,6 +11,7 @@ const NotificationsPage = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const [selectedChannel, setSelectedChannel] = useState<Notification | null>(null); const [selectedChannel, setSelectedChannel] = useState<Notification | null>(null);
const isDialogOpen = Boolean(selectedChannel);
const { const {
data: notifications, data: notifications,
@@ -17,7 +19,20 @@ const NotificationsPage = () => {
isValidating, isValidating,
error, error,
refetch, refetch,
} = useGet<Notification[]>("/notifications/team"); } = useGet<Notification[]>("/notifications/team", {}, { keepPreviousData: true });
const { deleteFn, loading: isDeleting } = useDelete();
const handleConfirm = async () => {
if (!selectedChannel) return;
await deleteFn(`/notifications/${selectedChannel.id}`);
setSelectedChannel(null);
refetch();
};
const handleCancel = () => {
setSelectedChannel(null);
};
return ( return (
<BasePageWithStates <BasePageWithStates
@@ -35,6 +50,14 @@ const NotificationsPage = () => {
notifications={notifications ?? []} notifications={notifications ?? []}
setSelectedChannel={setSelectedChannel} setSelectedChannel={setSelectedChannel}
/> />
<Dialog
open={isDialogOpen}
title={t("common.dialogs.delete.title")}
content={t("common.dialogs.delete.description")}
onConfirm={handleConfirm}
onCancel={handleCancel}
loading={isDeleting}
/>
</BasePageWithStates> </BasePageWithStates>
); );
}; };