diff --git a/frontend/src/app/Components/Overlay.tsx b/frontend/src/app/Components/Overlay.tsx index b4c7fa3..2ac9bc8 100644 --- a/frontend/src/app/Components/Overlay.tsx +++ b/frontend/src/app/Components/Overlay.tsx @@ -1,20 +1,22 @@ "use client"; -import React, { useState, useEffect } from 'react'; -import { PinData } from "./utils"; -import { addOutletFrontend, addOutlet, isOnLand } from "../utils/addOutlet"; +import React, { useState, useEffect } from "react"; import { - LucideBookmark, LucideClock, LucidePlus, LucideLocateFixed, LucideSearch, - LucideUpload, SunMedium, Moon, ChevronDown, Plus, Bike, PlugZap, User, - ArrowRight, MapPin, LucideX, Save, LucidePlugZap, LucideStar, LucideNavigation, LucidePlayCircle -} from 'lucide-react'; -import { auth, db } from "../firebase/firebase"; -import { signOut } from "firebase/auth"; -import { doc, getDoc, getDocs, collection, updateDoc } from "firebase/firestore"; -import { setIsAuthenticated, getIsAuthenticated } from '../globals'; -import { useRouter } from 'next/navigation'; -import Image from "next/image"; -import { useUserData } from '../create-account/UserDataContext'; + LucideZap, + LucideBookmark, + LucideClock, + LucidePlus, + LucideSearch, + LucideUpload, + LucideFilter, + LucideSlidersHorizontal, + LucideSunMedium, + LucideHome, + LucideBriefcase, + LucideGraduationCap, + LucideHistory, +} from "lucide-react"; +import { FaPlug } from "react-icons/fa6"; interface OverlayProps { showPinOverlay: boolean; @@ -33,6 +35,32 @@ interface OverlayProps { const portOptions = ["Triple Peg", "Double Peg", "USB", "HDMI"]; const conditionOptions = ["New", "Worn", "Slightly Damaged", "Damaged"]; +function useIsMobile() { + const [isMobile, setIsMobile] = useState(false); + useEffect(() => { + const checkMobile = () => setIsMobile(window.innerWidth <= 768); + checkMobile(); + window.addEventListener("resize", checkMobile); + return () => window.removeEventListener("resize", checkMobile); + }, []); + return isMobile; +} + +const dummyRecents = [ + { + title: "University of Waterloo", + address: "University Avenue West, Waterloo, ON", + }, + { + title: "University of Waterloo", + address: "University Avenue West, Waterloo, ON", + }, + { + title: "University of Waterloo", + address: "University Avenue West, Waterloo, ON", + }, +]; + const AddOutlet: React.FC = ({ showPinOverlay, coords, @@ -54,7 +82,9 @@ const AddOutlet: React.FC = ({ const [extraDetails, setExtraDetails] = useState(""); const [showSettings, setShowSettings] = useState(false); const [searchValue, setSearchValue] = useState(""); - const [searchResults, setSearchResults] = useState>([]); + const [searchFocused, setSearchFocused] = useState(false); + const isMobile = useIsMobile(); + const [searchResults, setSearchResults] = useState>([]); const [showSearchResults, setShowSearchResults] = useState(false); const [showProfile, setProfile] = useState(""); const { setUserData } = useUserData(); @@ -160,8 +190,25 @@ const AddOutlet: React.FC = ({ if (!coords) return; setAddress(`${coords.lng.toFixed(5)} ${coords.lat.toFixed(5)}`); setShowAddOutlet(true); - } else { - setShowAddOutlet(false); // <— key line + } + }, [coords]); + + if (isMobile) { + return ( + <> +
+
+
+ }, [coords, selectedPin]); + + // If a pin on the map is selected, pre-fill form fields for read-only display + useEffect(() => { + if (selectedPin) { + // Switch to the Add-Outlet form, but in existing-pin mode (no submit) + setShowAddOutlet(true); setAddress(selectedPin.title || ""); setPowerType(selectedPin.category || ""); setExtraDetails(selectedPin.description || ""); @@ -318,23 +365,120 @@ const AddOutlet: React.FC = ({ onKeyDown={handleSearchKeyDown} className={`bg-transparent outline-none w-full text-md ${lightMode ? "placeholder-black/60" : "placeholder-white/60"}`} /> - - {/* search results dropdown */} - {showSearchResults && searchResults.length > 0 && ( -
- {searchResults.map((result, index) => ( -
handleSearchResultClick(result)} - > - {result.place_name} + + + {/* search results dropdown */} + {showSearchResults && searchResults.length > 0 && ( +
+ {searchResults.map((result, index) => ( +
+
+ {searchValue === "" && ( + + )} + setSearchFocused(true)} + onBlur={() => setSearchFocused(false)} + onChange={(e) => setSearchValue(e.target.value)} + className="bg-transparent outline-none text-white placeholder-white/60 w-full text-md" + /> +
+
+ {searchFocused && ( +
+ {/* Home, Work, School */} +
+
+ + + Home + +
+
+ + + Work + +
+
+ + + School + +
+
+
+ {/* Recent Searches */} + {dummyRecents.map((item, idx) => ( +
+ +
+
+ {item.title} +
+
+ {item.address} +
+
+
+ ))}
- ))} + )}
- )} +
+
+ +
+
+
+ + + +
+
+ + ); + } + + return ( +
+
+ + +
{/* dark/light mode switch */}