From 4212e7c51e98f2e1314a4496c20ab6374378c9bb Mon Sep 17 00:00:00 2001 From: zmeyer44 Date: Tue, 24 Oct 2023 15:31:06 -0400 Subject: [PATCH] testing loction --- app/(app)/event/[naddr]/page.tsx | 16 +++++- components/Cards/CalendarEvent/index.tsx | 2 +- components/LocationPreview/index.tsx | 66 ++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 components/LocationPreview/index.tsx diff --git a/app/(app)/event/[naddr]/page.tsx b/app/(app)/event/[naddr]/page.tsx index 92b74cc..57b1b75 100644 --- a/app/(app)/event/[naddr]/page.tsx +++ b/app/(app)/event/[naddr]/page.tsx @@ -4,9 +4,14 @@ import Image from "next/image"; import { nip19 } from "nostr-tools"; import useEvents from "@/lib/hooks/useEvents"; import Spinner from "@/components/spinner"; -import { getTagValues, getTagsValues } from "@/lib/nostr/utils"; +import { + getTagAllValues, + getTagValues, + getTagsValues, +} from "@/lib/nostr/utils"; import Feed from "@/containers/Feed"; import Header from "./_components/Header"; +import LocationPreview from "@/components/LocationPreview"; export default function EventPage({ params: { naddr }, @@ -38,12 +43,21 @@ export default function EventPage({ ); } const noteIds = getTagsValues("e", event.tags).filter(Boolean); + const location = getTagAllValues("location", event.tags)[0] + ? getTagAllValues("location", event.tags) + : getTagAllValues("address", event.tags); return (
+ {location && ( + + )} diff --git a/components/LocationPreview/index.tsx b/components/LocationPreview/index.tsx new file mode 100644 index 0000000..602b0aa --- /dev/null +++ b/components/LocationPreview/index.tsx @@ -0,0 +1,66 @@ +"use client"; + +import { useLoadScript, GoogleMap } from "@react-google-maps/api"; +import type { NextPage } from "next"; +import { useMemo } from "react"; +import { + Card, + CardContent, + CardFooter, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { cn } from "@/lib/utils"; + +type LocationPreviewProps = { + coordinates: { + lat: number; + lng: number; + }; + address: string; + className?: string; +}; +export default function LocationPreview({ + coordinates, + address, + className, +}: LocationPreviewProps) { + const libraries = useMemo(() => ["places"], []); + const mapCenter = useMemo(() => coordinates, []); + + const mapOptions = useMemo( + () => ({ + disableDefaultUI: true, + clickableIcons: true, + scrollwheel: false, + }), + [], + ); + + const { isLoaded } = useLoadScript({ + googleMapsApiKey: process.env.NEXT_PUBLIC_GOOGLE_MAPS_KEY as string, + libraries: libraries as any, + }); + + if (!isLoaded) { + return

Loading...

; + } + return ( + + + Location + + + console.log("Map Component Loaded...")} + /> + {address} + + + ); +}