'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import { toast } from 'sonner'; import { Video, Building2, FolderPlus, PlayCircle, Bell, ChevronRight, Loader2, Lock, UserPlus, Globe, Youtube, Upload, Mail, AlertCircle, Info, } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Card, CardContent } from '@/components/ui/card'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Textarea } from '@/components/ui/textarea'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; import { cn } from '@/lib/utils'; type Visibility = 'PRIVATE' | 'INVITE' | 'PUBLIC'; const TOTAL_STEPS = 5; 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: , }, { value: 'INVITE', label: 'Invite Only', description: 'Share with specific people via email', icon: , }, { value: 'PUBLIC', label: 'Public', description: 'Anyone with the link can view', icon: , }, ]; function ToggleButton({ enabled, onToggle, label, description, }: { enabled: boolean; onToggle: () => void; label: string; description?: string; }) { return ( ); } // ─── Step 1: Welcome ─────────────────────────────────────────────────────────── function StepWelcome({ userName, onNext }: { userName: string; onNext: () => void }) { return (

Welcome to OpenFrame, {userName.split(' ')[0]}!

OpenFrame is your collaborative video review platform. Collect timestamped feedback, manage versions, and streamline approvals — all in one place.

); } // ─── Step 2: Create Workspace ────────────────────────────────────────────────── function StepWorkspace({ canCreateWorkspace, availableWorkspaces, selectedWorkspaceId, onWorkspaceSelected, onNext, onWorkspaceCreated, }: { canCreateWorkspace: boolean; availableWorkspaces: Array<{ id: string; name: string; isOwner: boolean }>; selectedWorkspaceId: string | null; onWorkspaceSelected: (workspaceId: string) => void; onNext: () => void; onWorkspaceCreated: (id: string) => void; }) { 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 res = await fetch('/api/workspaces', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(formData), }); const data = await res.json(); if (!res.ok) { setError(data.error || 'Failed to create workspace'); return; } onWorkspaceCreated(data.data.id); onNext(); } catch { setError('Something went wrong. Please try again.'); } finally { setIsLoading(false); } }; if (!canCreateWorkspace) { return (

Workspace access

Your account can't create a new workspace right now.

{availableWorkspaces.length > 0 ? (
You can still create projects inside workspaces where you already have admin access.
) : (
You don't currently have a workspace where you can create projects. Ask a workspace owner to invite you as an admin, or upgrade later to create your own workspace.
)}
); } return (

Create your workspace

Workspaces organize your projects and team members.

setFormData({ ...formData, name: e.target.value })} required disabled={isLoading} className="h-11" />