diff --git a/app/(app)/event/[naddr]/page.tsx b/app/(app)/event/[naddr]/page.tsx index 57b1b75..4b4233d 100644 --- a/app/(app)/event/[naddr]/page.tsx +++ b/app/(app)/event/[naddr]/page.tsx @@ -46,28 +46,31 @@ export default function EventPage({ const location = getTagAllValues("location", event.tags)[0] ? getTagAllValues("location", event.tags) : getTagAllValues("address", event.tags); + const geohash = getTagValues("g", event.tags); return (
-
- {location && ( +
+ {!!location && !!geohash && ( )} - ( -
-

No notes yet

-
- )} - /> +
+ ( +
+

No Announcements yet

+
+ )} + /> +
diff --git a/bun.lockb b/bun.lockb index 7ee5bf0..e3ed9cf 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/Cards/CalendarEvent/index.tsx b/components/Cards/CalendarEvent/index.tsx index 1cb0edb..073e48f 100644 --- a/components/Cards/CalendarEvent/index.tsx +++ b/components/Cards/CalendarEvent/index.tsx @@ -70,7 +70,7 @@ export default function CalendarEventCard({ height={150} unoptimized className={cn( - "h-full w-auto object-cover transition-all group-hover:scale-105", + "objegitct-cover h-full w-auto transition-all group-hover:scale-105", "aspect-video", )} /> diff --git a/components/LocationPreview/index.tsx b/components/LocationPreview/index.tsx index 602b0aa..1ec82c0 100644 --- a/components/LocationPreview/index.tsx +++ b/components/LocationPreview/index.tsx @@ -11,22 +11,22 @@ import { CardTitle, } from "@/components/ui/card"; import { cn } from "@/lib/utils"; +import Geohash from "latlon-geohash"; +import { HiMapPin } from "react-icons/hi2"; type LocationPreviewProps = { - coordinates: { - lat: number; - lng: number; - }; + geohash: string; address: string; className?: string; }; export default function LocationPreview({ - coordinates, + geohash, address, className, }: LocationPreviewProps) { const libraries = useMemo(() => ["places"], []); - const mapCenter = useMemo(() => coordinates, []); + const { lat, lon } = Geohash.decode(geohash); + const mapCenter = useMemo(() => ({ lat, lng: lon }), []); const mapOptions = useMemo( () => ({ @@ -43,24 +43,40 @@ export default function LocationPreview({ }); if (!isLoaded) { - return

Loading...

; + return ( + + + + Location + + +
+
+ + {address} + +
+ ); } return ( - + + Location - + console.log("Map Component Loaded...")} /> - {address} + + {address} + ); } diff --git a/components/LocationSearch/index.tsx b/components/LocationSearch/index.tsx index 5fa7358..4c8df1f 100644 --- a/components/LocationSearch/index.tsx +++ b/components/LocationSearch/index.tsx @@ -24,17 +24,20 @@ import { import { Button } from "@/components/ui/button"; import { useLoadScript } from "@react-google-maps/api"; import Spinner from "../spinner"; +import Geohash from "latlon-geohash"; type LocationSearchInputProps = { onSelect: (location: { name: string; address: string; coordinates: { lat: number; lng: number }; + geohash: string; }) => void; location?: { name: string; address: string; coordinates: { lat: number; lng: number }; + geohash: string; }; }; export default function LocationSearchInput({ @@ -73,11 +76,13 @@ type CommandSearchProps = { name: string; address: string; coordinates: { lat: number; lng: number }; + geohash: string; }) => void; location?: { name: string; address: string; coordinates: { lat: number; lng: number }; + geohash: string; }; }; function CommandSearch({ location, onSelect }: CommandSearchProps) { @@ -99,11 +104,13 @@ function CommandSearch({ location, onSelect }: CommandSearchProps) { }); if (!result[0]) return; const coordinates = getLatLng(result[0]); + const geohash = Geohash.encode(coordinates.lat, coordinates.lng, 6); setOpen(false); return onSelect({ name, coordinates, address: result[0].formatted_address, + geohash, }); } return ( diff --git a/components/Modals/CreateCalendarEvent.tsx b/components/Modals/CreateCalendarEvent.tsx index ddc4e75..495dee6 100644 --- a/components/Modals/CreateCalendarEvent.tsx +++ b/components/Modals/CreateCalendarEvent.tsx @@ -70,6 +70,7 @@ export default function CreateCalendarEventModal() { address: string; name: string; coordinates: { lat: number; lng: number }; + geohash: string; }>(); const { ndk } = useNDK(); const { currentUser } = useCurrentUser(); @@ -107,6 +108,7 @@ export default function CreateCalendarEventModal() { location.name, location.address, ]); + tags.push(["g", location.geohash]); } if (imageUrl) { tags.push(["image", imageUrl]); diff --git a/package.json b/package.json index cee7a7d..1cb74e7 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "focus-trap-react": "^10.2.3", "framer-motion": "^10.16.4", "jotai": "^2.4.3", + "latlon-geohash": "^2.0.0", "next": "13.5.4", "next-themes": "^0.2.1", "node-html-parser": "^6.1.10", @@ -73,6 +74,7 @@ "@tailwindcss/typography": "^0.5.10", "@total-typescript/ts-reset": "^0.5.1", "@types/crypto-js": "^4.1.2", + "@types/latlon-geohash": "^2.0.2", "@types/node": "^20", "@types/ramda": "^0.29.6", "@types/react": "^18",