2023-10-16 00:28:09 -04:00
|
|
|
"use client";
|
|
|
|
import { useEffect } from "react";
|
|
|
|
import Article from "@/containers/Article";
|
|
|
|
import { useNDK } from "@nostr-dev-kit/ndk-react";
|
2023-10-16 10:59:28 -04:00
|
|
|
import { nip19, type Event } from "nostr-tools";
|
2023-10-16 00:28:09 -04:00
|
|
|
import Spinner from "@/components/spinner";
|
|
|
|
import useEvents from "@/lib/hooks/useEvents";
|
2023-10-16 10:59:28 -04:00
|
|
|
import KindCard from "@/components/KindCard";
|
|
|
|
export default function EventPage({
|
|
|
|
params: { key },
|
2023-10-16 00:28:09 -04:00
|
|
|
}: {
|
|
|
|
params: {
|
2023-10-16 10:59:28 -04:00
|
|
|
key: string;
|
2023-10-16 00:28:09 -04:00
|
|
|
};
|
|
|
|
}) {
|
|
|
|
const { ndk } = useNDK();
|
2023-10-16 10:59:28 -04:00
|
|
|
const { data, type } = nip19.decode(key);
|
2023-10-16 00:28:09 -04:00
|
|
|
const { events } = useEvents({
|
|
|
|
filter:
|
2023-10-16 10:59:28 -04:00
|
|
|
type === "nevent"
|
2023-10-16 00:28:09 -04:00
|
|
|
? {
|
2023-10-16 10:59:28 -04:00
|
|
|
ids: [data.id],
|
2023-10-16 00:28:09 -04:00
|
|
|
limit: 1,
|
|
|
|
}
|
|
|
|
: {},
|
|
|
|
});
|
|
|
|
|
|
|
|
if (events?.[0]) {
|
2023-10-16 10:59:28 -04:00
|
|
|
const event = events[0].rawEvent() as Event;
|
|
|
|
return (
|
|
|
|
<div className="center pt-7 text-primary">
|
|
|
|
<KindCard {...event} />
|
|
|
|
</div>
|
|
|
|
);
|
2023-10-16 00:28:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="center pt-20 text-primary">
|
|
|
|
<Spinner />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|