"use client"; import { Sandbox } from "@/lib/types"; import ProjectCard from "./projectCard"; import Image from "next/image"; import ProjectCardDropdown from "./projectCard/dropdown"; import { Clock, Globe, Lock } from "lucide-react"; import Link from "next/link"; import { Card } from "../ui/card"; import { deleteSandbox, updateSandbox } from "@/lib/actions"; import { toast } from "sonner"; import { useEffect, useState } from "react"; import { CanvasRevealEffect } from "./projectCard/revealEffect"; const colors = { react: [ [71, 207, 237], [30, 126, 148], ], node: [ [86, 184, 72], [59, 112, 52], ], }; export default function DashboardProjects({ sandboxes, q, }: { sandboxes: Sandbox[]; q: string | null; }) { const [deletingId, setDeletingId] = useState(""); const onDelete = async (sandbox: Sandbox) => { setDeletingId(sandbox.id); toast(`Project ${sandbox.name} deleted.`); await deleteSandbox(sandbox.id); }; useEffect(() => { if (deletingId) { setDeletingId(""); } }, [sandboxes]); const onVisibilityChange = async (sandbox: Sandbox) => { const newVisibility = sandbox.visibility === "public" ? "private" : "public"; toast(`Project ${sandbox.name} is now ${newVisibility}.`); await updateSandbox({ id: sandbox.id, visibility: newVisibility, }); }; return (
{q && q.length > 0 ? `Showing search results for: ${q}` : "My Projects"}
{sandboxes.length > 0 ? (
{sandboxes.map((sandbox) => { if (q && q.length > 0) { if (!sandbox.name.toLowerCase().includes(q.toLowerCase())) { return null; } } return (
); })}
) : (
You don't have any projects yet. Create one to get started!
)}
); }