import { createClient } from '@/lib/supabase/server' import NewProjectButton from '@/components/NewProjectButton' import ProjectList from '@/components/ProjectList' import ProjectCard from '@/components/ProjectCard' export default async function DashboardPage() { const supabase = await createClient() const { data: { user }, } = await supabase.auth.getUser() if (!user) { return null } const { data: projects, error } = await supabase .from('projects') .select('id, name, updated_at') .eq('user_id', user.id) .order('updated_at', { ascending: false }) // Fetch shared projects (projects where this user is a collaborator) const { data: collaborations } = await supabase .from('project_collaborators') .select('role, projects(id, name, updated_at)') .eq('user_id', user.id) const sharedProjects = (collaborations || []) .filter((c) => c.projects) .map((c) => ({ ...(c.projects as unknown as { id: string; name: string; updated_at: string }), shared: true, role: c.role, })) .sort((a, b) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime()) if (error) { return (
Failed to load projects. Please try again.
Select a project to open the flowchart editor