/** @jsxImportSource @nym.sh/jrx */ import type { FeedItemRenderer } from "@aelis/core" import { FeedCard, SansSerifText, SerifText } from "@aelis/components" import type { CalDavEventData } from "./types.ts" import { CalDavEventStatus } from "./types.ts" function formatTime(date: Date): string { const hours = date.getHours() const minutes = date.getMinutes() const period = hours >= 12 ? "PM" : "AM" const h = hours % 12 || 12 const m = minutes.toString().padStart(2, "0") return `${h}:${m} ${period}` } function formatTimeRange(data: CalDavEventData): string { if (data.isAllDay) { return "All day" } return `${formatTime(data.startDate)} – ${formatTime(data.endDate)}` } function formatStatus(status: CalDavEventData["status"]): string | null { if (status === CalDavEventStatus.Cancelled) return "Cancelled" if (status === CalDavEventStatus.Tentative) return "Tentative" return null } export const renderCalDavFeedItem: FeedItemRenderer<"caldav-event", CalDavEventData> = (item) => { const { data, slots } = item const statusLabel = formatStatus(data.status) const attendeeCount = data.attendees.length return ( {statusLabel ? : null} {data.calendarName ? ( ) : null} {data.location ? ( ) : null} {attendeeCount > 0 ? ( ) : null} {slots?.insight?.content ? ( ) : null} {slots?.preparation?.content ? ( ) : null} {slots?.crossSource?.content ? ( ) : null} ) }