pricing-section.tsx151 lines, 4.4 KB
| 1 | import { api } from "@/lib/api"; |
| 2 | import stripePromise from "@/lib/stripe"; |
| 3 | import { |
| 4 | Card, |
| 5 | CardContent, |
| 6 | CardDescription, |
| 7 | CardFooter, |
| 8 | CardHeader, |
| 9 | CardTitle, |
| 10 | } from "./ui/card"; |
| 11 | import { Button } from "./ui/button"; |
| 12 | |
| 13 | export function PricingSection() { |
| 14 | const handleUpgrade = async () => { |
| 15 | try { |
| 16 | const response = await api.get("/payments/create-checkout-session"); |
| 17 | const stripe = await stripePromise; |
| 18 | await stripe?.redirectToCheckout({ |
| 19 | sessionId: response.data.sessionId, |
| 20 | }); |
| 21 | } catch (error) { |
| 22 | console.error(error); |
| 23 | } |
| 24 | }; |
| 25 | |
| 26 | return ( |
| 27 | <div className="container mx-auto px-4 py-16 bg-gradient-to-b from-background to-background/80"> |
| 28 | <h2 className="text-4xl font-extrabold tracking-tight sm:text-5xl text-center"> |
| 29 | Choose the plan that's right for you |
| 30 | </h2> |
| 31 | <p className="text-lg text-muted-foreground mt-4 text-center max-w-3xl mx-auto"> |
| 32 | Select the perfect plan for your needs. Upgrade anytime to unlock |
| 33 | premium features and support. |
| 34 | </p> |
| 35 | <div className="grid md:grid-cols-2 gap-8 max-w-5xl mx-auto"> |
| 36 | <PricingCard |
| 37 | title="Basic" |
| 38 | description="For comprehensive contract analysis" |
| 39 | price="Free" |
| 40 | period="/lifetime" |
| 41 | features={[ |
| 42 | "Advanced contract analysis", |
| 43 | "Unlimited projects", |
| 44 | "Chat with your contract", |
| 45 | "10+ risks with severity levels", |
| 46 | "10+ opportunities with impact levels", |
| 47 | "Comprehensive contract summary", |
| 48 | "Improvement recommendations", |
| 49 | "Key clauses identification", |
| 50 | "Legal compliance assessment", |
| 51 | "Negotiation points", |
| 52 | "Contract duration analysis", |
| 53 | "Termination conditions summary", |
| 54 | "Compensation structure breakdown", |
| 55 | "Performance metrics identification", |
| 56 | "Intellectual property clause summary", |
| 57 | ]} |
| 58 | buttonText="Upgrade" |
| 59 | onButtonClick={handleUpgrade} |
| 60 | /> |
| 61 | <PricingCard |
| 62 | title="Premium" |
| 63 | description="For comprehensive contract analysis" |
| 64 | price="$100" |
| 65 | highlight |
| 66 | period="/lifetime" |
| 67 | features={[ |
| 68 | "Advanced contract analysis", |
| 69 | "Unlimited projects", |
| 70 | "Chat with your contract", |
| 71 | "10+ risks with severity levels", |
| 72 | "10+ opportunities with impact levels", |
| 73 | "Comprehensive contract summary", |
| 74 | "Improvement recommendations", |
| 75 | "Key clauses identification", |
| 76 | "Legal compliance assessment", |
| 77 | "Negotiation points", |
| 78 | "Contract duration analysis", |
| 79 | "Termination conditions summary", |
| 80 | "Compensation structure breakdown", |
| 81 | "Performance metrics identification", |
| 82 | "Intellectual property clause summary", |
| 83 | ]} |
| 84 | buttonText="Upgrade" |
| 85 | onButtonClick={handleUpgrade} |
| 86 | /> |
| 87 | </div> |
| 88 | </div> |
| 89 | ); |
| 90 | } |
| 91 | |
| 92 | interface PricingCardProps { |
| 93 | title: string; |
| 94 | description: string; |
| 95 | price: string; |
| 96 | period: string; |
| 97 | features: string[]; |
| 98 | buttonText: string; |
| 99 | highlight?: boolean; |
| 100 | onButtonClick: () => void; |
| 101 | } |
| 102 | |
| 103 | function PricingCard({ |
| 104 | title, |
| 105 | description, |
| 106 | price, |
| 107 | features, |
| 108 | period, |
| 109 | buttonText, |
| 110 | highlight, |
| 111 | onButtonClick, |
| 112 | }: PricingCardProps) { |
| 113 | return ( |
| 114 | <Card |
| 115 | className={`flex flex-col ${ |
| 116 | highlight ? "border-primary shadow-lg" : "" |
| 117 | } relative overflow-hidden transition-all duration-300`} |
| 118 | > |
| 119 | <CardHeader> |
| 120 | <CardTitle className="text-2xl flex items-center gap-2"> |
| 121 | {title} |
| 122 | </CardTitle> |
| 123 | <CardDescription>{description}</CardDescription> |
| 124 | </CardHeader> |
| 125 | <CardContent className="flex-grow"> |
| 126 | <p className="text-5xl font-extrabold mb-6"> |
| 127 | {price} |
| 128 | <span className="text-base font-normal text-muted-foreground"> |
| 129 | {period} |
| 130 | </span> |
| 131 | </p> |
| 132 | <ul className="space-y-2"> |
| 133 | {features.map((feature, index) => ( |
| 134 | <li className="flex items-center gap-2" key={index}> |
| 135 | {feature} |
| 136 | </li> |
| 137 | ))} |
| 138 | </ul> |
| 139 | </CardContent> |
| 140 | <CardFooter> |
| 141 | <Button |
| 142 | className="w-full" |
| 143 | variant={highlight ? "default" : "outline"} |
| 144 | onClick={onButtonClick} |
| 145 | > |
| 146 | {buttonText} |
| 147 | </Button> |
| 148 | </CardFooter> |
| 149 | </Card> |
| 150 | ); |
| 151 | } |