import { useMutation } from 'react-query'; import { Trash2 } from 'lucide-react'; import { useEnvironmentId } from '@/react/hooks/useEnvironmentId'; import { Job } from '@/react/nomad/types'; import { confirmDelete } from '@@/modals/confirm'; import { LoadingButton } from '@@/buttons/LoadingButton'; import { deleteJobs } from './delete'; interface Props { selectedItems: Job[]; refreshData: () => Promise | void; } export function JobActions({ selectedItems, refreshData }: Props) { const environmentId = useEnvironmentId(); const mutation = useMutation(() => deleteJobs(environmentId, selectedItems)); return ( Remove ); async function handleDeleteClicked() { const confirmed = await confirmDelete( 'Are you sure to delete all selected jobs?' ); if (!confirmed) { return; } mutation.mutate(undefined, { onSuccess() { return refreshData(); }, }); } }