hyapp-admin-platform/ops-center/src/components/LuckyGiftPoolActions.jsx

49 lines
1.8 KiB
JavaScript

import { Button } from "@/shared/ui/Button.jsx";
export function LuckyGiftPoolActions({ canCredit, canDebit, disabled, onCredit, onDebit, pool }) {
if (!canCredit && !canDebit) {
return null;
}
const appCode = pool?.app_code || "-";
const poolID = pool?.pool_id || "-";
const strategyVersion = pool?.strategy_version || "fixed_v2";
const identity = `${appCode} / ${poolID} / ${strategyVersion}`;
const missingPool = !pool || pool.balance === undefined || pool.available_balance === undefined;
const availableBalance = Number(pool?.available_balance || 0);
return (
<div className="ops-pool-actions">
{canCredit ? (
<Button
aria-label={`添加水位 ${identity}`}
disabled={disabled || missingPool}
size="small"
title={missingPool ? "尚未获取该策略的奖池水位" : undefined}
onClick={() => onCredit(pool)}
>
添加水位
</Button>
) : null}
{canDebit ? (
<Button
aria-label={`扣减水位 ${identity}`}
disabled={disabled || missingPool || availableBalance <= 0}
size="small"
title={
missingPool
? "尚未获取该策略的奖池水位"
: availableBalance <= 0
? "当前无可扣减水位"
: undefined
}
variant="danger"
onClick={() => onDebit(pool)}
>
扣减水位
</Button>
) : null}
</div>
);
}