diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx new file mode 100644 index 0000000..7ddae9c --- /dev/null +++ b/src/app/dashboard/page.tsx @@ -0,0 +1,102 @@ +import { createClient } from '@/lib/supabase/server' +import Link from 'next/link' + +interface Project { + id: string + name: string + updated_at: string +} + +function formatDate(dateString: string): string { + const date = new Date(dateString) + return date.toLocaleDateString('en-US', { + year: 'numeric', + month: 'short', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + }) +} + +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 }) + + if (error) { + return ( +
+

+ Failed to load projects. Please try again. +

+
+ ) + } + + return ( +
+
+

+ Your Projects +

+

+ Select a project to open the flowchart editor +

+
+ + {projects && projects.length > 0 ? ( +
+ {projects.map((project: Project) => ( + +

+ {project.name} +

+

+ Last updated: {formatDate(project.updated_at)} +

+ + ))} +
+ ) : ( +
+ +

+ No projects yet +

+

+ Get started by creating your first visual novel project. +

+
+ )} +
+ ) +}