"use client";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import { RiArrowRightLine } from "react-icons/ri";
import useEvents from "@/lib/hooks/useEvents";
import { nip19 } from "nostr-tools";
import { type NDKKind } from "@nostr-dev-kit/ndk";
import { uniqBy } from "ramda";
import CalendarCard, { LoadingCalendarCard } from "../_components/CalendarCard";
import { getTagValues } from "@/lib/nostr/utils";
export default function ExploreCalendars() {
return (
Explore Calendars
);
}
function HorizontalCarousel() {
const { events } = useEvents({
filter: {
kinds: [31924 as NDKKind],
limit: 5,
},
});
if (events.length) {
return (
{uniqBy((e) => getTagValues("title", e.tags), events).map(
(calendar, index) => (
),
)}
);
}
return (
{Array.from(Array(5)).map((_, index) => (
))}
);
}
function Calendar({ encodedEvent }: { encodedEvent: string }) {
const { type, data } = nip19.decode(encodedEvent);
if (type !== "naddr") {
throw new Error("impoper type");
}
const { pubkey, identifier, kind } = data;
const { events } = useEvents({
filter: {
authors: [pubkey],
["#d"]: [identifier],
kinds: [31924 as NDKKind],
limit: 1,
},
});
const event = events[0];
if (!event) {
return null;
}
return ;
}