page.tsx47 lines, 1.5 KB
| 1 | "use client"; |
| 2 | |
| 3 | import React from "react"; |
| 4 | import { |
| 5 | useSubscriptionPlans, |
| 6 | useUserSubscription, |
| 7 | } from "@/lib/hooks/queries/subscriptions"; |
| 8 | import { Loader2 } from "lucide-react"; |
| 9 | import PricingSection from "@/components/pricing-section"; |
| 10 | |
| 11 | export default function SubscriptionPage() { |
| 12 | const { data: plans, isLoading: isLoadingPlans } = useSubscriptionPlans(); |
| 13 | const { data: userSubscription, isLoading: isLoadingSubscription } = |
| 14 | useUserSubscription(); |
| 15 | |
| 16 | const isLoading = isLoadingPlans || isLoadingSubscription; |
| 17 | |
| 18 | // Check if user has an active subscription |
| 19 | const hasActiveSubscription = |
| 20 | userSubscription?.isSubscribed && |
| 21 | userSubscription.subscription?.status === "active"; |
| 22 | |
| 23 | // Get the current plan if user is subscribed |
| 24 | const currentPlanId = hasActiveSubscription |
| 25 | ? userSubscription.subscription?.plan?.id |
| 26 | : undefined; |
| 27 | |
| 28 | return ( |
| 29 | <div className="container mx-auto px-4 py-8 max-w-6xl"> |
| 30 | <div className="text-center mb-12"> |
| 31 | <h1 className="text-4xl font-extrabold mb-4">Choose Your Plan</h1> |
| 32 | <p className="text-lg text-muted-foreground max-w-2xl mx-auto"> |
| 33 | Select the perfect plan for your video processing needs, with options |
| 34 | for every budget and requirement. |
| 35 | </p> |
| 36 | </div> |
| 37 | |
| 38 | {isLoading ? ( |
| 39 | <div className="flex justify-center items-center h-64"> |
| 40 | <Loader2 className="h-8 w-8 animate-spin text-primary" /> |
| 41 | </div> |
| 42 | ) : ( |
| 43 | <PricingSection plans={plans || []} currentPlanId={currentPlanId} /> |
| 44 | )} |
| 45 | </div> |
| 46 | ); |
| 47 | } |