From b64c4c036f97ef71fac21b293e018d388bf36970 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Wed, 25 Mar 2026 18:07:21 +0100 Subject: [PATCH] feat(settings): add working delete org to unified workspace general tab --- .../unified/tabs/WorkspaceGeneralTab.tsx | 80 ++++++++++++++++--- 1 file changed, 68 insertions(+), 12 deletions(-) diff --git a/components/settings/unified/tabs/WorkspaceGeneralTab.tsx b/components/settings/unified/tabs/WorkspaceGeneralTab.tsx index 3d89ef1..bdbbcd4 100644 --- a/components/settings/unified/tabs/WorkspaceGeneralTab.tsx +++ b/components/settings/unified/tabs/WorkspaceGeneralTab.tsx @@ -1,18 +1,25 @@ 'use client' import { useState, useEffect } from 'react' +import { useRouter } from 'next/navigation' import { Input, Button, toast } from '@ciphera-net/ui' import { Spinner } from '@ciphera-net/ui' import { useAuth } from '@/lib/auth/context' -import { getOrganization, updateOrganization } from '@/lib/api/organization' +import { getOrganization, updateOrganization, deleteOrganization } from '@/lib/api/organization' import { getAuthErrorMessage } from '@ciphera-net/ui' +import { useUnifiedSettings } from '@/lib/unified-settings-context' export default function WorkspaceGeneralTab() { const { user } = useAuth() + const router = useRouter() + const { closeUnifiedSettings } = useUnifiedSettings() const [name, setName] = useState('') const [slug, setSlug] = useState('') const [loading, setLoading] = useState(true) const [saving, setSaving] = useState(false) + const [showDeleteConfirm, setShowDeleteConfirm] = useState(false) + const [deleteText, setDeleteText] = useState('') + const [deleting, setDeleting] = useState(false) useEffect(() => { if (!user?.org_id) return @@ -39,6 +46,20 @@ export default function WorkspaceGeneralTab() { } } + const handleDelete = async () => { + if (!user?.org_id || deleteText !== 'DELETE') return + setDeleting(true) + try { + await deleteOrganization(user.org_id) + localStorage.clear() + closeUnifiedSettings() + router.push('/') + } catch (err) { + toast.error(getAuthErrorMessage(err as Error) || 'Failed to delete organization') + setDeleting(false) + } + } + if (loading) { return (
@@ -79,18 +100,53 @@ export default function WorkspaceGeneralTab() { {/* Danger Zone */}

Danger Zone

-
-
-

Delete Organization

-

Permanently delete this organization and all its data.

+
+
+
+

Delete Organization

+

Permanently delete this organization and all its data.

+
+
- + {showDeleteConfirm && ( +
+

This will permanently delete:

+
    +
  • All sites and their analytics data
  • +
  • All team members and pending invitations
  • +
  • Active subscription will be cancelled
  • +
  • All notifications and settings
  • +
+
+ + setDeleteText(e.target.value)} + className="w-full px-3 py-2 border border-neutral-700 rounded-lg bg-neutral-900 text-white text-sm" + placeholder="DELETE" + /> +
+
+ + +
+
+ )}