Some checks failed
lotteryadmin CI / build (push) Has been cancelled
- 各角色仪表盘:KPI 可点击跳转、快捷入口、去重冗余区块,代理/站点降级 analytics - 代理线路:创建玩家权限、侧栏搜索、深链 URL、档案保存与删除预检等修复 - 统一密码最短 6 位;代理模块表格/侧栏背景色一致(admin-table-inset) - 报表、钱包、对账、开奖、结算、配置等模块结构与 i18n 同步更新
123 lines
3.8 KiB
TypeScript
123 lines
3.8 KiB
TypeScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
import { ExternalLink, RotateCcw, Wrench } from "lucide-react";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import { AdminRowActionsMenu } from "@/components/admin/admin-row-actions-menu";
|
|
import { buttonVariants } from "@/components/ui/button";
|
|
import {
|
|
canCompleteTransferInCredit,
|
|
canManuallyProcessTransferOrder,
|
|
canReverseTransferOrder,
|
|
transferOrderHasReconcileAction,
|
|
} from "@/lib/wallet-transfer-actions";
|
|
import { cn } from "@/lib/utils";
|
|
import type { AdminReconcileItemRow } from "@/types/api/admin-reconcile";
|
|
|
|
type ReconcileItemActionsProps = {
|
|
row: AdminReconcileItemRow;
|
|
canWriteWallet: boolean;
|
|
busy: boolean;
|
|
compact?: boolean;
|
|
onCompleteCredit: (transferNo: string) => void;
|
|
onReverse: (transferNo: string) => void;
|
|
onManualProcess: (transferNo: string) => void;
|
|
};
|
|
|
|
export function ReconcileItemActions({
|
|
row,
|
|
canWriteWallet,
|
|
busy,
|
|
compact = false,
|
|
onCompleteCredit,
|
|
onReverse,
|
|
onManualProcess,
|
|
}: ReconcileItemActionsProps): React.ReactElement {
|
|
const { t } = useTranslation(["reconcile", "wallet"]);
|
|
|
|
const transferNo = row.side_a_ref ?? "";
|
|
const actionRow = {
|
|
direction: row.transfer_direction ?? undefined,
|
|
status: row.current_transfer_status ?? row.status,
|
|
fail_reason: row.transfer_fail_reason,
|
|
external_ref_no: row.external_ref_no,
|
|
can_reverse: row.can_reverse,
|
|
can_complete_credit: row.can_complete_credit,
|
|
can_manually_process: row.can_manually_process,
|
|
};
|
|
|
|
const hasWalletAction = transferNo !== "" && transferOrderHasReconcileAction(actionRow, canWriteWallet);
|
|
|
|
const menuActions = [
|
|
{
|
|
key: "complete",
|
|
label: t("completeCredit", { ns: "wallet" }),
|
|
hidden: !canCompleteTransferInCredit(actionRow, canWriteWallet),
|
|
onClick: () => onCompleteCredit(transferNo),
|
|
},
|
|
{
|
|
key: "manual",
|
|
label: t("markCaseClosed", { ns: "wallet" }),
|
|
icon: Wrench,
|
|
hidden: !canManuallyProcessTransferOrder(actionRow, canWriteWallet),
|
|
onClick: () => onManualProcess(transferNo),
|
|
},
|
|
{
|
|
key: "reverse",
|
|
label: t("reverse", { ns: "wallet" }),
|
|
icon: RotateCcw,
|
|
destructive: true,
|
|
hidden: !canReverseTransferOrder(actionRow, canWriteWallet),
|
|
onClick: () => onReverse(transferNo),
|
|
},
|
|
{
|
|
key: "transfer",
|
|
label: t("openTransferOrder"),
|
|
icon: ExternalLink,
|
|
hidden: transferNo === "",
|
|
onClick: () => {
|
|
window.location.href = `/admin/wallet/transfer-orders?transfer_no=${encodeURIComponent(transferNo)}`;
|
|
},
|
|
},
|
|
{
|
|
key: "txn",
|
|
label: t("openWalletTxn"),
|
|
icon: ExternalLink,
|
|
hidden: !row.side_b_ref,
|
|
onClick: () => {
|
|
window.location.href = `/admin/wallet/transactions?txn_no=${encodeURIComponent(row.side_b_ref ?? "")}`;
|
|
},
|
|
},
|
|
];
|
|
|
|
if (compact) {
|
|
if (!hasWalletAction && !transferNo && !row.side_b_ref) {
|
|
return <span>—</span>;
|
|
}
|
|
return <AdminRowActionsMenu busy={busy} actions={menuActions} />;
|
|
}
|
|
|
|
return (
|
|
<div className="flex flex-wrap gap-2">
|
|
{hasWalletAction ? <AdminRowActionsMenu busy={busy} actions={menuActions.filter((a) => a.key !== "transfer" && a.key !== "txn")} /> : null}
|
|
{transferNo !== "" ? (
|
|
<Link
|
|
href={`/admin/wallet/transfer-orders?transfer_no=${encodeURIComponent(transferNo)}`}
|
|
className={cn(buttonVariants({ variant: "outline", size: "sm" }), "h-8")}
|
|
>
|
|
{t("openTransferOrder")}
|
|
</Link>
|
|
) : null}
|
|
{row.side_b_ref ? (
|
|
<Link
|
|
href={`/admin/wallet/transactions?txn_no=${encodeURIComponent(row.side_b_ref)}`}
|
|
className={cn(buttonVariants({ variant: "outline", size: "sm" }), "h-8")}
|
|
>
|
|
{t("openWalletTxn")}
|
|
</Link>
|
|
) : null}
|
|
{!transferNo && !row.side_b_ref ? <span>—</span> : null}
|
|
</div>
|
|
);
|
|
} |