'use client'; import { useState } from 'react'; import { removeAllDatasetEntries } from '@/app/actions/remove-dataset-entries'; interface RemoveAllEntriesButtonProps { datasetId: number; } export default function RemoveAllEntriesButton({ datasetId }: RemoveAllEntriesButtonProps) { const [isConfirming, setIsConfirming] = useState(false); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); async function handleConfirm() { setLoading(true); setError(null); try { await removeAllDatasetEntries(datasetId); setIsConfirming(false); // Show success message and reload setTimeout(() => { window.location.reload(); }, 1000); } catch (err) { const message = err instanceof Error ? err.message : 'Failed to remove entries'; setError(message); } finally { setLoading(false); } } if (isConfirming) { return (

Remove all entries?

This will permanently delete all dataset entries and their files. This action cannot be undone.

{error && (
{error}
)}
); } return ( ); }