From 44afd93c35bd9296e8bf34680bfb4f0bea5aa31a Mon Sep 17 00:00:00 2001 From: James Bhattarai Date: Tue, 3 Mar 2026 23:23:18 +0545 Subject: [PATCH] Fix: Deletion Deadlocks (Owner, User) --- src/lib/api.ts | 9 ++- src/pages/org/DepartmentsPage.tsx | 3 - src/pages/org/OrgOverviewPage.tsx | 43 +++++++------- src/pages/org/PrincipalsPage.tsx | 3 - src/pages/user/ProfilePage.tsx | 93 +++++++++++++++++++++++++++---- 5 files changed, 108 insertions(+), 43 deletions(-) diff --git a/src/lib/api.ts b/src/lib/api.ts index 18c6083..05205cc 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -814,9 +814,12 @@ export const api = { getById: (orgId: string, requestConfig?: RequestConfig) => request<{ organization: Organization; member_count: number }>(`/organizations/${orgId}`, {}, true, requestConfig), - // Delete an organization (owner only; must have no other members) - deleteOrganization: (orgId: string, requestConfig?: RequestConfig) => - request<{ message: string }>(`/organizations/${orgId}`, { method: 'DELETE' }, true, requestConfig), + // Delete an organization (owner only; pass confirm=true when other members exist) + deleteOrganization: (orgId: string, confirm?: boolean, requestConfig?: RequestConfig) => + request<{ message: string }>(`/organizations/${orgId}`, { + method: 'DELETE', + ...(confirm ? { body: JSON.stringify({ confirm: true }) } : {}), + }, true, requestConfig), // Get organization members getMembers: (orgId: string, requestConfig?: RequestConfig) => diff --git a/src/pages/org/DepartmentsPage.tsx b/src/pages/org/DepartmentsPage.tsx index 72b5eef..b0cdc94 100644 --- a/src/pages/org/DepartmentsPage.tsx +++ b/src/pages/org/DepartmentsPage.tsx @@ -658,9 +658,6 @@ export default function DepartmentsPage() { }) )} -
- Created {new Date(dept.created_at).toLocaleDateString()} -
{/* Members toggle */} -