"use client"; import CustomButton from "@/components/ui/customButton"; import { Button } from "@/components/ui/button"; import { Code2, FolderDot, HelpCircle, Plus, Settings, Users, } from "lucide-react"; import { useEffect, useState } from "react"; import { Sandbox } from "@/lib/types"; import DashboardProjects from "./projects"; import DashboardSharedWithMe from "./shared"; import NewProjectModal from "./newProject"; import Link from "next/link"; import { useRouter, useSearchParams } from "next/navigation"; import AboutModal from "./about"; import { toast } from "sonner"; type TScreen = "projects" | "shared" | "settings" | "search"; export default function Dashboard({ sandboxes, shared, }: { sandboxes: Sandbox[]; shared: { id: string; name: string; type: "react" | "node"; author: string; sharedOn: Date; }[]; }) { const [screen, setScreen] = useState("projects"); const [newProjectModalOpen, setNewProjectModalOpen] = useState(false); const [aboutModalOpen, setAboutModalOpen] = useState(false); const activeScreen = (s: TScreen) => { if (screen === s) return "justify-start"; else return "justify-start font-normal text-muted-foreground"; }; const searchParams = useSearchParams(); const q = searchParams.get("q"); const router = useRouter(); useEffect(() => { if (!sandboxes) { router.refresh(); } }, [sandboxes]); return ( <>
{ if (sandboxes.length >= 8) { toast.error("You reached the maximum # of sandboxes."); return; } setNewProjectModalOpen(true); }} className="mb-4" > New Project {/* */}
{screen === "projects" ? ( <> {sandboxes ? ( ) : null} ) : screen === "shared" ? ( ) : screen === "settings" ? null : null}
); }