import { Link } from '@inertiajs/react';
import { Info } from 'lucide-react';
import type { ReactNode } from 'react';
import CopyButton from '@/components/member/copy-button';
import {
    Dialog,
    DialogContent,
    DialogDescription,
    DialogHeader,
    DialogTitle,
    DialogTrigger,
} from '@/components/ui/dialog';
import { index as supportIndex } from '@/routes/support';

/** Shows the member's account details so they can fund their wallet. */
export default function DepositDialog({
    accountNumber,
    accountName,
    children,
}: {
    accountNumber: string;
    accountName: string;
    children: ReactNode;
}) {
    return (
        <Dialog>
            <DialogTrigger asChild>{children}</DialogTrigger>
            <DialogContent className="gap-0 overflow-hidden rounded-landing-lg p-0 sm:max-w-md">
                <DialogHeader className="border-b border-surface-200 px-5 py-4 text-left">
                    <DialogTitle className="font-display text-lg text-ink">
                        Deposit to your wallet
                    </DialogTitle>
                    <DialogDescription className="text-sm text-ink-500">
                        Here is your wallet account. Funding by bank transfer is
                        being connected and will be available soon.
                    </DialogDescription>
                </DialogHeader>

                <div className="flex flex-col gap-4 p-5">
                    <div className="rounded-landing-lg bg-brand-dark p-5 text-center text-white">
                        <p className="text-[11px] font-semibold tracking-[0.14em] text-white/60 uppercase">
                            Smart Save wallet
                        </p>
                        <p className="mt-2 font-mono text-3xl font-semibold tracking-[0.12em] tabular-nums">
                            {accountNumber}
                        </p>
                        <p className="mt-1 text-sm text-white/75">
                            {accountName}
                        </p>
                        <CopyButton
                            value={accountNumber}
                            label="Copy account number"
                            className="mt-4 bg-highlight px-4 py-2 text-sm text-white hover:bg-highlight-dark"
                        />
                    </div>

                    <div className="flex items-start gap-2.5 rounded-landing border border-highlight/25 bg-highlight-faint px-3.5 py-3 text-sm text-ink-700">
                        <Info className="mt-0.5 size-4 shrink-0 text-highlight-dark" />
                        <p>
                            Please do not send bank transfers to this number
                            yet. To fund your wallet now,{' '}
                            <Link
                                href={supportIndex()}
                                className="font-semibold text-brand underline-offset-4 hover:underline"
                            >
                                contact support
                            </Link>
                            .
                        </p>
                    </div>
                </div>
            </DialogContent>
        </Dialog>
    );
}
