Files
lotteryFront/src/features/wallet/wallet-transfer-dialogs.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

143 lines
4.3 KiB
TypeScript

"use client";
import { ArrowDownLeft, ArrowUpRight } from "lucide-react";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import {
TransferInPanel,
TransferOutPanel,
} from "@/features/wallet/wallet-transfer-forms";
import { cn } from "@/lib/utils";
type BaseProps = {
currency: string;
onSuccess: () => Promise<void>;
/** 避免同页多实例 input id 冲突 */
idPrefix?: string;
};
export function TransferInDialog({
currency,
lotteryMinor,
onSuccess,
idPrefix = "",
triggerClassName,
triggerVariant = "wallet",
triggerLabel,
}: BaseProps & {
lotteryMinor: number;
triggerClassName?: string;
triggerVariant?: "wallet" | "hall";
triggerLabel?: string;
}) {
const [open, setOpen] = useState(false);
const { t } = useTranslation("player");
const resolvedTriggerLabel = triggerLabel ?? t("wallet.transferIn");
return (
<Dialog open={open} onOpenChange={setOpen}>
<Button
type="button"
variant="default"
className={cn(
"inline-flex h-10 min-h-10 w-full min-w-0 flex-1 items-center justify-center gap-1.5 px-3 text-sm font-medium",
triggerVariant === "hall" && "bg-[#07459f] text-white hover:bg-[#063b88]",
triggerClassName,
)}
onClick={() => setOpen(true)}
>
<ArrowDownLeft className="size-4 shrink-0" />
{resolvedTriggerLabel}
</Button>
<DialogContent showCloseButton className="gap-0 overflow-hidden p-0 sm:max-w-md">
<DialogHeader className="space-y-1.5 border-b border-border px-4 py-3 text-left">
<DialogTitle className="text-lg font-semibold">{t("wallet.transferInTitle")}</DialogTitle>
<DialogDescription className="text-sm leading-relaxed">
{t("wallet.dialogInDescription", { currency })}
</DialogDescription>
</DialogHeader>
<div className="px-4 py-3">
<TransferInPanel
variant="dialog"
currency={currency}
lotteryMinor={lotteryMinor}
idPrefix={idPrefix}
onCancel={() => setOpen(false)}
onSuccess={async () => {
await onSuccess();
setOpen(false);
}}
/>
</div>
</DialogContent>
</Dialog>
);
}
export function TransferOutDialog({
currency,
availableMinor,
onSuccess,
idPrefix = "",
triggerClassName,
triggerVariant = "wallet",
triggerLabel,
}: BaseProps & {
availableMinor: number;
triggerClassName?: string;
triggerVariant?: "wallet" | "hall";
triggerLabel?: string;
}) {
const [open, setOpen] = useState(false);
const { t } = useTranslation("player");
const resolvedTriggerLabel = triggerLabel ?? t("wallet.transferOut");
return (
<Dialog open={open} onOpenChange={setOpen}>
<Button
type="button"
variant="outline"
className={cn(
"inline-flex h-10 min-h-10 w-full min-w-0 flex-1 items-center justify-center gap-1.5 px-3 text-sm font-medium",
triggerVariant === "hall" && "border-border bg-card hover:bg-muted",
triggerClassName,
)}
onClick={() => setOpen(true)}
>
<ArrowUpRight className="size-4 shrink-0" />
{resolvedTriggerLabel}
</Button>
<DialogContent showCloseButton className="gap-0 overflow-hidden p-0 sm:max-w-md">
<DialogHeader className="space-y-1.5 border-b border-border px-4 py-3 text-left">
<DialogTitle className="text-lg font-semibold">{t("wallet.transferOutTitle")}</DialogTitle>
<DialogDescription className="text-sm leading-relaxed">
{t("wallet.dialogOutDescription")}
</DialogDescription>
</DialogHeader>
<div className="px-4 py-3">
<TransferOutPanel
variant="dialog"
currency={currency}
availableMinor={availableMinor}
idPrefix={idPrefix}
onCancel={() => setOpen(false)}
onSuccess={async () => {
await onSuccess();
setOpen(false);
}}
/>
</div>
</DialogContent>
</Dialog>
);
}