import Link from "next/link"; import { ArrowRight, FolderKanban } from "lucide-react"; import { getWorkspace } from "@/lib/session"; import { projectStatsByProject } from "@/lib/queries/account"; import { formatDateOnly, formatNumber, formatUsd, truncate } from "@/lib/format"; import { PageHeader } from "@/components/ui/page-header"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { EmptyState } from "@/components/ui/empty-state"; import { CreateProjectDialog } from "@/components/dashboard/projects/create-project-dialog"; import { SelectProjectButton } from "@/components/dashboard/projects/project-actions"; export const dynamic = "force-dynamic"; export const metadata = { title: "Projects · Fetcha" }; export default async function ProjectsPage({ searchParams }: { searchParams: Promise<{ new?: string }> }) { const sp = await searchParams; const ws = await getWorkspace(); const stats = await projectStatsByProject(ws.organization.id); return (
} /> {ws.projects.length === 0 ? ( } /> ) : (
Project Environment Requests · month Spend · month Keys Created Actions {ws.projects.map((p) => { const s = stats.get(p.id) ?? { requests: 0, spendUsd: 0, activeKeys: 0 }; const current = p.id === ws.project.id; return (
{p.name} {current ? ( Current ) : null}
{p.description ? {truncate(p.description, 80)} : {p.id}}
{p.environment} {formatNumber(s.requests)} {formatUsd(s.spendUsd)} {s.activeKeys} {formatDateOnly(p.createdAt)}
{!current ? : null}
); })}
)}
); }