import React, { useState } from "react";
import { Select, Modal, Button } from "antd";
import { X } from "lucide-react";
import styles from "./AddressSelect.module.scss";
const { Option } = Select;
const AddressSelect = ({
selectedAddress,
handleAddressSelect,
handleClearAddress,
deviceType,
locations,
}) => {
const [isModalVisible, setIsModalVisible] = useState(false);
const showModal = () => {
setIsModalVisible(true);
};
const handleClear = (e) => {
e.stopPropagation();
handleClearAddress();
};
const handleCancel = () => {
setIsModalVisible(false);
};
return (
{deviceType === "mobile" ? (
<>
}
footer={null}
>
{Array.isArray(locations) && locations.length > 0 ? (
locations.map((location) => (
- {
handleAddressSelect(location.name);
setIsModalVisible(false);
}}
className={styles.optionItem}
>
{location.name}
))
) : (
- Loading...
)}
>
) : (
,
}}
onClear={handleClearAddress}
className={styles.addressSelect}
showArrow={!selectedAddress}
loading={!locations}
dropdownRender={(menu) => (
{menu}
)}
>
{Array.isArray(locations) && locations.length > 0 ? (
locations.map((location) => (
))
) : (
)}
)}
);
};
export default AddressSelect;