"use client"; import { Loading } from "@/components/dashboard/loading"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTrigger, } from "@/components/ui/dialog"; import { toast } from "@/components/ui/toaster"; // import { trpc } from "@/lib/trpc/client"; // import { PostHogEvent } from "@/providers/PostHogProvider"; // import { type Workspace } from "@aigxion/db"; import { usePathname, useRouter, useSearchParams } from "next/navigation"; import React, { useEffect, useState } from "react"; // import { getTenantId } from "@/lib/auth"; // import { db } from "@/lib/db"; import { ArrowLeft } from "lucide-react"; import Link from "next/link"; import { ChangePlanButton } from "./button"; import { PayInfo, PaymentInfo, PaymentOrder, payStaff, queryPayStatus, queryProductionList } from "@/lib/http/staff"; import { FadeIn } from "@/components/landing/fade-in"; import { cn } from "@/lib/utils"; import { Modal, QRCode, message } from "antd"; import Image from "next/image"; import { useTranslation } from "react-i18next"; type Props = { newPlan: "free" | "pro"; // workspace: Workspace; tier: string; }; interface ProductInfo { [key: string]: { id: number; name: string; href: string; price: number; description: string; buttonText: string; features: string[]; footnotes: never[]; }; } const tiers: ProductInfo = { free: { id: 1, name: "月度计划", href: "/manage", price: 299, description: "启动下一个 API 所需的一切!", buttonText: "基础", features: [ "100 个每月活动密钥", "每月 2500 次成功验证", "无限的API", "7天免费保留", ], footnotes: [], }, pro: { id: 2, name: "季度计划", href: "/manage", price: 699, description: "对于那些有团队和更苛刻需求的人", buttonText: "Pro", features: [ "250 每月 xxxxxxxx*", "150,000 成功 xxxxxxx 包括 **", "xxxxxxxx APIs", "与团队成员的工作空间", "90 天分析保留", "90 天审核日志保留", ], footnotes: [ // " * Additional active keys are billed at $0.10", // " ** Additional verifications are billed at $10 per 100,000", ], }, custom: { id: 3, name: "年度计划", href: "/manage", price: 1299, description: "我们为有批量需求的人提供定制定价", buttonText: "Go", features: [ "自定义验证限制", "自定义活动键限制", "自定义分析保留", "专用支持合同", "每个API的白名单IP", ], footnotes: [], }, }; export const PlanCard: React.FC = ({ tier = "free", newPlan = "free" }) => { const router = useRouter(); const [open, setOpen] = useState(false); const [isLoading, setIsLoading] = useState(false); const [payQrcode, setPayQrcode] = useState(""); const path = usePathname() const { t, i18n } = useTranslation() const searchParams = useSearchParams() const staffId = searchParams.get('staffId') console.log("---PlanCard----", staffId, path) const isChatPage = path.includes('chat') useEffect(() => { // console.log("------------email", infoRef.current, userData.auth_token) async function initFunc() { const data = await queryProductionList() console.log(data) } initFunc() }, []); // const changePlan = trpc.workspace.changePlan.useMutation({ // onSuccess: (data, variables, _context) => { // toast.success(data.title, { // description: data.message, // }); // PostHogEvent({ // name: "plan_changed", // properties: { plan: variables.plan, workspace: variables.workspaceId }, // }); // setOpen(false); // router.refresh(); // }, // onError: (error) => { // toast.error(error.message); // }, // }); async function pollOrder(orderId: string, interval: number, maxAttempts: number): Promise { let attempts = 0; console.log("开始轮训订单", orderId) const poll = async (): Promise => { try { // 发送订单查询请求,假设返回的数据结构为 Order const result = await queryPayStatus(orderId); const order = result.data as PaymentOrder; // 如果订单状态为已完成,或者达到最大尝试次数,则停止轮询并返回订单 if (order.state >= 2 || attempts >= maxAttempts) { return order; } // 增加尝试次数 attempts++; // 等待一段时间后继续轮询 await new Promise(resolve => setTimeout(resolve, interval)); // 递归调用自身,继续轮询 return poll(); } catch (error) { // 处理轮询过程中的错误 console.error("Error occurred while polling order:", error); return null; } }; return poll(); } const isSamePlan = true; return (

{tiers[tier].name}

{tiers[tier].description}

{typeof tiers[tier].price === "number" ? ( <> {`${tiers[tier].price}`} {"/month"} ) : ( {tiers[tier].price} )}

    {tiers[tier].features.map((feature) => (
  • {feature}
  • ))}
{tiers[tier].footnotes && (
    {tiers[tier].footnotes.map((footnote, i) => (
  • {footnote}
  • ))}
)} {/* {tier === "custom" ? ( ) : ( )} */} {/* */} { staffId && }
{ if (setOpen) { setOpen(false) } }} onCancel={() => { setOpen(false) }} footer="" // width={"50%"} className={cn('min-w-[95%] lg:min-w-[700px] p-[20px]', "")} >

请使用支付宝进行支付

{/*
*/} {payQrcode &&
{/*
Hero Image
*/} {/*
Hero Image
*/}
}
); };