import React from 'react';

import { Button } from '@/components/ui/button';
import {
    Dialog,
    DialogContent,
    DialogFooter,
} from '@/components/ui/dialog';
import { Lang } from '@/lang/Lang';

import {
    HALL_SEAT_FILL_DIRECTION_LANG_KEY,
    HALL_SEAT_FILL_DIRECTIONS,
    type HallSeatFillDirection,
} from '../hallSeatOrder';

type Props = {
    open: boolean;
    onOpenChange: (open: boolean) => void;
    startFrom: string;
    fillDirection: HallSeatFillDirection;
    onStartFromChange: (value: string) => void;
    onFillDirectionChange: (direction: HallSeatFillDirection) => void;
    onApply: () => void;
};

export default function SeatNumberingDialog({
    open,
    onOpenChange,
    startFrom,
    fillDirection,
    onStartFromChange,
    onFillDirectionChange,
    onApply,
}: Props) {
    return (
        <Dialog open={open} onOpenChange={onOpenChange}>
            <DialogContent className="max-w-md">
                <div className="space-y-4">
                    <div className="text-sm font-semibold">{Lang.key('hall_seat_numbering_title')}</div>
                    <div className="space-y-2">
                        <div className="text-xs text-slate-600">{Lang.key('hall_seat_start_from')}</div>
                        <input
                            className="w-full border rounded-md h-9 px-3 text-sm"
                            type="text"
                            inputMode="text"
                            autoComplete="off"
                            value={startFrom}
                            onChange={(e) => onStartFromChange(e.target.value)}
                        />
                        <div className="text-xs text-slate-500">{Lang.key('hall_seat_start_hint')}</div>
                    </div>
                    <div className="space-y-2">
                        <div className="text-xs text-slate-600">{Lang.key('hall_seat_direction_label')}</div>
                        <select
                            className="w-full border rounded-md h-9 px-3 text-sm bg-white"
                            value={fillDirection}
                            onChange={(e) => onFillDirectionChange(e.target.value as HallSeatFillDirection)}
                        >
                            {HALL_SEAT_FILL_DIRECTIONS.map((dir) => (
                                <option key={dir} value={dir}>
                                    {Lang.key(HALL_SEAT_FILL_DIRECTION_LANG_KEY[dir])}
                                </option>
                            ))}
                        </select>
                    </div>
                </div>
                <DialogFooter>
                    <Button
                        onClick={() => onOpenChange(false)}
                        type="button"
                        variant="outline"
                    >
                        {Lang.key('cancel')}
                    </Button>
                    <Button onClick={onApply} type="button">
                        {Lang.key('apply')}
                    </Button>
                </DialogFooter>
            </DialogContent>
        </Dialog>
    );
}
