"use client"; import Link from "next/link"; import { ArrowRight, BarChart3, Crown, Lock, ShieldCheck, Sparkles, X, Zap, } from "lucide-react"; import { useI18n } from "@/hooks/useI18n"; import { useDashboardStore } from "@/hooks/useDashboardStore"; import { useMemo, useState } from "react"; type ProFeaturePaywallProps = { feature: "today" | "history" | "future"; onClose?: () => void; }; export function ProFeaturePaywall({ feature, onClose, }: ProFeaturePaywallProps) { const { locale } = useI18n(); const { proAccess } = useDashboardStore(); const [usePoints, setUsePoints] = useState(true); const isEn = locale === "en-US"; // Redemption logic: 500 points = $1 discount // Max discount $3 (requires 1500 points) const PRO_PRICE = 5; const POINTS_VAL = 500; const MAX_DISCOUNT = 3; const pointsAvailable = proAccess.points || 0; const billing = useMemo(() => { const maxRedeemable = MAX_DISCOUNT * POINTS_VAL; const actualRedeem = Math.min(pointsAvailable, maxRedeemable); const discount = Math.floor(actualRedeem / POINTS_VAL); return { pointsUsed: discount * POINTS_VAL, discountAmount: discount, payAmount: PRO_PRICE - (usePoints ? discount : 0), }; }, [usePoints, pointsAvailable]); return (
{isEn ? "Unlock 15-day precision trends, real-time radar, and ad-free experience across all platforms." : "解锁 15 天高精度趋势分析、实时雷达与闪电追踪。尊享全平台无广告体验。"}
PRO PLAN