import { createClient } from '@/lib/supabase/server' import Link from 'next/link' import FlowchartEditor from './FlowchartEditor' import type { FlowchartData } from '@/types/flowchart' type PageProps = { params: Promise<{ projectId: string }> } export default async function EditorPage({ params }: PageProps) { const { projectId } = await params const supabase = await createClient() const { data: { user }, } = await supabase.auth.getUser() if (!user) { return null } const { data: project, error } = await supabase .from('projects') .select('id, name, flowchart_data') .eq('id', projectId) .eq('user_id', user.id) .single() if (error || !project) { notFound() } const rawData = project.flowchart_data || {} const flowchartData: FlowchartData = { nodes: rawData.nodes || [], edges: rawData.edges || [], characters: rawData.characters || [], variables: rawData.variables || [], } // Migration flag: if the raw data doesn't have characters/variables arrays, // the project was created before these features existed and may need auto-migration const needsMigration = !rawData.characters && !rawData.variables return (<>

Project Not Found

The project you're looking for doesn't exist or you don't have access to it.

Back to Dashboard
) } const flowchartData = (project.flowchart_data || { nodes: [], edges: [], }) as FlowchartData return ( ) }