gitscope
← marzneshin / v0.7.0 / dashboard/src/modules/hosts/dialogs/delete-confirmation/index.tsx
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/modules/hosts/dialogs/delete-confirmation/index.tsx · TypeScript
Blame Raw
 1import { DeleteConfirmation } from '@marzneshin/common/components'
 2import { type FC, useEffect } from 'react'
 3import { HostType, useHostsDeletionMutation } from '@marzneshin/modules/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}