import { Badge, Box, Button, darken, Group, Image, lighten, ScrollArea, Stack, Text, useMantineColorScheme, } from "@mantine/core"; import { IconClock, IconPin } from "@tabler/icons-react"; import dayjs from "dayjs"; import { isNullOrWhitespace } from "@homarr/common"; import type { CalendarEvent } from "@homarr/integrations/types"; import { useI18n } from "@homarr/translation/client"; import classes from "./calendar-event-list.module.css"; interface CalendarEventListProps { events: CalendarEvent[]; } export const CalendarEventList = ({ events }: CalendarEventListProps) => { const { colorScheme } = useMantineColorScheme(); const t = useI18n(); return ( {events.map((event, eventIndex) => ( {event.image !== null && ( {event.image.badge !== undefined && ( {event.image.badge.content} )} )} {event.subTitle !== null && ( {event.subTitle} )} {event.title} {event.metadata?.type === "radarr" && ( {t(`widget.calendar.option.releaseType.options.${event.metadata.releaseType}`)} )} {isAllDay(event) ? ( {t("widget.calendar.duration.allDay")} ) : ( <> {dayjs(event.startDate).format("HH:mm")} {event.endDate !== null && ( <> -{" "} {dayjs(event.endDate).format("HH:mm")} )} )} {event.location !== null && ( {event.location} )} {!isNullOrWhitespace(event.description) && ( {event.description} )} {event.links.length > 0 && ( {event.links .filter((link) => link.href) .map((link) => ( ))} )} ))} ); }; const isAllDay = (event: Pick) => { if (!event.endDate) return false; const start = dayjs(event.startDate); const end = dayjs(event.endDate); return start.startOf("day").isSame(start) && end.endOf("day").isSame(end); };