gitscope
← marzneshin / v0.5.6 / dashboard/src/features/nodes/dialogs/delete-confirmation/index.tsx
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/features/nodes/dialogs/delete-confirmation/index.tsx · TypeScript
Blame Raw
 1
 2import { DeleteConfirmation } from '@marzneshin/components'
 3import { FC, useEffect } from 'react'
 4import { NodeType, useNodesDeletionMutation } from '@marzneshin/features/nodes'
 5
 6interface NodesDeleteConfirmationDialogProps {
 7    onOpenChange: (state: boolean) => void
 8    open: boolean
 9    entity: NodeType
10    onClose: () => void
11}
12
13export const NodesDeleteConfirmationDialog: FC<NodesDeleteConfirmationDialogProps> = (
14    { onOpenChange, open, entity, onClose }
15) => {
16    const deleteMutation = useNodesDeletionMutation();
17
18    useEffect(() => {
19        if (!open) onClose();
20    }, [open, onClose]);
21
22    return (
23        <DeleteConfirmation
24            open={open}
25            onOpenChange={onOpenChange}
26            action={() => deleteMutation.mutate(entity)}
27        />
28    )
29}