'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { ArrowLeft, Loader2, Building2, Lock } 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'; export default function NewWorkspacePage({ workspaceCreation, }: { workspaceCreation: { canCreateWorkspace: boolean; reason: string | null; }; }) { const router = useRouter(); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(''); const [formData, setFormData] = useState({ name: '', description: '', }); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); setError(''); try { const response = await fetch('/api/workspaces', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(formData), }); const data = await response.json(); if (!response.ok) { setError(data.error || 'Failed to create workspace'); return; } router.push(`/workspaces/${data.data.id}`); } catch { setError('Something went wrong. Please try again.'); } finally { setIsLoading(false); } }; return (
You can still create and manage projects inside workspaces where you are already a member.