"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 (
{/* 关闭按钮 */} {onClose && ( )} {/* Crown Badge */}

{isEn ? "Unlock PolyWeather Pro" : "开启 PolyWeather Pro"}

{isEn ? "Unlock 15-day precision trends, real-time radar, and ad-free experience across all platforms." : "解锁 15 天高精度趋势分析、实时雷达与闪电追踪。尊享全平台无广告体验。"}

{/* 订阅方案卡片 */}
{isEn ? "Monthly" : "月付套餐"}

PRO PLAN

$5.00 / {isEn ? "mo" : "月"}
{/* 积分抵扣卡片 */}
= 500 ? "bg-indigo-600/20 border-indigo-500/50" : "bg-white/5 border-white/10"}`} >
= 500 ? "text-indigo-400" : "text-slate-500"}`} > {isEn ? "Points Credit" : "积分抵扣"}
= 500 ? "text-emerald-400" : "text-slate-500"}`} > -${billing.discountAmount.toFixed(2)} OFF

{pointsAvailable < 500 ? isEn ? `Need 500+ points (Current: ${pointsAvailable})` : `积分不足 (当前 ${pointsAvailable})` : usePoints ? isEn ? `Consumed ${billing.pointsUsed} points` : `已自动消耗 ${billing.pointsUsed} 积分` : isEn ? "Up to $3.00 off" : "开启后最多抵扣 $3.00"}

{isEn ? "Total Due:" : "应付总计:"} ${billing.payAmount.toFixed(2)}
{isEn ? "Connect Wallet & Pay" : "连接钱包并支付"}
{" "} {isEn ? "Secured Payment" : "安全加密支付"} {isEn ? "FAQ" : "常见问题 (FAQ)"}
); }