← marzneshin
/
v0.5.5
/
dashboard/src/features/hosts/dialogs/delete-confirmation/index.tsx
https://dev.kronoz.win/r/marzneshin.git
1import { DeleteConfirmation } from '@marzneshin/components'
2import { type FC, useEffect } from 'react'
3import { HostType, useHostsDeletionMutation } from '@marzneshin/features/hosts'
4
5interface HostsDeleteConfirmationDialogProps {
6 onOpenChange: (state: boolean) => void
7 onClose: () => void
8 open: boolean
9 entity: HostType
10}
11
12export const HostsDeleteConfirmationDialog: FC<HostsDeleteConfirmationDialogProps> = ({ onOpenChange, open, entity, onClose }) => {
13 const deleteMutation = useHostsDeletionMutation();
14
15 useEffect(() => {
16 if (!open) onClose();
17 }, [open, onClose]);
18
19 return (
20 <DeleteConfirmation
21 open={open}
22 onOpenChange={onOpenChange}
23 action={() => deleteMutation.mutate(entity)}
24 />
25 )
26}