"use client"; import { use, useState, useEffect } from "react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Cog, Database, Github, Globe, Server, Code2, ExternalLink, Plus, Loader2, CheckCircle2, Circle, Clock, Key, Zap, } from "lucide-react"; import { Separator } from "@/components/ui/separator"; import Link from "next/link"; import { toast } from "sonner"; import { CollapsibleSidebar } from "@/components/ui/collapsible-sidebar"; interface WorkItem { id: string; title: string; path: string; status: "built" | "in_progress" | "missing"; category: string; sessionsCount: number; commitsCount: number; estimatedCost?: number; } interface TechResource { id: string; name: string; type: "firebase" | "github" | "domain" | "api"; status: "active" | "inactive"; url?: string; lastUpdated?: string; } export default function TechPage({ params, }: { params: Promise<{ workspace: string; projectId: string }>; }) { const { workspace, projectId } = use(params); const [workItems, setWorkItems] = useState([]); const [resources, setResources] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { loadTechData(); }, [projectId]); const loadTechData = async () => { try { setLoading(true); const response = await fetch(`/api/projects/${projectId}/timeline-view`); if (response.ok) { const data = await response.json(); // Filter for technical items only const techItems = data.workItems.filter((item: WorkItem) => isTechnical(item) ); setWorkItems(techItems); } // Mock resources data setResources([ { id: "1", name: "Firebase Project", type: "firebase", status: "active", url: "https://console.firebase.google.com", lastUpdated: new Date().toISOString(), }, { id: "2", name: "GitHub Repository", type: "github", status: "active", url: "https://github.com", lastUpdated: new Date().toISOString(), }, ]); } catch (error) { console.error("Error loading tech data:", error); toast.error("Failed to load tech data"); } finally { setLoading(false); } }; const isTechnical = (item: WorkItem): boolean => { const path = item.path.toLowerCase(); const title = item.title.toLowerCase(); // APIs and backend if (path.startsWith('/api/')) return true; if (title.includes(' api') || title.includes('api ')) return true; // Auth infrastructure if (path.includes('oauth') && !path.includes('button') && !path.includes('signin')) return true; // System settings if (item.category === 'Settings' && title.includes('api')) return true; return false; }; const getStatusIcon = (status: string) => { if (status === "built" || status === "active") return ; if (status === "in_progress") return ; return ; }; const getResourceIcon = (type: string) => { switch (type) { case "firebase": return ; case "github": return ; case "domain": return ; case "api": return ; default: return ; } }; return (
{/* Left Sidebar */}

Infrastructure

Resources {resources.length}
Active {resources.filter(r => r.status === 'active').length}
Work Items {workItems.length}
{/* Main Content */}
{/* Header */}

Tech Infrastructure

APIs, services, and technical resources

{/* Content */}
{loading ? (
) : ( <> {/* Infrastructure Resources */}

Infrastructure Resources

{resources.map((resource) => (
{getResourceIcon(resource.type)} {resource.name}
{getStatusIcon(resource.status)}
{resource.type} {resource.lastUpdated && (

Updated {new Date(resource.lastUpdated).toLocaleDateString()}

)} {resource.url && ( )}
))}
{/* Technical Work Items */}

Technical Work Items

{workItems.length} items
{workItems.length === 0 ? (

No technical items yet

Technical items include APIs, services, and infrastructure

) : (
{workItems.map((item) => (
{getStatusIcon(item.status)}
{/* Title and Status */}

{item.title}

{item.status === "built" ? "Active" : item.status === "in_progress" ? "In Progress" : "Planned"}
{/* Path */}

{item.path}

{/* Stats */}
{item.sessionsCount} sessions {item.commitsCount} commits {item.estimatedCost && ( <> ${item.estimatedCost.toFixed(2)} )}
{/* Actions */}
{item.path.startsWith('/api/') && ( )}
))}
)}
{/* Quick Links */} )}
{/* End Main Content */}
); }