page.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { getSession } from '@/lib/auth'
  2. import Link from 'next/link'
  3. import { PlansComponent } from '@/components/Manage'
  4. import { getPlans, getSubscription } from '@/lib/data'
  5. import { redirect } from 'next/navigation'
  6. export const metadata = {
  7. title: 'Change plan'
  8. }
  9. export default async function Page() {
  10. const session = await getSession()
  11. const sub = await getSubscription(session?.user?.id)
  12. if (!sub) {
  13. redirect('/billing')
  14. }
  15. const plans = await getPlans()
  16. return (
  17. <section className="section">
  18. <div className="container">
  19. <h2 className="page-title text-center">Change plan</h2>
  20. <Link href="/billing/" className="mb-6">&larr; Back to billing</Link>
  21. {sub.status == 'on_trial' && (
  22. <div className="my-8 p-4 h-subheader">
  23. You are currently on a free trial. You will not be charged when changing plans during a trial.
  24. </div>
  25. )}
  26. <PlansComponent plans={plans} sub={sub} />
  27. <script src="https://app.lemonsqueezy.com/js/lemon.js" defer></script>
  28. </div>
  29. </section>
  30. )
  31. }