11"use client" ;
22
33import { authClient } from "@databuddy/auth/client" ;
4- import { SignOutIcon , TrashIcon } from "@phosphor-icons/react" ;
4+ import {
5+ BookOpenIcon ,
6+ SignOutIcon ,
7+ TrashIcon ,
8+ WarningIcon ,
9+ } from "@phosphor-icons/react" ;
510import { useRouter } from "next/navigation" ;
611import { useEffect , useState } from "react" ;
712import { toast } from "sonner" ;
@@ -64,7 +69,7 @@ export function DangerZoneSettings({
6469 try {
6570 await deleteOrganizationAsync ( organization . id ) ;
6671 router . push ( "/organizations" ) ;
67- } catch ( _error ) {
72+ } catch {
6873 toast . error ( "Failed to delete organization" ) ;
6974 } finally {
7075 setIsDeleting ( false ) ;
@@ -77,7 +82,7 @@ export function DangerZoneSettings({
7782 try {
7883 await leaveOrganizationAsync ( organization . id ) ;
7984 router . push ( "/organizations" ) ;
80- } catch ( _error ) {
85+ } catch {
8186 toast . error ( "Failed to leave organization" ) ;
8287 } finally {
8388 setIsLeaving ( false ) ;
@@ -86,76 +91,107 @@ export function DangerZoneSettings({
8691 } ;
8792
8893 return (
89- < div className = "h-full p-6" >
90- < div className = "space-y-8" >
91- { /* Content Sections */ }
92- < div className = "space-y-8" >
93- { /* Transfer Assets Section */ }
94- < div className = "rounded-lg border bg-card" >
95- < div className = "border-b p-6" >
96- < h3 className = "font-semibold text-lg" > Transfer Assets</ h3 >
97- < p className = "text-muted-foreground text-sm" >
98- Move websites between your personal account and organization
94+ < div className = "h-full lg:grid lg:grid-cols-[1fr_18rem]" >
95+ { /* Main Content */ }
96+ < div className = "flex flex-col gap-6 border-b p-5 lg:border-b-0 lg:border-r" >
97+ { /* Transfer Assets Section */ }
98+ < section >
99+ < div className = "mb-4" >
100+ < h3 className = "font-semibold" > Transfer Assets</ h3 >
101+ < p className = "text-muted-foreground text-sm" >
102+ Move websites between your personal account and this organization
103+ </ p >
104+ </ div >
105+ < TransferAssets organizationId = { organization . id } />
106+ </ section >
107+
108+ { /* Destructive Action */ }
109+ < section className = "mt-auto rounded border border-destructive/20 bg-destructive/5 p-4" >
110+ < div className = "flex items-start justify-between gap-4" >
111+ < div >
112+ < h3 className = "font-semibold text-destructive" >
113+ { isOwner === null
114+ ? "Loading..."
115+ : isOwner
116+ ? "Delete Organization"
117+ : "Leave Organization" }
118+ </ h3 >
119+ < p className = "mt-1 text-destructive/70 text-sm" >
120+ { isOwner === null
121+ ? "Checking permissions..."
122+ : isOwner
123+ ? "Permanently delete this organization and all its data"
124+ : "You will lose access to all resources" }
99125 </ p >
100126 </ div >
101- < div className = "p-6" >
102- < TransferAssets organizationId = { organization . id } />
103- </ div >
127+ { isOwner === null ? (
128+ < Button disabled size = "sm" variant = "destructive" >
129+ < div className = "mr-2 h-3 w-3 animate-spin rounded-full border border-destructive-foreground/30 border-t-destructive-foreground" />
130+ Loading
131+ </ Button >
132+ ) : isOwner ? (
133+ < Button
134+ onClick = { ( ) => setShowDeleteDialog ( true ) }
135+ size = "sm"
136+ variant = "destructive"
137+ >
138+ < TrashIcon className = "mr-2" size = { 14 } />
139+ Delete
140+ </ Button >
141+ ) : (
142+ < Button
143+ onClick = { ( ) => setShowLeaveDialog ( true ) }
144+ size = "sm"
145+ variant = "destructive"
146+ >
147+ < SignOutIcon className = "mr-2" size = { 14 } />
148+ Leave
149+ </ Button >
150+ ) }
104151 </ div >
152+ </ section >
153+ </ div >
105154
106- { /* Leave/Delete Organization Section */ }
107- < div className = "rounded-lg border border-destructive/20 bg-destructive/5" >
108- < div className = "p-6" >
109- < div className = "space-y-4" >
110- < div >
111- < h3 className = "font-semibold text-destructive text-lg" >
112- { isOwner === null
113- ? "Loading..."
114- : isOwner
115- ? "Delete Organization"
116- : "Leave Organization" }
117- </ h3 >
118- < p className = "text-destructive/80 text-sm" >
119- { isOwner === null
120- ? "Checking permissions..."
121- : isOwner
122- ? "Once you delete an organization, there is no going back. Please be certain."
123- : "You will lose access to this organization and all its resources." }
124- </ p >
125- </ div >
126-
127- < div className = "flex justify-end" >
128- { isOwner === null ? (
129- < Button disabled size = "default" variant = "destructive" >
130- < div className = "mr-2 h-4 w-4 animate-spin rounded-full border border-destructive-foreground/30 border-t-destructive-foreground" />
131- Loading...
132- </ Button >
133- ) : isOwner ? (
134- < Button
135- onClick = { ( ) => setShowDeleteDialog ( true ) }
136- size = "default"
137- variant = "destructive"
138- >
139- < TrashIcon className = "mr-2 h-4 w-4" size = { 16 } />
140- Delete Organization
141- </ Button >
142- ) : (
143- < Button
144- onClick = { ( ) => setShowLeaveDialog ( true ) }
145- size = "default"
146- variant = "destructive"
147- >
148- < SignOutIcon className = "mr-2 h-4 w-4" size = { 16 } />
149- Leave Organization
150- </ Button >
151- ) }
152- </ div >
153- </ div >
154- </ div >
155+ { /* Sidebar */ }
156+ < aside className = "flex flex-col gap-4 bg-muted/30 p-5" >
157+ { /* Warning Card */ }
158+ < div className = "flex items-start gap-3 rounded border border-amber-500/20 bg-amber-500/5 p-4" >
159+ < div className = "flex h-8 w-8 shrink-0 items-center justify-center rounded bg-amber-500/10" >
160+ < WarningIcon className = "text-amber-600" size = { 16 } weight = "fill" />
161+ </ div >
162+ < div >
163+ < p className = "font-medium text-amber-700 text-sm dark:text-amber-400" >
164+ Danger Zone
165+ </ p >
166+ < p className = "mt-1 text-amber-600/80 text-xs dark:text-amber-500/80" >
167+ Actions here can result in permanent data loss
168+ </ p >
155169 </ div >
156170 </ div >
157- </ div >
158171
172+ { /* Docs Link */ }
173+ < Button asChild className = "w-full justify-start" variant = "outline" >
174+ < a
175+ href = "https://www.databuddy.cc/docs/getting-started"
176+ rel = "noopener noreferrer"
177+ target = "_blank"
178+ >
179+ < BookOpenIcon className = "mr-2" size = { 16 } />
180+ Documentation
181+ </ a >
182+ </ Button >
183+
184+ { /* Tip */ }
185+ < div className = "mt-auto rounded border border-dashed bg-background/50 p-4" >
186+ < p className = "mb-2 font-medium text-sm" > Need help?</ p >
187+ < p className = "text-muted-foreground text-xs leading-relaxed" >
188+ Contact support if you need to recover deleted data or transfer
189+ ownership of an organization.
190+ </ p >
191+ </ div >
192+ </ aside >
193+
194+ { /* Delete Dialog */ }
159195 < AlertDialog onOpenChange = { setShowDeleteDialog } open = { showDeleteDialog } >
160196 < AlertDialogContent >
161197 < AlertDialogHeader >
@@ -185,6 +221,7 @@ export function DangerZoneSettings({
185221 </ AlertDialogContent >
186222 </ AlertDialog >
187223
224+ { /* Leave Dialog */ }
188225 < AlertDialog onOpenChange = { setShowLeaveDialog } open = { showLeaveDialog } >
189226 < AlertDialogContent >
190227 < AlertDialogHeader >
0 commit comments