import React from 'react';

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

type Direction = 'ttb' | 'btt';

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

export default function SeatRowsDialog({
    open,
    onOpenChange,
    startFrom,
    direction,
    onStartFromChange,
    onDirectionChange,
    onApply,
}: Props) {
    return (
        <Dialog open={open} onOpenChange={onOpenChange}>
            <DialogContent className="max-w-md">
                <div className="space-y-4">
                    <div className="text-sm font-semibold">Seat rows</div>
                    <div className="space-y-2">
                        <div className="text-xs text-slate-600">Start from</div>
                        <input
                            className="w-full border rounded-md h-9 px-3 text-sm"
                            min={0}
                            type="number"
                            value={startFrom}
                            onChange={(e) => onStartFromChange(e.target.value)}
                        />
                    </div>
                    <div className="space-y-2">
                        <div className="text-xs text-slate-600">Direction</div>
                        <div className="flex gap-2">
                            <Button
                                onClick={() => onDirectionChange('ttb')}
                                type="button"
                                variant={direction === 'ttb' ? 'default' : 'outline'}
                            >
                                Top to bottom
                            </Button>
                            <Button
                                onClick={() => onDirectionChange('btt')}
                                type="button"
                                variant={direction === 'btt' ? 'default' : 'outline'}
                            >
                                Bottom to top
                            </Button>
                        </div>
                    </div>
                </div>
                <DialogFooter>
                    <Button
                        onClick={() => onOpenChange(false)}
                        type="button"
                        variant="outline"
                    >
                        {Lang.key('cancel')}
                    </Button>
                    <Button onClick={onApply} type="button">
                        Apply
                    </Button>
                </DialogFooter>
            </DialogContent>
        </Dialog>
    );
}

