From 342ff4b589e9efea3c2af705802ff66d1c3b4402 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Tue, 9 Jul 2024 01:16:06 -0600 Subject: [PATCH] feat(notifications): add delete notification modal --- .../notifications/delete-notification.tsx | 16 ++++++++-------- .../notifications/show-notifications.tsx | 13 +++++++------ server/api/routers/notification.ts | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/components/dashboard/settings/notifications/delete-notification.tsx b/components/dashboard/settings/notifications/delete-notification.tsx index c5a3bdfee..0a3db329b 100644 --- a/components/dashboard/settings/notifications/delete-notification.tsx +++ b/components/dashboard/settings/notifications/delete-notification.tsx @@ -16,10 +16,10 @@ import { TrashIcon } from "lucide-react"; import { toast } from "sonner"; interface Props { - destinationId: string; + notificationId: string; } -export const DeleteDestination = ({ destinationId }: Props) => { - const { mutateAsync, isLoading } = api.destination.remove.useMutation(); +export const DeleteNotification = ({ notificationId }: Props) => { + const { mutateAsync, isLoading } = api.notification.remove.useMutation(); const utils = api.useUtils(); return ( @@ -33,7 +33,7 @@ export const DeleteDestination = ({ destinationId }: Props) => { Are you absolutely sure? This action cannot be undone. This will permanently delete the - destination + notification @@ -41,14 +41,14 @@ export const DeleteDestination = ({ destinationId }: Props) => { { await mutateAsync({ - destinationId, + notificationId, }) .then(() => { - utils.destination.all.invalidate(); - toast.success("Destination delete succesfully"); + utils.notification.all.invalidate(); + toast.success("Notification delete succesfully"); }) .catch(() => { - toast.error("Error to delete destination"); + toast.error("Error to delete notification"); }); }} > diff --git a/components/dashboard/settings/notifications/show-notifications.tsx b/components/dashboard/settings/notifications/show-notifications.tsx index 8eac36cee..a4d61ffdc 100644 --- a/components/dashboard/settings/notifications/show-notifications.tsx +++ b/components/dashboard/settings/notifications/show-notifications.tsx @@ -8,6 +8,7 @@ import { import { api } from "@/utils/api"; import { BellRing } from "lucide-react"; import { AddNotification } from "./add-notification"; +import { DeleteNotification } from "./delete-notification"; export const ShowNotifications = () => { const { data } = api.notification.all.useQuery(); @@ -41,14 +42,14 @@ export const ShowNotifications = () => { {index + 1}. {destination.name} - {/*
- + {/* */} + - -
*/} + ))}
diff --git a/server/api/routers/notification.ts b/server/api/routers/notification.ts index c54ffd351..e8a99f12b 100644 --- a/server/api/routers/notification.ts +++ b/server/api/routers/notification.ts @@ -78,7 +78,7 @@ export const notificationRouter = createTRPCRouter({ }); } }), - removeNotification: adminProcedure + remove: adminProcedure .input(apiFindOneNotification) .mutation(async ({ input }) => { try {