Download tasks/linkedin/solution/site/implementation/clone/components/Premium.tsx from TIGER-Lab/WebsiteBench: direct link, hf CLI and curl.
- Browser
- Download file 6.29 kB
-
https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/linkedin/solution/site/implementation/clone/components/Premium.tsx
- Command line
-
hf download hf://datasets/TIGER-Lab/WebsiteBench/tasks/linkedin/solution/site/implementation/clone/components/Premium.tsx
-
curl -L -o Premium.tsx https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/linkedin/solution/site/implementation/clone/components/Premium.tsx
6.29 kB
| "use client"; | |
| import { useEffect, useState } from "react"; | |
| import { Check, CreditCard, ExternalLink, ShieldCheck, Sparkles } from "lucide-react"; | |
| import { StripeCardForm } from "@/components/StripeCardForm"; | |
| type Subscription = { | |
| status: string; | |
| currentPeriodEnd: string | null; | |
| cancelAtPeriodEnd: boolean; | |
| } | null; | |
| export function PremiumView() { | |
| const [subscription, setSubscription] = useState<Subscription>(null); | |
| const [billingAvailable, setBillingAvailable] = useState(true); | |
| const [billingMode, setBillingMode] = useState("stripe-test"); | |
| const [loading, setLoading] = useState(true); | |
| const [action, setAction] = useState<"checkout" | "portal" | null>(null); | |
| const [error, setError] = useState(""); | |
| const [cardSetup, setCardSetup] = useState<{ setupIntentId: string } | null>(null); | |
| useEffect(() => { | |
| fetch("/api/billing/subscription") | |
| .then(async (response) => { | |
| if (response.status === 401) return; | |
| const result = await response.json() as { subscription?: Subscription; billingAvailable?: boolean; mode?: string; error?: string }; | |
| if (!response.ok) throw new Error(result.error ?? "Unable to load billing."); | |
| setSubscription(result.subscription ?? null); | |
| setBillingAvailable(result.billingAvailable !== false); | |
| setBillingMode(result.mode ?? "stripe-test"); | |
| }) | |
| .catch((caught: unknown) => setError(caught instanceof Error ? caught.message : "Unable to load billing.")) | |
| .finally(() => setLoading(false)); | |
| }, []); | |
| async function openBilling(endpoint: "checkout" | "portal") { | |
| setAction(endpoint); | |
| setError(""); | |
| try { | |
| const response = await fetch(`/api/billing/${endpoint}`, { | |
| method: "POST", | |
| headers: { "content-type": "application/json" }, | |
| body: "{}", | |
| }); | |
| const result = await response.json() as { url?: string; setupIntentId?: string; error?: string }; | |
| if (!response.ok) throw new Error(result.error ?? "Unable to open Stripe."); | |
| if (endpoint === "checkout") { | |
| if (!result.setupIntentId) throw new Error("Stripe did not prepare the test card simulation."); | |
| setCardSetup({ setupIntentId: result.setupIntentId }); | |
| setAction(null); | |
| } else { | |
| if (!result.url) throw new Error("Unable to open Stripe."); | |
| window.location.assign(result.url); | |
| } | |
| } catch (caught) { | |
| setError(caught instanceof Error ? caught.message : "Unable to open Stripe."); | |
| setAction(null); | |
| } | |
| } | |
| const active = subscription && ["active", "trialing"].includes(subscription.status); | |
| return ( | |
| <div className="premium-page"> | |
| <header className="premium-header"> | |
| <div> | |
| <span className="premium-kicker"><Sparkles size={17} /> LinkedIn Premium</span> | |
| <h1>More signal for your professional work</h1> | |
| <p>Advanced discovery and profile tools with secure Stripe Test Mode billing.</p> | |
| </div> | |
| <div className="premium-trust"><ShieldCheck size={21} /><span><b>Stripe Test Mode</b> Test values stay in your browser while Stripe binds its standard sandbox card to this account.</span></div> | |
| </header> | |
| <section className="premium-plan" aria-labelledby="premium-plan-title"> | |
| <div className="premium-plan-copy"> | |
| <span>Individual plan</span> | |
| <h2 id="premium-plan-title">Premium Career</h2> | |
| <p>One subscription for deeper job insights, stronger profile discovery, and focused learning.</p> | |
| <ul> | |
| <li><Check size={18} /> Applicant and company insights</li> | |
| <li><Check size={18} /> Advanced people and job search filters</li> | |
| <li><Check size={18} /> Full learning library access</li> | |
| <li><Check size={18} /> Profile discovery analytics</li> | |
| </ul> | |
| </div> | |
| <div className="premium-plan-action"> | |
| <div><strong>$29.99</strong><span>USD / month</span></div> | |
| {loading ? ( | |
| <button className="button button-primary button-full" disabled>Loading billing…</button> | |
| ) : !billingAvailable ? ( | |
| <button className="button button-outline button-full" disabled> | |
| <CreditCard size={18} /> Billing temporarily unavailable | |
| </button> | |
| ) : active ? ( | |
| <> | |
| <div className="subscription-status"><Check size={18} /> {subscription.status === "trialing" ? "Trial active" : "Subscription active"}</div> | |
| {billingMode === "stripe-test" ? ( | |
| <div className="subscription-status"><ShieldCheck size={18} /> Stripe sandbox payment verified</div> | |
| ) : ( | |
| <button className="button button-outline button-full" disabled={action === "portal"} onClick={() => openBilling("portal")}> | |
| <CreditCard size={18} /> {action === "portal" ? "Opening…" : "Manage subscription"} <ExternalLink size={15} /> | |
| </button> | |
| )} | |
| </> | |
| ) : cardSetup ? ( | |
| <StripeCardForm | |
| setupIntentId={cardSetup.setupIntentId} | |
| onCancel={() => setCardSetup(null)} | |
| onComplete={(nextSubscription) => { | |
| setSubscription(nextSubscription); | |
| setCardSetup(null); | |
| setAction(null); | |
| setError(""); | |
| }} | |
| /> | |
| ) : ( | |
| <button className="button button-primary button-full" disabled={action === "checkout"} onClick={() => openBilling("checkout")}> | |
| <CreditCard size={18} /> {action === "checkout" ? "Preparing secure card form…" : "Add a test card"} | |
| </button> | |
| )} | |
| {!active && billingAvailable && !loading && !cardSetup && <small>No card is attached to this account. Only name, card number, expiration date, and security code are collected.</small>} | |
| {subscription?.currentPeriodEnd && <small>Current period ends {new Date(subscription.currentPeriodEnd).toLocaleDateString("en-US")}.</small>} | |
| {subscription?.cancelAtPeriodEnd && <small>Your plan is set to cancel at the end of the current period.</small>} | |
| {error && <div className="form-error" role="alert">{error}</div>} | |
| </div> | |
| </section> | |
| </div> | |
| ); | |
| } | |