import { useState } from "react";
import { Box, Button, Modal } from "@mui/material";

// Icon
import ArrowBottomH from "@/components/icons/ArrowBottomH";
import Location from "@/components/icons/Location";
import { styleDefault } from "@/mui";
import CloseModalD from "@/components/icons/CloseModalD";
import AutoCompleteSelect from "@/app/component/element/AutoCompleteSelect";
import ArrowLeftM from "@/components/icons/ArrowLeftM";

function ModalSearchCity() {

    const states = [
        { label: 'تهران', id: 10 },
        { label: 'اصفهان', id: 20 },
        { label: 'مازندران', id: 30 }
    ];

    const cities = [
        { label: 'شهر یک', id: 10 },
        { label: 'شهر دو', id: 20 },
        { label: 'شهر سه', id: 30 }
    ];

    const [open, setOpen] = useState(false);
    const handleOpen = () => setOpen(true);
    const handleClose = () => setOpen(false);

    return (
        <>
            {/* Button Modal */}
            <Button
                className="!border-none hover:!bg-transparent !py-[11.5px] !px-[7px] sm:!py-3 sm:!px-[9px] md:!px-[11px] lg:!px-[12px] min-w-fit !rounded-3"
                onClick={handleOpen}
                variant="contained"
                color="secondary"
            >
                <div className="min-w-[20px] min-h-[20px] hidden md:flex">
                    <Location />
                </div>
                <p className="text-[#616161] text-[16px] leading-[17px] sm:leading-[19px] md:leading-[22px] lg:leading-[24px] font-medium ml-1 md:mx-1">انتخاب شهر</p>
                <div className="w-[16px] h-[16px] md:w-[18px] md:h-[18px] lg:w-[20px] lg:h-[20px] grid place-items-center">
                    <ArrowBottomH />
                </div>
            </Button>
            {/* Content Modal */}
            <Modal
                open={open}
                onClose={handleClose}
            >
                <Box sx={styleDefault}>
                    <div
                        className="flex justify-end w-full"
                    >
                        <div className="cursor-pointer" onClick={handleClose}>
                            <CloseModalD />
                        </div>
                    </div>
                    <div className="px-2">
                        <p className="text-[#525252] mt-4 text-[16px] font-medium text-center">شهر یا استان مورد نظر را انتخاب نمایید:</p>
                        <div className="flex flex-col mt-8 mb-14 justify-center items-center gap-10">
                            <AutoCompleteSelect
                                list={states}
                                label='استان'
                            />
                            <AutoCompleteSelect
                                list={cities}
                                label='شهر'
                            />
                        </div>
                        <div className="w-full flex justify-end">
                            <Button
                                variant="contained"
                                color="primary"
                                className="flex !px-3 items-center justify-center gap-1 mr-auto"
                            >
                                تایید و ادامه
                                <ArrowLeftM />
                            </Button>
                        </div>
                    </div>
                </Box>
            </Modal>
        </>
    )
}

export default ModalSearchCity