"use client"; import { useMemo } from "react"; import usePlacesAutocomplete from "use-places-autocomplete"; import { Input } from "../ui/input"; import { cn } from "@/lib/utils"; import { HiOutlineBuildingStorefront } from "react-icons/hi2"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { Button } from "@/components/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandItem, CommandInput, CommandList, CommandSeparator, } from "@/components/ui/command"; import { useLoadScript } from "@react-google-maps/api"; export default function LocationSearchInput() { const libraries = useMemo(() => ["places"], []); const { isLoaded, loadError } = useLoadScript({ googleMapsApiKey: process.env.NEXT_PUBLIC_GOOGLE_MAPS_KEY as string, libraries: libraries as any, }); const { ready, value, suggestions: { status, data }, // results from Google Places API for the given search term setValue, // use this method to link input value with the autocomplete hook clearSuggestions, } = usePlacesAutocomplete({ requestOptions: { componentRestrictions: { country: "us" } }, // restrict search to US debounce: 300, cache: 86400, }); if (loadError) { return

hello{JSON.stringify(loadError)}

; } if (!isLoaded) { return

Loading...

; } return ; } function CommandSearch() { const { ready, value, suggestions: { status, data }, // results from Google Places API for the given search term setValue, // use this method to link input value with the autocomplete hook clearSuggestions, } = usePlacesAutocomplete({ requestOptions: { componentRestrictions: { country: "us" } }, // restrict search to US debounce: 300, cache: 86400, }); return ( setValue((e.target as unknown as { value: string }).value) } value={value} placeholder="Search places..." /> No results found. {data.map( ({ description, place_id, structured_formatting: { main_text, secondary_text }, }) => ( {main_text} {description} ), )} {/* Profile Mail Settings */} ); }