From a20b3fecff146c57ab748c9f757172b5896f02aa Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 12 Sep 2023 17:59:23 +0300 Subject: [PATCH] Add a map to the SectionGridHasMap component. - Add a GoogleMapReact component to the code. - Set the default zoom and center of the map. - Add a checkbox to allow users to search as they move the map. - Map each stay to a marker on the map. --- src/app/(stay-listings)/SectionGridHasMap.tsx | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/app/(stay-listings)/SectionGridHasMap.tsx diff --git a/src/app/(stay-listings)/SectionGridHasMap.tsx b/src/app/(stay-listings)/SectionGridHasMap.tsx new file mode 100644 index 0000000..22a96d0 --- /dev/null +++ b/src/app/(stay-listings)/SectionGridHasMap.tsx @@ -0,0 +1,102 @@ +"use client"; + +import React, { FC, useEffect, useState } from "react"; +import AnyReactComponent from "@/components/AnyReactComponent/AnyReactComponent"; +import GoogleMapReact from "google-map-react"; +import { DEMO_STAY_LISTINGS } from "@/data/listings"; +import ButtonClose from "@/shared/ButtonClose"; +import Checkbox from "@/shared/Checkbox"; +import Pagination from "@/shared/Pagination"; +import TabFilters from "./TabFilters"; +import Heading2 from "@/shared/Heading2"; +import StayCard2 from "@/components/StayCard2"; + +const DEMO_STAYS = DEMO_STAY_LISTINGS.filter((_, i) => i < 12); +export interface SectionGridHasMapProps {} + +const SectionGridHasMap: FC = () => { + const [currentHoverID, setCurrentHoverID] = useState(-1); + const [showFullMapFixed, setShowFullMapFixed] = useState(false); + + return ( +
+
+ {/* CARDSSSS */} +
+ +
+ +
+
+ {DEMO_STAYS.map((item) => ( +
setCurrentHoverID((_) => item.id)} + onMouseLeave={() => setCurrentHoverID((_) => -1)} + > + +
+ ))} +
+
+ +
+
+ + {!showFullMapFixed && ( +
setShowFullMapFixed(true)} + > + + Show map +
+ )} + + {/* MAPPPPP */} +
+ {showFullMapFixed && ( + setShowFullMapFixed(false)} + className="bg-white absolute z-50 left-3 top-3 shadow-lg rounded-xl w-10 h-10" + /> + )} + +
+
+ +
+ + {DEMO_STAYS.map((item) => ( + + ))} + +
+
+
+
+ ); +}; + +export default SectionGridHasMap;