mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat(notifications): add delete notification modal
This commit is contained in:
@@ -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 (
|
||||
<AlertDialog>
|
||||
@@ -33,7 +33,7 @@ export const DeleteDestination = ({ destinationId }: Props) => {
|
||||
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
This action cannot be undone. This will permanently delete the
|
||||
destination
|
||||
notification
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
@@ -41,14 +41,14 @@ export const DeleteDestination = ({ destinationId }: Props) => {
|
||||
<AlertDialogAction
|
||||
onClick={async () => {
|
||||
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");
|
||||
});
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -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 = () => {
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{index + 1}. {destination.name}
|
||||
</span>
|
||||
{/* <div className="flex flex-row gap-1">
|
||||
<UpdateDestination
|
||||
<div className="flex flex-row gap-1">
|
||||
{/* <UpdateDestination
|
||||
destinationId={destination.destinationId}
|
||||
/> */}
|
||||
<DeleteNotification
|
||||
notificationId={destination.notificationId}
|
||||
/>
|
||||
<DeleteDestination
|
||||
destinationId={destination.destinationId}
|
||||
/>
|
||||
</div> */}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<div>
|
||||
|
||||
@@ -78,7 +78,7 @@ export const notificationRouter = createTRPCRouter({
|
||||
});
|
||||
}
|
||||
}),
|
||||
removeNotification: adminProcedure
|
||||
remove: adminProcedure
|
||||
.input(apiFindOneNotification)
|
||||
.mutation(async ({ input }) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user