feat: add workspace management features including member invitations and role updates

- Implemented API endpoints for managing workspace members (GET, POST, PATCH, DELETE).
- Added workspace creation and retrieval functionalities.
- Enhanced project model to associate with workspaces.
- Updated project member roles and access control logic.
- Created sign-out page and updated authentication flow.
- Modified header to include navigation to workspaces.
- Updated Prisma schema to include workspace and member models.
- Seed script updated to create demo workspaces and associated members.
This commit is contained in:
Yusuf İpek
2026-02-07 07:41:12 +03:00
parent d90ce4e1f6
commit 6e95f667e3
28 changed files with 2891 additions and 138 deletions
@@ -0,0 +1,329 @@
'use client';
import { useState, useEffect, useCallback } from 'react';
import { useParams, useRouter } from 'next/navigation';
import Link from 'next/link';
import {
ArrowLeft,
Plus,
Loader2,
Crown,
Shield,
MessageSquare,
Trash2,
UserPlus,
} from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { Badge } from '@/components/ui/badge';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
interface Member {
id: string;
role: 'ADMIN' | 'COMMENTATOR';
userId: string;
user: {
id: string;
name: string | null;
email: string | null;
image: string | null;
};
}
interface Owner {
id: string;
name: string | null;
email: string | null;
image: string | null;
}
export default function WorkspaceMembersPage() {
const params = useParams();
const router = useRouter();
const workspaceId = params.workspaceId as string;
const [members, setMembers] = useState<Member[]>([]);
const [owner, setOwner] = useState<Owner | null>(null);
const [isLoading, setIsLoading] = useState(true);
const [inviteEmail, setInviteEmail] = useState('');
const [inviteRole, setInviteRole] = useState<'ADMIN' | 'COMMENTATOR'>('COMMENTATOR');
const [isInviting, setIsInviting] = useState(false);
const [error, setError] = useState('');
const [success, setSuccess] = useState('');
const fetchMembers = useCallback(async () => {
try {
const res = await fetch(`/api/workspaces/${workspaceId}/members`);
if (!res.ok) {
if (res.status === 403) router.push('/workspaces');
return;
}
const data = await res.json();
setMembers(data.members);
setOwner(data.owner);
} catch {
setError('Failed to load members');
} finally {
setIsLoading(false);
}
}, [workspaceId, router]);
useEffect(() => {
fetchMembers();
}, [fetchMembers]);
const handleInvite = async (e: React.FormEvent) => {
e.preventDefault();
setIsInviting(true);
setError('');
setSuccess('');
try {
const res = await fetch(`/api/workspaces/${workspaceId}/members`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: inviteEmail, role: inviteRole }),
});
const data = await res.json();
if (!res.ok) {
setError(data.error || 'Failed to invite member');
return;
}
setSuccess(`Invited ${data.user.name || data.user.email} as ${inviteRole.toLowerCase()}`);
setInviteEmail('');
fetchMembers();
} catch {
setError('Something went wrong');
} finally {
setIsInviting(false);
}
};
const handleRoleChange = async (memberId: string, newRole: string) => {
try {
const res = await fetch(`/api/workspaces/${workspaceId}/members/${memberId}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ role: newRole }),
});
if (!res.ok) {
const data = await res.json();
setError(data.error || 'Failed to update role');
return;
}
fetchMembers();
} catch {
setError('Failed to update role');
}
};
const handleRemove = async (memberId: string) => {
if (!confirm('Are you sure you want to remove this member?')) return;
try {
const res = await fetch(`/api/workspaces/${workspaceId}/members/${memberId}`, {
method: 'DELETE',
});
if (!res.ok) {
const data = await res.json();
setError(data.error || 'Failed to remove member');
return;
}
fetchMembers();
} catch {
setError('Failed to remove member');
}
};
if (isLoading) {
return (
<div className="flex items-center justify-center min-h-[50vh]">
<Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
</div>
);
}
return (
<div className="px-6 lg:px-8 py-8 w-full max-w-4xl mx-auto">
<div className="mb-6">
<Link
href={`/workspaces/${workspaceId}`}
className="inline-flex items-center text-sm text-muted-foreground hover:text-foreground transition-colors"
>
<ArrowLeft className="h-4 w-4 mr-1" />
Back to Workspace
</Link>
</div>
<div className="mb-8">
<h1 className="text-3xl font-bold tracking-tight">Members</h1>
<p className="text-muted-foreground mt-1">
Manage who has access to this workspace and all its projects
</p>
</div>
{/* Invite Form */}
<Card className="mb-8">
<CardHeader>
<CardTitle className="flex items-center gap-2">
<UserPlus className="h-5 w-5" />
Invite Member
</CardTitle>
<CardDescription>
Invite someone by email. They must have an account to be added.
</CardDescription>
</CardHeader>
<CardContent>
<form onSubmit={handleInvite} className="flex gap-3 items-end">
<div className="flex-1">
<Label htmlFor="email" className="mb-2 block">Email Address</Label>
<Input
id="email"
type="email"
placeholder="[email protected]"
value={inviteEmail}
onChange={(e) => setInviteEmail(e.target.value)}
required
disabled={isInviting}
/>
</div>
<div className="w-40">
<Label className="mb-2 block">Role</Label>
<Select value={inviteRole} onValueChange={(v) => setInviteRole(v as 'ADMIN' | 'COMMENTATOR')}>
<SelectTrigger className="w-full">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="ADMIN">Admin</SelectItem>
<SelectItem value="COMMENTATOR">Commentator</SelectItem>
</SelectContent>
</Select>
</div>
<Button type="submit" disabled={isInviting}>
{isInviting ? (
<Loader2 className="h-4 w-4 animate-spin" />
) : (
<>
<Plus className="h-4 w-4 mr-1" />
Invite
</>
)}
</Button>
</form>
{error && (
<div className="mt-3 rounded-md bg-destructive/10 p-3 text-sm text-destructive">
{error}
</div>
)}
{success && (
<div className="mt-3 rounded-md bg-green-500/10 p-3 text-sm text-green-700 dark:text-green-400">
{success}
</div>
)}
</CardContent>
</Card>
{/* Members List */}
<Card>
<CardHeader>
<CardTitle>Current Members</CardTitle>
<CardDescription>
Admins can manage projects and members. Commentators can view and comment only.
</CardDescription>
</CardHeader>
<CardContent className="space-y-3">
{/* Owner */}
{owner && (
<div className="flex items-center justify-between p-3 rounded-lg bg-accent/30">
<div className="flex items-center gap-3">
<Avatar className="h-9 w-9">
<AvatarImage src={owner.image ?? undefined} />
<AvatarFallback>{owner.name?.charAt(0).toUpperCase() ?? 'U'}</AvatarFallback>
</Avatar>
<div>
<p className="text-sm font-medium">{owner.name || 'Unnamed'}</p>
<p className="text-xs text-muted-foreground">{owner.email}</p>
</div>
</div>
<Badge variant="default" className="flex items-center gap-1">
<Crown className="h-3 w-3" />
Owner
</Badge>
</div>
)}
{/* Members */}
{members.map((member) => (
<div key={member.id} className="flex items-center justify-between p-3 rounded-lg border">
<div className="flex items-center gap-3">
<Avatar className="h-9 w-9">
<AvatarImage src={member.user.image ?? undefined} />
<AvatarFallback>{member.user.name?.charAt(0).toUpperCase() ?? 'U'}</AvatarFallback>
</Avatar>
<div>
<p className="text-sm font-medium">{member.user.name || 'Unnamed'}</p>
<p className="text-xs text-muted-foreground">{member.user.email}</p>
</div>
</div>
<div className="flex items-center gap-2">
<Select
value={member.role}
onValueChange={(v) => handleRoleChange(member.id, v)}
>
<SelectTrigger className="w-36 h-8">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="ADMIN">
<span className="flex items-center gap-1.5">
<Shield className="h-3.5 w-3.5" />
Admin
</span>
</SelectItem>
<SelectItem value="COMMENTATOR">
<span className="flex items-center gap-1.5">
<MessageSquare className="h-3.5 w-3.5" />
Commentator
</span>
</SelectItem>
</SelectContent>
</Select>
<Button
variant="ghost"
size="icon"
className="h-8 w-8 text-destructive hover:text-destructive"
onClick={() => handleRemove(member.id)}
>
<Trash2 className="h-4 w-4" />
</Button>
</div>
</div>
))}
{members.length === 0 && (
<p className="text-sm text-muted-foreground text-center py-4">
No members yet. Invite someone above.
</p>
)}
</CardContent>
</Card>
</div>
);
}
@@ -0,0 +1,203 @@
import Link from 'next/link';
import { notFound, redirect } from 'next/navigation';
import {
ArrowLeft,
Plus,
Settings,
FolderOpen,
Clock,
Users,
Globe,
Lock,
UserPlus,
} from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { auth } from '@/lib/auth';
import { db } from '@/lib/db';
function VisibilityIcon({ visibility }: { visibility: string }) {
switch (visibility) {
case 'PUBLIC':
return <Globe className="h-3.5 w-3.5" />;
case 'INVITE':
return <UserPlus className="h-3.5 w-3.5" />;
default:
return <Lock className="h-3.5 w-3.5" />;
}
}
function formatRelativeTime(date: Date): string {
const now = new Date();
const diffMs = now.getTime() - date.getTime();
const diffMins = Math.floor(diffMs / 60000);
const diffHours = Math.floor(diffMs / 3600000);
const diffDays = Math.floor(diffMs / 86400000);
if (diffMins < 1) return 'just now';
if (diffMins < 60) return `${diffMins}m ago`;
if (diffHours < 24) return `${diffHours}h ago`;
if (diffDays < 7) return `${diffDays}d ago`;
return date.toLocaleDateString();
}
interface WorkspacePageProps {
params: Promise<{ workspaceId: string }>;
}
export default async function WorkspacePage({ params }: WorkspacePageProps) {
const session = await auth();
const { workspaceId } = await params;
if (!session?.user?.id) {
redirect('/login');
}
const workspace = await db.workspace.findUnique({
where: { id: workspaceId },
include: {
owner: { select: { id: true, name: true } },
members: {
where: { userId: session.user.id },
select: { role: true },
},
projects: {
orderBy: { updatedAt: 'desc' },
include: {
_count: { select: { videos: true, members: true } },
},
},
_count: { select: { projects: true, members: true } },
},
});
if (!workspace) {
notFound();
}
const isOwner = session.user.id === workspace.ownerId;
const membership = workspace.members[0];
const isMember = !!membership;
const isAdmin = isOwner || membership?.role === 'ADMIN';
if (!isOwner && !isMember) {
redirect('/workspaces');
}
return (
<div className="px-6 lg:px-8 py-8 w-full">
{/* Back & Header */}
<div className="mb-6">
<Link
href="/workspaces"
className="inline-flex items-center text-sm text-muted-foreground hover:text-foreground transition-colors"
>
<ArrowLeft className="h-4 w-4 mr-1" />
All Workspaces
</Link>
</div>
<div className="flex items-center justify-between mb-8">
<div>
<h1 className="text-3xl font-bold tracking-tight">{workspace.name}</h1>
{workspace.description && (
<p className="text-muted-foreground mt-1">{workspace.description}</p>
)}
<div className="flex items-center gap-4 mt-2 text-sm text-muted-foreground">
<span className="flex items-center gap-1">
<FolderOpen className="h-3.5 w-3.5" />
{workspace._count.projects} projects
</span>
<span className="flex items-center gap-1">
<Users className="h-3.5 w-3.5" />
{workspace._count.members + 1} members
</span>
</div>
</div>
<div className="flex items-center gap-2">
{isAdmin && (
<>
<Button asChild variant="outline" size="sm">
<Link href={`/workspaces/${workspaceId}/members`}>
<Users className="h-4 w-4 mr-2" />
Members
</Link>
</Button>
<Button asChild variant="outline" size="sm">
<Link href={`/workspaces/${workspaceId}/settings`}>
<Settings className="h-4 w-4 mr-2" />
Settings
</Link>
</Button>
<Button asChild size="sm">
<Link href={`/workspaces/${workspaceId}/projects/new`}>
<Plus className="h-4 w-4 mr-2" />
New Project
</Link>
</Button>
</>
)}
</div>
</div>
{/* Projects Grid */}
{workspace.projects.length > 0 ? (
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
{workspace.projects.map((project) => (
<Link key={project.id} href={`/projects/${project.id}`}>
<Card className="h-full transition-colors hover:bg-accent/50 cursor-pointer">
<CardHeader>
<div className="flex items-start justify-between">
<CardTitle className="flex items-center gap-2">
<FolderOpen className="h-5 w-5 text-primary" />
{project.name}
</CardTitle>
<Badge variant="outline" className="flex items-center gap-1">
<VisibilityIcon visibility={project.visibility} />
{project.visibility.toLowerCase()}
</Badge>
</div>
<CardDescription className="line-clamp-2">
{project.description || 'No description'}
</CardDescription>
</CardHeader>
<CardContent>
<div className="flex items-center gap-4 text-sm text-muted-foreground">
<span className="flex items-center gap-1">
<Clock className="h-3.5 w-3.5" />
{formatRelativeTime(project.updatedAt)}
</span>
<span className="flex items-center gap-1">
<Users className="h-3.5 w-3.5" />
{project._count.members + 1}
</span>
<span>{project._count.videos} videos</span>
</div>
</CardContent>
</Card>
</Link>
))}
</div>
) : (
<Card className="border-dashed">
<CardContent className="flex flex-col items-center justify-center py-16">
<FolderOpen className="h-12 w-12 text-muted-foreground mb-4" />
<h3 className="text-lg font-medium mb-2">No projects yet</h3>
<p className="text-muted-foreground text-center mb-4">
Create a project in this workspace to get started
</p>
{isAdmin && (
<Button asChild>
<Link href={`/workspaces/${workspaceId}/projects/new`}>
<Plus className="h-4 w-4 mr-2" />
Create Project
</Link>
</Button>
)}
</CardContent>
</Card>
)}
</div>
);
}
@@ -0,0 +1,182 @@
'use client';
import { useState, use } from 'react';
import { useRouter } from 'next/navigation';
import Link from 'next/link';
import { ArrowLeft, Loader2, Globe, Lock, UserPlus, FolderPlus } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Textarea } from '@/components/ui/textarea';
type Visibility = 'PRIVATE' | 'INVITE' | 'PUBLIC';
const visibilityOptions: { value: Visibility; label: string; description: string; icon: React.ReactNode }[] = [
{
value: 'PRIVATE',
label: 'Private',
description: 'Only workspace members and project members can access',
icon: <Lock className="h-5 w-5" />,
},
{
value: 'INVITE',
label: 'Invite Only',
description: 'Share with specific people via email',
icon: <UserPlus className="h-5 w-5" />,
},
{
value: 'PUBLIC',
label: 'Public',
description: 'Anyone with the link can view',
icon: <Globe className="h-5 w-5" />,
},
];
export default function NewWorkspaceProjectPage({ params }: { params: Promise<{ workspaceId: string }> }) {
const { workspaceId } = use(params);
const router = useRouter();
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState('');
const [formData, setFormData] = useState({
name: '',
description: '',
visibility: 'PRIVATE' as Visibility,
});
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setIsLoading(true);
setError('');
try {
const response = await fetch('/api/projects', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ ...formData, workspaceId }),
});
const data = await response.json();
if (!response.ok) {
setError(data.error || 'Failed to create project');
return;
}
router.push(`/projects/${data.id}`);
} catch {
setError('Something went wrong. Please try again.');
} finally {
setIsLoading(false);
}
};
return (
<div className="min-h-[calc(100vh-4rem)] flex items-start justify-center py-12 px-4">
<div className="w-full max-w-xl">
<div className="mb-8">
<Link
href={`/workspaces/${workspaceId}`}
className="inline-flex items-center text-sm text-muted-foreground hover:text-foreground transition-colors"
>
<ArrowLeft className="h-4 w-4 mr-1" />
Back to Workspace
</Link>
</div>
<Card className="border-border/50 shadow-lg">
<CardHeader className="text-center pb-2">
<div className="mx-auto w-14 h-14 rounded-full bg-primary/10 flex items-center justify-center mb-4">
<FolderPlus className="h-7 w-7 text-primary" />
</div>
<CardTitle className="text-2xl">Create Project in Workspace</CardTitle>
<CardDescription className="text-base">
This project will be accessible to all workspace members
</CardDescription>
</CardHeader>
<CardContent className="pt-6">
<form onSubmit={handleSubmit} className="space-y-6">
<div className="space-y-2">
<Label htmlFor="name" className="text-sm font-medium">
Project Name
</Label>
<Input
id="name"
placeholder="e.g., Product Launch Video"
value={formData.name}
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
required
disabled={isLoading}
/>
</div>
<div className="space-y-2">
<Label htmlFor="description" className="text-sm font-medium">
Description{' '}
<span className="text-muted-foreground font-normal">(optional)</span>
</Label>
<Textarea
id="description"
placeholder="What is this project about?"
value={formData.description}
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
rows={3}
disabled={isLoading}
/>
</div>
<div className="space-y-3">
<Label className="text-sm font-medium">Visibility</Label>
<div className="grid gap-2">
{visibilityOptions.map((option) => (
<label
key={option.value}
className={`flex items-start gap-3 rounded-lg border p-3 cursor-pointer transition-colors ${
formData.visibility === option.value
? 'border-primary bg-primary/5'
: 'hover:bg-accent/50'
}`}
>
<input
type="radio"
name="visibility"
value={option.value}
checked={formData.visibility === option.value}
onChange={(e) =>
setFormData({ ...formData, visibility: e.target.value as Visibility })
}
className="sr-only"
/>
<div className="mt-0.5 text-muted-foreground">{option.icon}</div>
<div>
<p className="text-sm font-medium">{option.label}</p>
<p className="text-xs text-muted-foreground">{option.description}</p>
</div>
</label>
))}
</div>
</div>
{error && (
<div className="rounded-md bg-destructive/10 p-3 text-sm text-destructive">
{error}
</div>
)}
<Button type="submit" className="w-full" disabled={isLoading}>
{isLoading ? (
<>
<Loader2 className="h-4 w-4 mr-2 animate-spin" />
Creating...
</>
) : (
'Create Project'
)}
</Button>
</form>
</CardContent>
</Card>
</div>
</div>
);
}
@@ -0,0 +1,226 @@
'use client';
import { useState, useEffect, useCallback } from 'react';
import { useParams, useRouter } from 'next/navigation';
import Link from 'next/link';
import { ArrowLeft, Loader2, Building2, Trash2 } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Textarea } from '@/components/ui/textarea';
import { Separator } from '@/components/ui/separator';
interface WorkspaceData {
id: string;
name: string;
description: string | null;
slug: string;
ownerId: string;
}
export default function WorkspaceSettingsPage() {
const params = useParams();
const router = useRouter();
const workspaceId = params.workspaceId as string;
const [workspace, setWorkspace] = useState<WorkspaceData | null>(null);
const [isLoading, setIsLoading] = useState(true);
const [isSaving, setIsSaving] = useState(false);
const [isDeleting, setIsDeleting] = useState(false);
const [error, setError] = useState('');
const [success, setSuccess] = useState('');
const [formData, setFormData] = useState({ name: '', description: '' });
const fetchWorkspace = useCallback(async () => {
try {
const res = await fetch(`/api/workspaces/${workspaceId}`);
if (!res.ok) {
router.push('/workspaces');
return;
}
const data = await res.json();
setWorkspace(data);
setFormData({
name: data.name,
description: data.description || '',
});
} catch {
setError('Failed to load workspace');
} finally {
setIsLoading(false);
}
}, [workspaceId, router]);
useEffect(() => {
fetchWorkspace();
}, [fetchWorkspace]);
const handleSave = async (e: React.FormEvent) => {
e.preventDefault();
setIsSaving(true);
setError('');
setSuccess('');
try {
const res = await fetch(`/api/workspaces/${workspaceId}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(formData),
});
if (!res.ok) {
const data = await res.json();
setError(data.error || 'Failed to update workspace');
return;
}
setSuccess('Workspace updated successfully');
} catch {
setError('Something went wrong');
} finally {
setIsSaving(false);
}
};
const handleDelete = async () => {
if (!confirm('Are you sure? This will NOT delete the projects inside, but they will be unlinked from this workspace.')) return;
if (!confirm('This action cannot be undone. Type the workspace name to confirm.')) return;
setIsDeleting(true);
try {
const res = await fetch(`/api/workspaces/${workspaceId}`, {
method: 'DELETE',
});
if (!res.ok) {
const data = await res.json();
setError(data.error || 'Failed to delete workspace');
return;
}
router.push('/workspaces');
} catch {
setError('Failed to delete workspace');
} finally {
setIsDeleting(false);
}
};
if (isLoading) {
return (
<div className="flex items-center justify-center min-h-[50vh]">
<Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
</div>
);
}
if (!workspace) return null;
return (
<div className="px-6 lg:px-8 py-8 w-full max-w-2xl mx-auto">
<div className="mb-6">
<Link
href={`/workspaces/${workspaceId}`}
className="inline-flex items-center text-sm text-muted-foreground hover:text-foreground transition-colors"
>
<ArrowLeft className="h-4 w-4 mr-1" />
Back to Workspace
</Link>
</div>
<div className="mb-8">
<h1 className="text-3xl font-bold tracking-tight">Workspace Settings</h1>
<p className="text-muted-foreground mt-1">
Manage workspace configuration
</p>
</div>
<Card className="mb-8">
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Building2 className="h-5 w-5" />
General
</CardTitle>
</CardHeader>
<CardContent>
<form onSubmit={handleSave} className="space-y-4">
<div className="space-y-2">
<Label htmlFor="name">Workspace Name</Label>
<Input
id="name"
value={formData.name}
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
required
disabled={isSaving}
/>
</div>
<div className="space-y-2">
<Label htmlFor="description">Description</Label>
<Textarea
id="description"
value={formData.description}
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
rows={3}
disabled={isSaving}
/>
</div>
{error && (
<div className="rounded-md bg-destructive/10 p-3 text-sm text-destructive">
{error}
</div>
)}
{success && (
<div className="rounded-md bg-green-500/10 p-3 text-sm text-green-700 dark:text-green-400">
{success}
</div>
)}
<Button type="submit" disabled={isSaving}>
{isSaving ? (
<>
<Loader2 className="h-4 w-4 mr-2 animate-spin" />
Saving...
</>
) : (
'Save Changes'
)}
</Button>
</form>
</CardContent>
</Card>
<Separator className="my-8" />
{/* Danger Zone */}
<Card className="border-destructive/50">
<CardHeader>
<CardTitle className="text-destructive">Danger Zone</CardTitle>
<CardDescription>
Irreversible actions. Proceed with caution.
</CardDescription>
</CardHeader>
<CardContent>
<Button
variant="destructive"
onClick={handleDelete}
disabled={isDeleting}
>
{isDeleting ? (
<>
<Loader2 className="h-4 w-4 mr-2 animate-spin" />
Deleting...
</>
) : (
<>
<Trash2 className="h-4 w-4 mr-2" />
Delete Workspace
</>
)}
</Button>
</CardContent>
</Card>
</div>
);
}