From e4e04fa784218df2cbe8bf5f7faf0a15dfab1dbc Mon Sep 17 00:00:00 2001 From: Michele Date: Sat, 31 Jan 2026 13:43:29 +0100 Subject: [PATCH] feat(01-06): add subscription management page - Display all plans (Free, Creator, Pro) in card grid - Highlight current plan with 'Piano attuale' badge - Add feature comparison table - Include FAQ section - Show payment deferral notice - All text in Italian --- src/app/(dashboard)/subscription/page.tsx | 179 ++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 src/app/(dashboard)/subscription/page.tsx diff --git a/src/app/(dashboard)/subscription/page.tsx b/src/app/(dashboard)/subscription/page.tsx new file mode 100644 index 0000000..5dcb0da --- /dev/null +++ b/src/app/(dashboard)/subscription/page.tsx @@ -0,0 +1,179 @@ +import { createClient } from '@/lib/supabase/server' +import { redirect } from 'next/navigation' +import { PlanCard } from '@/components/subscription/plan-card' +import { Plan, PlanFeatures } from '@/types/database' +import { PLAN_DISPLAY_ORDER } from '@/lib/plans' + +export default async function SubscriptionPage() { + const supabase = await createClient() + + const { data: { user } } = await supabase.auth.getUser() + + if (!user) { + redirect('/login') + } + + // Get user's current plan + const { data: profile } = await supabase + .from('profiles') + .select('plan_id') + .eq('id', user.id) + .single() + + // Get all plans + const { data: plans, error: plansError } = await supabase + .from('plans') + .select('*') + .order('price_monthly', { ascending: true }) + + if (plansError || !plans) { + return ( +
+

Errore nel caricamento dei piani

+
+ ) + } + + // Sort plans by our display order + const sortedPlans = [...plans].sort((a, b) => { + return PLAN_DISPLAY_ORDER.indexOf(a.name as typeof PLAN_DISPLAY_ORDER[number]) - + PLAN_DISPLAY_ORDER.indexOf(b.name as typeof PLAN_DISPLAY_ORDER[number]) + }) + + return ( +
+
+

Il tuo abbonamento

+

+ Scegli il piano piu adatto alle tue esigenze +

+
+ + {/* Info banner */} +
+

+ Nota: Il pagamento verra implementato nelle prossime versioni. + Per ora puoi passare liberamente tra i piani per testare le funzionalita. +

+
+ + {/* Plans grid */} +
+ {sortedPlans.map((plan) => ( + + ))} +
+ + {/* Feature comparison */} +
+

+ Confronto funzionalita +

+
+ + + + + {sortedPlans.map((plan) => ( + + ))} + + + + (p.features as PlanFeatures).posts_per_month.toString()} + /> + (p.features as PlanFeatures).social_accounts.toString()} + /> + (p.features as PlanFeatures).ai_models.length.toString()} + /> + (p.features as PlanFeatures).image_generation ? '\u2713' : '\u2014'} + /> + { + const auto = (p.features as PlanFeatures).automation + if (auto === false) return '\u2014' + if (auto === 'manual') return 'Manuale' + if (auto === 'full') return 'Completa' + return '\u2014' + }} + /> + +
+ Funzionalita + + {plan.display_name_it} +
+
+
+ + {/* FAQ */} +
+

+ Domande frequenti +

+
+ + + +
+
+
+ ) +} + +function FeatureRow({ + feature, + plans, + getValue, +}: { + feature: string + plans: Plan[] + getValue: (plan: Plan) => string +}) { + return ( + + {feature} + {plans.map((plan) => ( + + {getValue(plan)} + + ))} + + ) +} + +function FaqItem({ question, answer }: { question: string; answer: string }) { + return ( +
+

{question}

+

{answer}

+
+ ) +}