import { LoaderCircleIcon, X } from 'lucide-react'; import React from 'react'; import { useIntl } from 'react-intl'; import { Button } from '#shared/ui/Button'; import { Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '#shared/ui/Dialog'; import { useDelete } from '../../api/delete'; import { invalidateList } from '../../api/list'; export const DeleteTrigger: React.FC< React.PropsWithChildren<{ id: number; deleteTarget?: React.ReactNode; }> > = ({ id, deleteTarget, children }) => { const intl = useIntl(); const mutationDelete = useDelete(); const handleDelete = () => { mutationDelete.mutate( { id: id }, { onSuccess() { invalidateList(); } } ); }; return ( {children ? ( children ) : ( )} {intl.formatMessage({ id: 'ACTION.CONFIRM' })} {deleteTarget ? ( {intl.formatMessage( { id: 'MODULE.COMMON.REMOVE_ITEM_QUESTION' }, { target: deleteTarget } )} {intl.formatMessage({ id: 'MODULE.COMMON.REMOVE_ITEM_QUESTION_DESC' })} ) : ( intl.formatMessage({ id: 'MODULE.COMMON.ARE_YOU_SURE?' }) + ' ' + intl.formatMessage({ id: 'MODULE.COMMON.REMOVE_ITEM_QUESTION_DESC' }) )} ); };