"use client"; import { useState } from "react"; import Image from "next/image"; import Link from "next/link"; import { nip19 } from "nostr-tools"; import useEvents from "@/lib/hooks/useEvents"; import Spinner from "@/components/spinner"; import { getTagAllValues, getTagValues, getTagsAllValues, getTagsValues, } from "@/lib/nostr/utils"; import Header from "./_components/Header"; import LocationPreview from "@/components/LocationPreview"; import HostsContainer from "./_components/HostsContainer"; import LocationContainer from "./_components/LocationContainer"; import AnnouncementsContainer from "./_components/AnnouncementsContainer"; import AttendeesContainer from "./_components/AttendeesContainer"; export default function EventPage({ params: { naddr }, }: { params: { naddr: string; }; }) { const { type, data } = nip19.decode(naddr); if (type !== "naddr") { throw new Error("Invalid list"); } const { identifier, kind, pubkey } = data; const { events } = useEvents({ filter: { authors: [pubkey], kinds: [kind], ["#d"]: [identifier], limit: 1, }, }); const event = events[0]; if (!event) { return (
); } const { tags } = event; const eventReference = event.encode(); const noteIds = getTagsValues("e", tags).filter(Boolean); const location = getTagAllValues("location", tags)[0] ? getTagAllValues("location", tags) : getTagAllValues("address", tags); const geohash = getTagValues("g", tags); const hosts = getTagsAllValues("p", tags) .filter(([pubkey, relay, role]) => role === "host") .map(([pubkey]) => pubkey) .filter(Boolean); const attendees = getTagsAllValues("p", tags) .map(([pubkey]) => pubkey) .filter(Boolean); return (
{!!location && !!geohash && ( )}
); }