add delete confirmation dialog to notificiaton page

This commit is contained in:
Alex Holliday committed 2025-07-07 15:34:45 -07:00
1 parent 961c398690
commit e08fba1b76
2 files changed
+19 -7

No files matched your search

@@ -7,6 +7,7 @@ import ConfigBox from "../../../Components/ConfigBox";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import Select from "../../../Components/Inputs/Select"; import Select from "../../../Components/Inputs/Select";
import TextInput from "../../../Components/Inputs/TextInput"; import TextInput from "../../../Components/Inputs/TextInput";
import Dialog from "../../../Components/Dialog";
// Utils // Utils
import { useState } from "react"; import { useState } from "react";
@@ -60,10 +61,9 @@ const CreateNotifications = () => {
const [errors, setErrors] = useState({}); const [errors, setErrors] = useState({});
const { t } = useTranslation(); const { t } = useTranslation();
const [notificationIsLoading] = useGetNotificationById( const [notificationIsLoading] = useGetNotificationById(notificationId, setNotification);
notificationId,
setNotification const [isOpen, setIsOpen] = useState(false);
);
// handlers // handlers
const onSubmit = (e) => { const onSubmit = (e) => {
@@ -220,14 +220,14 @@ const CreateNotifications = () => {
color="secondary" color="secondary"
onClick={onTestNotification} onClick={onTestNotification}
> >
{t("testNotification")} {t("createNotifications.testNotification")}
</Button> </Button>
{notificationId && ( {notificationId && (
<Button <Button
loading={isDeleting} loading={isDeleting}
variant="contained" variant="contained"
color="error" color="error"
onClick={onDelete} onClick={() => setIsOpen(true)}
> >
{t("delete")} {t("delete")}
</Button> </Button>
@@ -242,6 +242,15 @@ const CreateNotifications = () => {
</Button> </Button>
</Stack> </Stack>
</Stack> </Stack>
<Dialog
open={isOpen}
onClose={() => setIsOpen(false)}
onCancel={() => setIsOpen(false)}
title={t("createNotifications.dialogDeleteTitle")}
confirmationButtonLabel={t("createNotifications.dialogDeleteConfirm")}
onConfirm={onDelete}
isLoading={isDeleting}
/>
</Stack> </Stack>
); );
}; };
+4 -1
View File
@@ -284,7 +284,10 @@
"title": "Webhook", "title": "Webhook",
"webhookLabel": "Webhook URL", "webhookLabel": "Webhook URL",
"webhookPlaceholder": "https://your-server.com/webhook" "webhookPlaceholder": "https://your-server.com/webhook"
} },
"testNotification": "Test notification",
"dialogDeleteTitle": "Are you sure you want to delete this notification?",
"dialogDeleteConfirm": "Delete"
}, },
"createYour": "Create your", "createYour": "Create your",
"date&Time": "Date & Time", "date&Time": "Date & Time",