"use client"; import Image from "next/image"; import { CheckCircle, XCircle, ExternalLink } from "lucide-react"; import { Button } from "@heroui/react"; import { useApp } from "@/contexts/AppContext"; import { ProductDetail } from "@/lib/api/fundmarket"; interface AssetCustodyVerificationProps { product: ProductDetail; } interface VerificationCardProps { icon: string; title: string; description: string; buttonText: string; reportUrl?: string; } function VerificationCard({ icon, title, description, buttonText, reportUrl }: VerificationCardProps) { return ( ); } function getInitials(name: string) { return name.split(/\s+/).map(w => w[0]).slice(0, 2).join("").toUpperCase(); } function formatUSD(v: number) { return "$" + v.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 }); } function formatMaturityDate(dateStr: string) { if (!dateStr) return "--"; const d = new Date(dateStr); return d.toLocaleDateString("en-GB", { day: "2-digit", month: "short", year: "numeric" }); } export default function AssetCustodyVerification({ product }: AssetCustodyVerificationProps) { const { t } = useApp(); const custody = product.custody; const extra = custody?.additionalInfo ?? {}; const assetType: string = extra.asset_type ?? "--"; const maturityDate: string = extra.maturity_date ? formatMaturityDate(extra.maturity_date as string) : "--"; const daysRemaining: number | null = typeof extra.days_remaining === "number" ? extra.days_remaining : null; const custodyValueUSD: number = typeof extra.custody_value_usd === "number" ? extra.custody_value_usd : 0; const verificationStatus: string = typeof extra.verification_status === "string" ? extra.verification_status : "Unverified"; const isVerified = verificationStatus.toLowerCase() === "verified"; const auditReportUrl = custody?.auditReportUrl || ""; // 动态获取 verification 区域的链接,按 displayOrder 排序 const verificationLinks = (product.productLinks ?? []) .filter((l) => l.displayArea === 'verification' || l.displayArea === 'both') .sort((a, b) => a.displayOrder - b.displayOrder); // 循环使用的图标列表 const ICONS = [ "/components/product/component-117.svg", "/components/product/component-119.svg", "/components/product/component-121.svg", ]; // Get attestation reports for Independent Verifications const attestationReports = (product.auditReports ?? []).filter( (r) => r.reportType === "attestation" ); return (
{/* Header */}

{t("custody.title")}

{t("custody.description")}

{/* Holdings Table Card */}
{/* Table Header */}

{t("custody.underlyingHoldings")}

{t("custody.verifiedBy")} {custody?.auditorName ?? "--"}

{custody?.lastAuditDate && (
{t("custody.lastUpdated")}: {custody.lastAuditDate}
)}
{/* ── 移动端:卡片化布局 ── */}
{/* Custodian 卡片 */}
{custody?.custodianName ? getInitials(custody.custodianName) : "--"}
{custody?.custodianName ?? "--"} {custody?.custodyType ?? "--"}
{/* 信息网格:2列 */}
{/* Asset Type */}
{t("custody.assetType")} {assetType}
{/* Maturity */}
{t("custody.maturity")} {maturityDate} {daysRemaining !== null && ( daysRemaining < 0 ? {t("custody.expired")} : ({daysRemaining} {t("custody.days")}) )}
{/* Value USD */}
{t("custody.valueUSD")} {custodyValueUSD > 0 ? formatUSD(custodyValueUSD) : "--"}
{/* Status */}
{t("custody.status")}
{isVerified ? : } {verificationStatus}
{auditReportUrl && ( )} {/* Total Value */}
{t("custody.totalValue")} {custodyValueUSD > 0 ? formatUSD(custodyValueUSD) : "--"}
{/* ── 桌面端:表格布局 ── */}
{/* Table Header Row */}
{t("custody.custodian")}
{t("custody.assetType")}
{t("custody.maturity")}
{t("custody.valueUSD")}
{t("custody.status")}
{t("custody.viewReports")}
{/* Table Body Row */}
{custody?.custodianName ? getInitials(custody.custodianName) : "--"}
{custody?.custodianName ?? "--"} {custody?.custodyType ?? "--"}
{assetType}
{maturityDate} {daysRemaining !== null && ( daysRemaining < 0 ? {t("custody.expired")} : ({daysRemaining} {t("custody.days")}) )}
{custodyValueUSD > 0 ? formatUSD(custodyValueUSD) : "--"}
{isVerified ? : } {verificationStatus}
{auditReportUrl && ( )}
{/* Table Footer Row */}
{t("custody.totalValue")}
{custodyValueUSD > 0 ? formatUSD(custodyValueUSD) : "--"}
{/* Verification Cards Row */}
{/* 验证卡片:移动端1列,桌面端3列 */} {verificationLinks.length > 0 && (
{verificationLinks.map((link, idx) => ( ))}
)} {/* Independent Verifications:移动端全宽,桌面端固定宽度 */}

{t("custody.independentVerifications")}

{t("custody.independentDesc")}

{attestationReports.length > 0 ? ( attestationReports.map((report, idx) => ( )) ) : (

{t("custody.noReports")}

)}
); }