diff --git a/src/app/(dashboard)/dashboard/providers/[id]/page.js b/src/app/(dashboard)/dashboard/providers/[id]/page.js index 5cb3154c..673d666c 100644 --- a/src/app/(dashboard)/dashboard/providers/[id]/page.js +++ b/src/app/(dashboard)/dashboard/providers/[id]/page.js @@ -637,7 +637,7 @@ export default function ProviderDetailPage() { try { const res = await fetch(`/api/providers/${id}`, { method: "DELETE" }); if (res.ok) { - setConnections(connections.filter(c => c.id !== id)); + setConnections(prev => prev.filter(c => c.id !== id)); } } catch (error) { console.log("Error deleting connection:", error); @@ -646,6 +646,32 @@ export default function ProviderDetailPage() { }); }; + const handleBulkDelete = () => { + const count = selectedConnectionIds.length; + if (count === 0) return; + setConfirmState({ + title: `Delete ${count} Connection${count > 1 ? "s" : ""}`, + message: `Delete ${count} connection${count > 1 ? "s" : ""}? This cannot be undone.`, + onConfirm: async () => { + setConfirmState(null); + let failed = 0; + const idsToDelete = [...selectedConnectionIds]; + for (const id of idsToDelete) { + try { + const res = await fetch(`/api/providers/${id}`, { method: "DELETE" }); + if (!res.ok) failed += 1; + } catch (error) { + console.log("Error deleting connection:", error); + failed += 1; + } + } + setConnections(prev => prev.filter(c => !idsToDelete.includes(c.id))); + setSelectedConnectionIds([]); + if (failed > 0) alert(`Deleted ${idsToDelete.length - failed} connection(s), ${failed} failed.`); + } + }); + }; + const handleOAuthSuccess = () => { fetchConnections(); setShowOAuthModal(false); @@ -844,6 +870,14 @@ export default function ProviderDetailPage() { {connections .map((conn, index) => (