feat: add extraction deletion functionality with confirmation dialog and update extraction list on deletion
This commit is contained in:
@@ -159,6 +159,23 @@ export function ExtractionsPage() {
|
||||
setShowCreateDialog(false)
|
||||
}
|
||||
|
||||
const handleExtractionDeleted = (extractionId: number) => {
|
||||
// Remove the deleted extraction from the current list
|
||||
setExtractions(prev => prev.filter(extraction => extraction.id !== extractionId))
|
||||
|
||||
// Update total count
|
||||
setTotalCount(prev => prev - 1)
|
||||
|
||||
// If current page is now empty and not the first page, go to previous page
|
||||
const remainingOnCurrentPage = extractions.length - 1
|
||||
if (remainingOnCurrentPage === 0 && currentPage > 1) {
|
||||
setCurrentPage(currentPage - 1)
|
||||
}
|
||||
|
||||
// Refresh the full list to ensure accuracy
|
||||
fetchExtractions()
|
||||
}
|
||||
|
||||
const renderContent = () => {
|
||||
if (loading) {
|
||||
return <ExtractionsLoading />
|
||||
@@ -174,7 +191,10 @@ export function ExtractionsPage() {
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<ExtractionsTable extractions={extractions} />
|
||||
<ExtractionsTable
|
||||
extractions={extractions}
|
||||
onExtractionDeleted={handleExtractionDeleted}
|
||||
/>
|
||||
<AppPagination
|
||||
currentPage={currentPage}
|
||||
totalPages={totalPages}
|
||||
|
||||
Reference in New Issue
Block a user