"use client"; // ============================================================================ // Onboarding Page - First Workspace Creation // ============================================================================ import { useState } from "react"; import { useRouter } from "next/navigation"; import { Building2, Loader2, Megaphone } from "lucide-react"; import { workspacesApi } from "@/lib/api"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/components/ui/card"; import { STORAGE_KEYS } from "@/lib/utils/constants"; export default function OnboardingPage() { const router = useRouter(); const [name, setName] = useState(""); const [isCreating, setIsCreating] = useState(false); const [error, setError] = useState(null); const handleCreate = async () => { if (!name.trim()) return; try { setIsCreating(true); setError(null); const workspace = await workspacesApi.create({ name: name.trim() }); // Save as selected workspace localStorage.setItem(STORAGE_KEYS.SELECTED_WORKSPACE, workspace.id); // Redirect to dashboard router.replace(`/dashboard/${workspace.id}`); } catch (err: any) { setError(err?.error?.message || "Не удалось создать воркспейс"); } finally { setIsCreating(false); } }; return (
Добро пожаловать в TGEX! Создайте свой первый воркспейс для начала работы
setName(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") { handleCreate(); } }} disabled={isCreating} />

Воркспейс — это изолированное пространство для вашей команды. Вы сможете пригласить участников и настроить права доступа.

{error && (
{error}
)}
); }