Spaces:
Running

sdex / src /components /TransactionDetailsView.tsx
vip
Upload Shengda frontend
25b8647
Raw History Blame Contribute Delete
22.7 kB
import React, { useState } from "react";
import { ScreenId, AppState, Transaction } from "../types";
import { ArrowLeft, Copy, Filter, Calendar, BarChart2, CheckCircle2 } from "lucide-react";
interface TransactionDetailsViewProps {
state: AppState;
onNavigate: (screen: ScreenId) => void;
}
export const TransactionDetailsView: React.FC<TransactionDetailsViewProps> = ({ state, onNavigate }) => {
// Mode can be: "LIST" (Screen 27), "DETAIL" (Screen 11), "FILTER" (Screen 20), "REVENUE" (Screen 18)
const [txMode, setTxMode] = useState<"LIST" | "DETAIL" | "FILTER" | "REVENUE">("LIST");
const [selectedTx, setSelectedTx] = useState<Transaction | null>(null);
// Filters inputs
const [startDate, setStartDate] = useState("2024-05-01");
const [endDate, setEndDate] = useState("2024-05-25");
const [filterType, setFilterType] = useState<"All" | "Deposit" | "Withdrawal">("All");
const handleTxSelect = (tx: Transaction) => {
setSelectedTx(tx);
setTxMode("DETAIL");
};
const handleCopyText = (txt: string) => {
navigator.clipboard.writeText(txt);
alert("已复制到剪贴板 Copy Success: " + txt);
};
// Get filtered items
const filteredTxs = state.transactions.filter(tx => {
if (filterType === "Deposit" && tx.amount < 0) return false;
if (filterType === "Withdrawal" && tx.amount > 0) return false;
return true;
});
const getStatusBadge = (status: Transaction["status"]) => {
switch (status) {
case "Success":
return <span className="text-[10px] text-emerald-400 bg-emerald-500/10 border border-emerald-500/20 px-2 py-0.5 rounded font-bold uppercase">SUCCESS 到账</span>;
case "Pending":
return <span className="text-[10px] text-amber-500 bg-amber-500/10 border border-amber-500/20 px-2 py-0.5 rounded font-bold uppercase animate-pulse">PENDING 处理</span>;
case "Failed":
return <span className="text-[10px] text-rose-500 bg-rose-500/10 border border-rose-500/20 px-2 py-0.5 rounded font-bold uppercase">FAILED 失败</span>;
}
};
return (
<div className="bg-[#000B14] text-[#d1e4ff] min-h-screen pb-24 font-sans select-none overflow-x-hidden">
{/* 1. TRANSACTION LIST OVERVIEW (Screen 27) */}
{txMode === "LIST" && (
<>
<header className="bg-[#0b2135] fixed top-0 w-full z-45 h-14 border-b border-[#414755] flex items-center px-4 justify-between">
<button
onClick={() => onNavigate(ScreenId.PROFILE)}
className="p-1 rounded-full text-[#afc6ff] hover:bg-[#22364c]"
>
<ArrowLeft className="w-6 h-6" />
</button>
<span className="text-white text-base font-bold">交易与充值概览</span>
<div className="flex gap-2">
<button
onClick={() => setTxMode("REVENUE")}
className="p-1 rounded-full text-[#FFD700] hover:bg-[#22364c]"
title="营收看板"
>
<BarChart2 className="w-5.5 h-5.5" />
</button>
<button
onClick={() => setTxMode("FILTER")}
className="p-1 rounded-full text-[#afc6ff] hover:bg-[#22364c]"
title="过滤"
>
<Filter className="w-5.5 h-5.5" />
</button>
</div>
</header>
<main className="max-w-md mx-auto px-4 mt-20 space-y-4">
{/* Monthly deposit summaries header card */}
<div className="bg-[#0b2135] border border-white/5 rounded-2xl p-5 shadow-lg relative overflow-hidden">
<span className="text-[10px] text-[#c1c6d7] block uppercase font-semibold">本月流水汇总概况 (This Month Summary)</span>
<div className="flex justify-between items-baseline mt-2">
<span className="text-2xl font-bold font-mono text-white">$4,250.00 <span className="text-xs text-[#afc6ff]">USD</span></span>
<span className="text-xs text-emerald-400 font-bold bg-emerald-500/10 border border-emerald-500/20 px-2 py-0.5 rounded">无风险风控</span>
</div>
<p className="text-[9px] text-[#c1c6d7] mt-2 leading-relaxed">
数据合并统计自网银、代收代付通道和USDT,单笔提现或充值如有疑问请保留对账单与客服申诉核销。
</p>
</div>
<h3 className="text-xs font-bold text-[#afc6ff] tracking-wider pt-2 flex justify-between items-center px-1">
<span>往来对账历史明细 ({filteredTxs.length})</span>
<span className="text-[10px] text-zinc-500">点击列表项可查看详情对账单</span>
</h3>
{/* List */}
<div className="space-y-3">
{filteredTxs.map((tx) => (
<div
key={tx.id}
onClick={() => handleTxSelect(tx)}
className="bg-[#0b2135] border border-white/5 rounded-xl p-4 flex justify-between items-center hover:bg-[#22364c]/20 cursor-pointer group transition-colors"
>
<div>
<span className="text-xs font-bold text-white block group-hover:text-amber-400 transition-colors">{tx.type}</span>
<span className="text-[10px] text-[#c1c6d7] font-mono mt-0.5 block opacity-80">{tx.date}</span>
</div>
<div className="text-right flex flex-col items-end gap-1">
<span className={`text-sm font-bold font-mono ${tx.amount > 0 ? "text-emerald-400" : "text-white"}`}>
{tx.amount > 0 ? "+" : ""}${tx.amount.toFixed(2)}
</span>
{getStatusBadge(tx.status)}
</div>
</div>
))}
</div>
<div className="pt-2">
<button
onClick={() => onNavigate(ScreenId.DEPOSIT)}
className="w-full bg-[#528dff] hover:bg-[#528dff]/90 text-[#00275f] font-bold py-3 rounded-xl text-xs uppercase"
>
前往充值中心 (Submit Deposit)
</button>
</div>
</main>
</>
)}
{/* 2. TRANSACTION DETAILED SINGLE LOG (Screen 11) */}
{txMode === "DETAIL" && selectedTx && (
<>
<header className="bg-[#0b2135] fixed top-0 w-full z-45 h-14 border-b border-[#414755] flex items-center px-4 justify-between">
<button
onClick={() => setTxMode("LIST")}
className="p-1 rounded-full text-[#afc6ff] hover:bg-[#22364c]"
>
<ArrowLeft className="w-6 h-6" />
</button>
<span className="text-white text-base font-bold">盛大出款对账单</span>
<div className="w-6"></div>
</header>
<main className="max-w-md mx-auto px-4 mt-20 text-center select-none">
{selectedTx.amount < 0 ? (
<div className="w-16 h-16 rounded-full bg-emerald-500/10 border border-emerald-500/30 flex items-center justify-center text-emerald-400 mx-auto mb-3 shadow-[0_0_15px_rgba(16,185,129,0.15)]">
<CheckCircle2 className="w-9 h-9 animate-pulse" />
</div>
) : (
<div className="w-16 h-16 rounded-full bg-[#528dff]/10 border border-[#528dff]/30 flex items-center justify-center text-[#528dff] mx-auto mb-3 shadow-[0_0_15px_rgba(82,141,255,0.15)]">
<CheckCircle2 className="w-9 h-9" />
</div>
)}
<h2 className="text-sm font-bold text-white uppercase tracking-wider">
{selectedTx.amount < 0 ? "提现汇出成功" : "充值录金到账成功"}
</h2>
<div className="text-2xl font-extrabold text-[#FFD700] mt-1 font-mono tracking-wide">
{selectedTx.amount > 0 ? "+" : ""}${selectedTx.amount.toFixed(2)}
<span className="text-xs text-white/50 font-normal ml-1">USD</span>
</div>
{/* Detail rows */}
<div className="bg-[#0b2135] border border-white/5 rounded-2xl p-5 text-left space-y-3 shadow-xl mt-6">
<div className="flex justify-between items-center text-xs pb-2 border-b border-white/5 font-mono">
<span className="text-[#c1c6d7]">交易类型 (Type):</span>
<span className="text-white font-bold">{selectedTx.type}</span>
</div>
<div className="flex justify-between items-center text-xs pb-2 border-b border-white/5 font-mono">
<span className="text-[#c1c6d7]">往来状态 (Status):</span>
<span className="text-emerald-400 font-bold uppercase rounded bg-emerald-500/10 px-1.5 py-0.2 border border-emerald-500/20">Success 已结算</span>
</div>
<div className="flex justify-between items-center text-xs pb-2 border-b border-white/5 font-mono">
<span className="text-[#c1c6d7]">交易时间 (Time):</span>
<span className="text-white font-medium">{selectedTx.date}</span>
</div>
<div className="flex justify-between items-center text-xs pb-2 border-b border-white/5 font-mono">
<span className="text-[#c1c6d7]">订单串码 ID (TxID):</span>
<button
type="button"
onClick={() => handleCopyText(selectedTx.id)}
className="flex items-center gap-1.5 text-[#afc6ff] hover:underline"
>
<span className="text-[10px] uppercase font-bold truncate max-w-[130px]">{selectedTx.id}</span>
<Copy className="w-3 h-3" />
</button>
</div>
<div className="flex justify-between items-center text-xs pb-2 border-b border-white/5 font-mono">
<span className="text-[#c1c6d7]">付款方式 (Payment):</span>
<span className="text-white font-bold">{selectedTx.paymentMethod}</span>
</div>
{selectedTx.remarks && (
<div className="text-[11px] font-mono text-zinc-500 leading-normal pt-1">
备注/remarks: {selectedTx.remarks}
</div>
)}
</div>
<div className="grid grid-cols-2 gap-3 mt-6">
<button
onClick={() => onNavigate(ScreenId.CUSTOMER_SUPPORT)}
className="py-3 bg-[#22364c] hover:bg-[#2d4661] text-xs font-bold text-[#afc6ff] rounded-xl border border-white/5 active:scale-95 transition-transform"
>
申诉或联系客服
</button>
<button
onClick={() => setTxMode("LIST")}
className="py-3 bg-[#528dff] hover:bg-[#528dff]/90 text-[#00275f] font-bold rounded-xl text-xs active:scale-95 transition-transform"
>
返回交易概览 (View List)
</button>
</div>
</main>
</>
)}
{/* 3. TRANSACTION FILTER SCREEN CARD (Screen 20) */}
{txMode === "FILTER" && (
<>
<header className="bg-[#0b2135] fixed top-0 w-full z-45 h-14 border-b border-[#414755] flex items-center px-4 justify-between">
<button
onClick={() => setTxMode("LIST")}
className="p-1 rounded-full text-[#afc6ff] hover:bg-[#22364c]"
>
<ArrowLeft className="w-6 h-6" />
</button>
<span className="text-white text-base font-bold">交易历史过滤</span>
<div className="w-6"></div>
</header>
<main className="max-w-md mx-auto px-4 mt-20 space-y-6">
<div className="bg-[#0b2135] border border-white/5 p-5 rounded-2xl space-y-4">
<h3 className="text-xs font-bold text-[#afc6ff] flex items-center gap-1">
<Calendar className="w-4 h-4 text-amber-500" /> 选择对账单结算周期明细
</h3>
<div className="grid grid-cols-2 gap-3 text-xs select-none">
<div>
<span className="text-[10px] text-[#c1c6d7] block mb-1">开始日期 (Start Date)</span>
<input
type="date"
value={startDate}
onChange={(e) => setStartDate(e.target.value)}
className="w-full bg-[#001428] border border-[#414755]/50 rounded-xl py-2 px-3 text-white focus:outline-none focus:border-[#528dff]"
/>
</div>
<div>
<span className="text-[10px] text-[#c1c6d7] block mb-1">截止日期 (End Date)</span>
<input
type="date"
value={endDate}
onChange={(e) => setEndDate(e.target.value)}
className="w-full bg-[#001428] border border-[#414755]/50 rounded-xl py-2 px-3 text-white focus:outline-none focus:border-[#528dff]"
/>
</div>
</div>
</div>
{/* Selector tags */}
<div className="bg-[#0b2135] border border-white/5 p-5 rounded-2xl space-y-3">
<h3 className="text-xs font-bold text-[#afc6ff]">选择交易流向类型</h3>
<div className="grid grid-cols-3 gap-2.5 text-xs">
{["All", "Deposit", "Withdrawal"].map((type) => (
<button
key={type}
onClick={() => setFilterType(type as any)}
className={`py-2 rounded-xl border font-semibold transition-all ${
filterType === type
? "bg-amber-400 text-slate-950 border-transparent font-bold"
: "bg-[#001428] border-[#414755]/40 text-[#c1c6d7]"
}`}
>
{type === "All" ? "全部" : (type === "Deposit" ? "仅充值入本" : "仅提现出金")}
</button>
))}
</div>
</div>
<button
onClick={() => setTxMode("LIST")}
className="w-full py-4 bg-[#528dff] hover:bg-[#528dff]/90 text-[#00275f] font-bold text-xs uppercase tracking-wider rounded-2xl active:scale-95 transition-transform"
>
应用筛选过滤规则 (Apply Filters)
</button>
</main>
</>
)}
{/* 4. REVENUE DASHBOARD CANVASES SCREEN (Screen 18) */}
{txMode === "REVENUE" && (
<>
<header className="bg-[#0b2135] fixed top-0 w-full z-45 h-14 border-b border-[#414755] flex items-center px-4 justify-between">
<button
onClick={() => setTxMode("LIST")}
className="p-1 rounded-full text-[#afc6ff] hover:bg-[#22364c]"
>
<ArrowLeft className="w-6 h-6" />
</button>
<span className="text-white text-base font-bold">盛大财富营收看板</span>
<div className="w-6"></div>
</header>
<main className="max-w-md mx-auto px-4 mt-20 space-y-5">
{/* Logo and aggregate panel */}
<div className="bg-gradient-to-br from-[#0b2135] to-[#071d31] border border-white/5 rounded-2xl p-5 shadow-xl relative overflow-hidden">
<div className="flex justify-between items-center">
<div>
<span className="text-[10px] text-[#c1c6d7] block uppercase font-bold text-slate-400">总累计会员金库池 (Income Reservoir)</span>
<span className="text-2xl font-bold font-mono text-white mt-1 block">USDT {state.balance.toFixed(2)}</span>
</div>
<div className="text-right">
<span className="text-[9px] text-[#FFD700] bg-amber-400/10 border border-amber-500/25 px-2 py-0.5 rounded-full font-bold">周增长 +15.4%</span>
</div>
</div>
<p className="text-[9px] text-[#c1c6d7] mt-3 border-t border-white/5 pt-2 leading-relaxed">
实时出入数据采用区块链安全加密机制同步上报,自动过滤不法套利。
</p>
</div>
{/* Income Trend: Interactive line graph using vector SVG */}
<div className="bg-[#0b2135] border border-white/5 rounded-2xl p-4">
<h4 className="text-xs font-bold text-white mb-3">走势折线图 (Earnings Trend Week-to-Date)</h4>
<div className="aspect-[2/1] w-full relative">
{/* SVG line */}
<svg className="w-full h-full overflow-visible" viewBox="0 0 100 40">
{/* Grid lines and background */}
<line x1="0" y1="35" x2="100" y2="35" stroke="rgba(255,255,255,0.05)" strokeWidth="0.5" />
<line x1="0" y1="20" x2="100" y2="20" stroke="rgba(255,255,255,0.05)" strokeWidth="0.5" />
<line x1="0" y1="5" x2="100" y2="5" stroke="rgba(255,255,255,0.05)" strokeWidth="0.5" />
{/* Gradient Area under curve */}
<defs>
<linearGradient id="areaGrad" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" stopColor="#528dff" stopOpacity="0.25" />
<stop offset="100%" stopColor="#528dff" stopOpacity="0" />
</linearGradient>
</defs>
{/* Closed Path for Gradient */}
<path d="M 0 32 L 20 28 L 40 12 L 60 25 L 80 8 L 100 2 Z" fill="none" stroke="#528dff" strokeWidth="1.5" />
<path d="M 0 32 L 20 28 L 40 12 L 60 25 L 80 8 L 100 2 L 100 35 L 0 35 Z" fill="url(#areaGrad)" />
{/* Nodes */}
<circle cx="20" cy="28" r="1.5" fill="white" stroke="#528dff" strokeWidth="0.5" />
<circle cx="40" cy="12" r="1.5" fill="white" stroke="#528dff" strokeWidth="0.5" />
<circle cx="60" cy="25" r="1.5" fill="white" stroke="#528dff" strokeWidth="0.5" />
<circle cx="80" cy="8" r="1.5" fill="white" stroke="#528dff" strokeWidth="0.5" />
<circle cx="100" cy="2" r="1.5" fill="#FFD700" stroke="#528dff" strokeWidth="0.5" />
</svg>
{/* Legend */}
<div className="flex justify-between items-center text-[8px] text-[#c1c6d7] font-mono mt-1 font-semibold uppercase">
<span>周一</span>
<span>周三</span>
<span>周五</span>
<span>今天(高峰)</span>
</div>
</div>
</div>
{/* Distribution donut chart using Vector SVGs */}
<div className="bg-[#0b2135] border border-white/5 rounded-2xl p-4 flex gap-4 items-center">
<div className="w-16 h-16 shrink-0 relative">
{/* SVG circular progress */}
<svg className="w-full h-full -rotate-90" viewBox="0 0 36 36">
{/* Under circle */}
<path d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831" fill="none" stroke="rgba(255,255,255,0.05)" strokeWidth="3" />
{/* Slots 65% */}
<path d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831" fill="none" stroke="#FFD700" strokeWidth="3" strokeDasharray="65, 100" />
{/* Sports 25% */}
<path d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831" fill="none" stroke="#528dff" strokeWidth="3" strokeDasharray="25, 100" strokeDashoffset="-65" />
</svg>
<div className="absolute inset-0 flex items-center justify-center text-[10px] font-bold text-white font-mono">
85%
</div>
</div>
<div className="space-y-1.5 flex-1">
<span className="text-[10px] text-white font-bold block">金出款盈利分布 (Earnings Distribution)</span>
<div className="grid grid-cols-2 gap-2 text-[9px] text-[#c1c6d7]">
<div className="flex items-center gap-1.5">
<span className="w-2 h-2 rounded bg-amber-400"></span>
<span>财神到电子 (65%)</span>
</div>
<div className="flex items-center gap-1.5">
<span className="w-2 h-2 rounded bg-[#528dff]"></span>
<span>顶级视讯 (25%)</span>
</div>
<div className="flex items-center gap-1.5">
<span className="w-2 h-2 rounded bg-zinc-600"></span>
<span>其他小额 (10%)</span>
</div>
</div>
</div>
</div>
{/* Top earning sources list */}
<div className="bg-[#0b2135] border border-white/5 rounded-2xl p-4 space-y-3">
<h4 className="text-xs font-bold text-[#afc6ff]">主要核心创收通道来源</h4>
<div className="space-y-2 text-xs">
<div className="flex justify-between items-center py-1.5 border-b border-white/5">
<span className="text-white">Mega Jackpot Slots (财神到电子彩池)</span>
<span className="text-emerald-400 font-bold">+$48,250 涌入</span>
</div>
<div className="flex justify-between items-center py-1.5 border-b border-white/5">
<span className="text-white">VIP Blackjack Table 12 (精品黑杰克现场)</span>
<span className="text-emerald-400 font-bold">+$12,500</span>
</div>
<div className="flex justify-between items-center py-1.5">
<span className="text-white">Premier League Bets IM (英超滚球极速盈)</span>
<span className="text-emerald-400 font-bold">+$8,900</span>
</div>
</div>
</div>
<button
onClick={() => setTxMode("LIST")}
className="w-full py-3 bg-[#528dff] hover:bg-[#528dff]/90 text-[#00275f] font-bold text-xs uppercase cursor-pointer rounded-xl"
>
返回交易概览列表 (Back to Logs)
</button>
</main>
</>
)}
</div>
);
};