"use client"; import Image from "next/image"; import { cn, formatNumber } from "@/lib/utils"; import { Badge } from "@/components/ui/badge"; import { RxClock, RxCalendar } from "react-icons/rx"; import { HiOutlineUsers } from "react-icons/hi"; import { AspectRatio } from "@/components/ui/aspect-ratio"; import { Skeleton } from "@/components/ui/skeleton"; import { formatDate } from "@/lib/utils/dates"; import { NostrEvent } from "@nostr-dev-kit/ndk"; import { getTagAllValues, getTagValues, getTagsValues, } from "@/lib/nostr/utils"; import useProfile from "@/lib/hooks/useProfile"; import SmallProfileLine from "@/components/ProfileContainers/SmallProfileLine"; type CalendarEventCardProps = { event: NostrEvent; className?: string; }; export default function CalendarEventCard({ className, event, }: CalendarEventCardProps) { const { pubkey, tags } = event; const { profile } = useProfile(pubkey); const title = getTagValues("name", tags) || "Untitled"; const image = getTagValues("image", tags) ?? getTagValues("picture", tags) ?? getTagValues("banner", tags) ?? profile?.banner; const description = event.content; const startDate = getTagValues("start", tags) ? new Date(parseInt(getTagValues("start", tags) as string) * 1000) : null; const endDate = getTagValues("end", tags) ? new Date(parseInt(getTagValues("end", tags) as string) * 1000) : null; const getLocation = () => { let temp = getTagAllValues("location", tags); if (temp[0]) { return temp; } return getTagAllValues("address", tags); }; const location = getLocation(); const users = getTagsValues("p", tags); const hashtags = getTagsValues("t", tags); return (
{title}

{title}

{!!startDate && ( <> {startDate.getDay() === endDate?.getDay() ? (
{formatDate(startDate, "ddd, MMM D")}
) : (
{formatDate(startDate, "ddd, MMM D")} {!!endDate && ( <> {" "} -{" "} {formatDate(endDate, "MMM D")} )}
)}
{formatDate(startDate, "h:mm a")} {!!endDate && ( <> {" "} -{" "} {formatDate(endDate, "h:mm a")} )}
)} {!!users.length && (
{formatNumber(users.length)}
)}
); } export function CardLoading({ className }: { className?: string }) { return (
); }