'use client' import { AlertDialog, AlertDialogActions, AlertDialogCancelButton, AlertDialogConfirmButton, AlertDialogContent, AlertDialogDescription, AlertDialogTitle, } from '@langgenius/dify-ui/alert-dialog' import { toast } from '@langgenius/dify-ui/toast' import { useMutation } from '@tanstack/react-query' import { useTranslation } from 'react-i18next' import { consoleQuery } from '@/service/client' type DeleteAgentDialogProps = { agentId: string agentName: string open: boolean onOpenChange: (open: boolean) => void } export function DeleteAgentDialog({ agentId, agentName, open, onOpenChange, }: DeleteAgentDialogProps) { const { t } = useTranslation('agentV2') const { t: tCommon } = useTranslation('common') const deleteAgentMutation = useMutation(consoleQuery.agent.byAgentId.delete.mutationOptions()) const handleDelete = () => { if (deleteAgentMutation.isPending) return deleteAgentMutation.mutate( { params: { agent_id: agentId, }, }, { onSuccess: () => { toast.success(t(($) => $['roster.deleteSuccess'])) onOpenChange(false) }, onError: () => { toast.error(t(($) => $['roster.deleteFailed'])) }, }, ) } return ( {t(($) => $['roster.deleteDialog.title'], { name: agentName })} {t(($) => $['roster.deleteDialog.description'])} {tCommon(($) => $['operation.cancel'])} {tCommon(($) => $['operation.delete'])} ) }