diff --git a/src/app/(dashboard)/dashboard/page.tsx b/src/app/(dashboard)/dashboard/page.tsx new file mode 100644 index 0000000..7695cb9 --- /dev/null +++ b/src/app/(dashboard)/dashboard/page.tsx @@ -0,0 +1,113 @@ +import { createClient } from '@/lib/supabase/server' +import { redirect } from 'next/navigation' +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' + +export default async function DashboardPage() { + const supabase = await createClient() + + const { data: { user } } = await supabase.auth.getUser() + + if (!user) { + redirect('/login') + } + + // Get profile with plan details + const { data: profile } = await supabase + .from('profiles') + .select(` + *, + plans ( + name, + display_name_it, + features + ) + `) + .eq('id', user.id) + .single() + + const features = profile?.plans?.features as { + posts_per_month?: number + ai_models?: string[] + social_accounts?: number + } | null + + return ( +
+
+

Dashboard

+

Benvenuto in Leopost

+
+ +
+ + + Il tuo piano + + {profile?.plans?.display_name_it || 'Gratuito'} + + + +
    +
  • + {features?.posts_per_month || 10} post/mese +
  • +
  • + {features?.social_accounts || 1} account social +
  • +
  • + {features?.ai_models?.length || 1} modelli AI +
  • +
+
+
+ + + + Prossimi passi + + Completa la configurazione + + + +
    +
  • + + ✓ + + Account creato +
  • +
  • + + 2 + + Collega social (Phase 2) +
  • +
  • + + 3 + + Configura brand (Phase 3) +
  • +
+
+
+ + + + Attivita + + Le tue statistiche + + + +
+ Nessuna attivita ancora. +
+ Inizia collegando un account social! +
+
+
+
+
+ ) +} diff --git a/src/app/(dashboard)/layout.tsx b/src/app/(dashboard)/layout.tsx new file mode 100644 index 0000000..fe8252d --- /dev/null +++ b/src/app/(dashboard)/layout.tsx @@ -0,0 +1,72 @@ +import { createClient } from '@/lib/supabase/server' +import { redirect } from 'next/navigation' +import { UserNav } from '@/components/layout/user-nav' +import Link from 'next/link' + +export default async function DashboardLayout({ + children, +}: { + children: React.ReactNode +}) { + const supabase = await createClient() + + // Get user (should always exist due to middleware) + const { data: { user }, error: authError } = await supabase.auth.getUser() + + if (authError || !user) { + redirect('/login') + } + + // Get profile with plan info + const { data: profile } = await supabase + .from('profiles') + .select(` + *, + plans ( + name, + display_name_it + ) + `) + .eq('id', user.id) + .single() + + return ( +
+ {/* Header */} +
+
+
+
+ + Leopost + + +
+ +
+
+
+ + {/* Main content */} +
+ {children} +
+
+ ) +} diff --git a/src/components/layout/user-nav.tsx b/src/components/layout/user-nav.tsx new file mode 100644 index 0000000..66edbb7 --- /dev/null +++ b/src/components/layout/user-nav.tsx @@ -0,0 +1,43 @@ +'use client' + +import { createClient } from '@/lib/supabase/client' +import { useRouter } from 'next/navigation' +import { Button } from '@/components/ui/button' +import { useState } from 'react' + +interface UserNavProps { + email: string + planName?: string +} + +export function UserNav({ email, planName }: UserNavProps) { + const [loading, setLoading] = useState(false) + const router = useRouter() + const supabase = createClient() + + async function handleSignOut() { + setLoading(true) + await supabase.auth.signOut() + router.push('/login') + router.refresh() + } + + return ( +
+
+

{email}

+ {planName && ( +

Piano {planName}

+ )} +
+ +
+ ) +}