Files
lotteryFront/src/features/wallet/transfer-in-screen.tsx
kang 0cd85ae287 feat: enhance UI consistency and improve spacing across components
- Added styles for player-side toast notifications to improve user feedback.
- Adjusted padding and spacing in various components for a more cohesive layout.
- Updated card and dialog components to streamline visual hierarchy and enhance readability.
- Refactored player panel and navigation elements for better alignment and user experience.
2026-05-21 17:28:06 +08:00

66 lines
1.7 KiB
TypeScript

"use client";
import { useRouter } from "next/navigation";
import { useCallback, useEffect, useMemo, useState } from "react";
import { getWalletBalance } from "@/api/wallet";
import { TransferInPage } from "@/features/wallet/wallet-transfer-forms";
import { Skeleton } from "@/components/ui/skeleton";
import { resolvePlayerCurrency } from "@/lib/player-currency";
import { usePlayerSessionStore } from "@/stores/player-session-store";
import type { WalletBalanceData } from "@/types/api/wallet-balance";
/** 独立路由 `/wallet/transfer-in` */
export function TransferInScreen() {
const router = useRouter();
const profile = usePlayerSessionStore((s) => s.profile);
const [balance, setBalance] = useState<WalletBalanceData | null>(null);
const [loading, setLoading] = useState(true);
const currency = useMemo(
() => resolvePlayerCurrency(profile, balance),
[balance, profile],
);
const load = useCallback(async () => {
const b = await getWalletBalance();
setBalance(b);
}, []);
useEffect(() => {
let c = false;
void (async () => {
try {
await load();
} finally {
if (!c) setLoading(false);
}
})();
return () => {
c = true;
};
}, [load]);
const onSuccess = useCallback(async () => {
await load();
router.push("/wallet");
}, [load, router]);
if (loading && !balance) {
return (
<div className="space-y-3">
<Skeleton className="h-8 w-40" />
<Skeleton className="h-48 w-full rounded-xl" />
</div>
);
}
return (
<TransferInPage
currency={currency}
lotteryMinor={Number(balance?.balance ?? 0)}
onSuccess={onSuccess}
/>
);
}