feat: 接入公开币种目录并统一多币种金额与语言初始化处理

This commit is contained in:
2026-05-21 15:14:00 +08:00
parent 626914feb6
commit 6b18e25766
27 changed files with 277 additions and 94 deletions

View File

@@ -18,7 +18,12 @@ import {
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { PlayerPanel } from "@/components/layout/player-panel";
import { formatMinorAsCurrency, parseDecimalInputToMinor } from "@/lib/money";
import {
formatMinorAsCurrency,
getCurrencyDecimalPlaces,
parseDecimalInputToMinor,
} from "@/lib/money";
import { useCurrencyCatalog } from "@/hooks/use-currency-catalog";
import { formatWalletClientError } from "@/lib/wallet-api-error";
import { LotteryApiBizError } from "@/types/api/errors";
@@ -64,14 +69,15 @@ export function TransferInPanel({
variant?: PanelVariant;
}) {
const { t } = useTranslation("player");
useCurrencyCatalog();
const [amountText, setAmountText] = useState("");
const [submitting, setSubmitting] = useState(false);
const [localError, setLocalError] = useState<string | null>(null);
const tid = `${idPrefix}in-amount`;
const parsedMinor = useMemo(
() => parseDecimalInputToMinor(amountText),
[amountText],
() => parseDecimalInputToMinor(amountText, currency),
[amountText, currency],
);
const previewAfter =
parsedMinor != null ? lotteryMinor + parsedMinor : lotteryMinor;
@@ -204,14 +210,15 @@ export function TransferOutPanel({
variant?: PanelVariant;
}) {
const { t } = useTranslation("player");
useCurrencyCatalog();
const [amountText, setAmountText] = useState("");
const [submitting, setSubmitting] = useState(false);
const [localError, setLocalError] = useState<string | null>(null);
const tid = `${idPrefix}out-amount`;
const parsedMinor = useMemo(
() => parseDecimalInputToMinor(amountText),
[amountText],
() => parseDecimalInputToMinor(amountText, currency),
[amountText, currency],
);
const previewAfter =
parsedMinor != null
@@ -219,8 +226,9 @@ export function TransferOutPanel({
: availableMinor;
const fillAll = () => {
const major = availableMinor / 100;
setAmountText(major.toFixed(2));
const decimals = getCurrencyDecimalPlaces(currency);
const major = availableMinor / 10 ** decimals;
setAmountText(major.toFixed(decimals));
};
const submit = async () => {