import React from 'react' import { usePage, Link } from '@inertiajs/react' import SeoHead from '../../../components/seo/SeoHead' import AccessBadge from '../../../components/academy/billing/AccessBadge' import PlanCard from '../../../components/academy/billing/PlanCard' import { trackUpgradeClick, useAcademyPageAnalytics } from '../../../lib/academyAnalytics' function getCsrfToken() { return document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || '' } function heroText(currentTier, isSubscribed) { if (isSubscribed && currentTier === 'pro') { return { heading: 'You have full Academy access.', body: 'All lessons, prompts, and Academy content are unlocked on your Pro plan. To upgrade, downgrade, or cancel, use the subscription manager below.', } } if (isSubscribed && currentTier === 'creator') { return { heading: "You're on the Creator plan.", body: 'Creator content is fully unlocked. Upgrade to Pro anytime to access the advanced lesson track and everything new that launches at the Pro tier.', } } if (currentTier === 'admin') { return { heading: 'Academy plans.', body: 'Your admin account already has full Academy access. Browse the plans below.', } } if (isSubscribed) { return { heading: 'Manage your Academy subscription.', body: 'Your plan is active. Review your options below or use the subscription manager to make changes.', } } return { heading: 'Unlock everything in Academy.', body: "Start free and upgrade when you're ready. Creator unlocks premium lessons and the full prompt library. Pro adds the advanced lesson track and is the highest Academy tier.", } } function SidePanel({ currentTier, isSubscribed, activePlanLabel, activePlanPrice, manageHref }) { if (isSubscribed) { return (

Your subscription

Active plan

{activePlanLabel || 'Academy plan'}

Billed monthly

{activePlanPrice || '—'}

{manageHref ? ( Manage subscription ) : null}
) } return (

Why upgrade?

{[ { title: 'Instant access', body: 'Subscription activates the moment payment is confirmed.' }, { title: 'Cancel anytime', body: 'No lock-in. Keep access until the end of the billing period.' }, { title: 'Switch freely', body: 'Move between Creator and Pro from your subscription manager.' }, ].map(({ title, body }) => (

{title}

{body}

))}
) } export default function AcademyBillingPricing({ seo, billingEnabled, currentTier, isSubscribed, activePlanKey = null, activePlanLabel = null, catalog = [], links = {}, analytics, missingRemote = [] }) { const { auth, errors, flash } = usePage().props useAcademyPageAnalytics(analytics) const loginHref = auth?.user ? null : `${links.login || '/login'}?intended=${encodeURIComponent(links.pricing || '/academy/pricing')}` const products = catalog.map((product) => ({ ...product, selectedPlan: product.plans[0] || null, })) const activePlanPrice = products .flatMap((p) => p.plans) .find((p) => p?.key === activePlanKey)?.price_display || null const handleCheckout = (plan) => { if (!plan?.key || !links.checkout) return trackUpgradeClick(analytics, { source: 'academy_billing_pricing', academy_plan: plan.key, academy_interval: plan.interval, }) const form = document.createElement('form') form.method = 'POST' form.action = links.checkout form.style.display = 'none' const csrfInput = document.createElement('input') csrfInput.type = 'hidden' csrfInput.name = '_token' csrfInput.value = getCsrfToken() const planInput = document.createElement('input') planInput.type = 'hidden' planInput.name = 'plan' planInput.value = plan.key form.appendChild(csrfInput) form.appendChild(planInput) document.body.appendChild(form) form.submit() } const hero = heroText(currentTier, isSubscribed) const showFreeBadgeAsCurrentPlan = currentTier === 'free' && !isSubscribed && auth?.user return (
{/* Hero */}

Skinbase Academy

{currentTier !== 'free' ? : null}

{hero.heading}

{hero.body}

{errors?.plan ?

{errors.plan}

: null} {flash?.error ?

{flash.error}

: null} {flash?.success ?

{flash.success}

: null} {Array.isArray(missingRemote) && missingRemote.length > 0 ? (

Purchases temporarily disabled:

The following plans could not be verified in Stripe: {missingRemote.join(', ')}

) : null}
{/* Plan grid */}
{/* Free / Explorer card */}

Free

Explorer

{showFreeBadgeAsCurrentPlan ? Your plan : }

Free

No payment needed

Everything you need to explore Academy, follow public lessons, and see a preview of what the paid tiers include.

{[ 'Public lessons and Academy listings', 'Prompt previews and public documentation', 'Community access and updates', 'Upgrade to Creator or Pro anytime', ].map((feature) => (
{feature}
))}
{products.map((product) => ( ))}
) }