// import React, { useState } from "react";
// import "./Current_Location_Offcanvas.css";
// import { Form, Offcanvas } from "react-bootstrap";
// import Black_Btn from "../../common-components/common_btn/black_btn/Black_Btn";
// import Gray_Btn from "../../common-components/common_btn/gray_btn/Gray_Btn";
// import Your_Location_modal from "../../common-components/common_modal/Your_Location_modal/Your_Location_modal";
// import { useDispatch, useSelector } from "react-redux";
// import { getCurrentLocation } from "../../../features/location/locationSlice";

// const Current_Location_Offcanvas = ({ show, onHide, ...props }) => {
//   const [showLocationModal, setShowLocationModal] = useState(false);

//   // const handleShowLocationModal = () => {
//   //   setShowLocationModal(true); // Show the "Type manually" modal
//   //   onHide();
//   // };

//   // const handleCloseLocationModal = () => {
//   //   setShowLocationModal(false); // Close the "Type manually" modal
//   // };

//   // const handleOpenLocationModal = () => {
//   //   setShowLocationModal(true); // Close the "Type manually" modal
//   // };
//   const [isLoading, setIsLoading] = useState(false);
//   const [locationText, setLocationText] = useState("Use Current Location");

//   const dispatch = useDispatch();
//   const handleUseCurrentLocation = async () => {
//     setLocationText("Fetching your location...");
//     setIsLoading(true);

//     try {
//       const res = await dispatch(getCurrentLocation());
//       if (res.meta.requestStatus === "fulfilled") {
//         setLocationText("Location fetched");
//         setTimeout(() => {
//           onHide();
//         }, 2000);
//       } else if (res.meta.requestStatus === "rejected") {
//         console.log("Error:", res.payload || "Failed to fetch location");
//         setLocationText("Failed to get location");
//       }
//     } catch (error) {
//       console.error("Error in location fetch:", error);
//       setLocationText("An unexpected error occurred.");
//     } finally {
//       setIsLoading(false);
//     }
//   };

//   return (
//     <>
//       <Offcanvas
//         show={show}
//         onHide={onHide}
//         className="Current_Location_Offcanvas"
//         placement="end"
//       >
//         <Offcanvas.Header>
//           <div className="logo_div">
//             <img
//               // src={"/assets/images/logo/Logo.png"}
//               src={"/assets/images/logo/A-Marts.png"}
//               className="logo"
//             />
//           </div>
//           <div className="close_div" onClick={onHide}>
//             <img
//               src={"/assets/images/location_offcanvas/close.png"}
//               className="close_img"
//             />
//           </div>
//         </Offcanvas.Header>
//         <Offcanvas.Body>
//           <div className="inner_div">
//             <p className="title_text">Location</p>

//             <div className="sub_text_div">
//               <div className="icon_holder">
//                 <img
//                   src={"/assets/images/location_offcanvas/icon.png"}
//                   className="inner_img"
//                 />
//               </div>
//               <div>
//                 <p className="simple_text">To get quick delivery,</p>
//                 <p className="simple_text">
//                   we would like to ensure your current location.
//                 </p>
//               </div>
//             </div>

//             <div className="btns_holder">
//               <Black_Btn
//                 btnText={"Type manually"}
//                 onClick={handleShowLocationModal}
//               />
//               <Gray_Btn
//                 btnText={locationText}
//                 onClick={handleUseCurrentLocation}
//               />
//             </div>
//           </div>
//         </Offcanvas.Body>
//       </Offcanvas>

//       <Your_Location_modal
//         show={showLocationModal}
//         onHide={handleCloseLocationModal}
//         onOpen={handleOpenLocationModal}
//         onBackToChooseLocation={handleCloseLocationModal}
//         onOpenYourLocation={handleCloseLocationModal}
//         setShowConfimLocModal={props?.setShowConfimLocModal}
//       />
//     </>
//   );
// };

// export default Current_Location_Offcanvas;
