"use client"; import { RiAddLine, RiCheckboxCircleFill } from "@remixicon/react"; import type { KeyboardEvent, MouseEvent } from "react"; import type { CalendarDay, CalendarEvent } from "@/shared/lib/types/calendar"; import { currencyFormatter } from "@/shared/utils/currency"; import { cn } from "@/shared/utils/ui"; type DayCellProps = { day: CalendarDay; onSelect: (day: CalendarDay) => void; onCreate: (day: CalendarDay) => void; }; export const EVENT_TYPE_STYLES: Record< CalendarEvent["type"], { wrapper: string; dot: string } > = { transaction: { wrapper: "bg-primary/10 text-primary dark:bg-primary/5 dark:text-primary", dot: "bg-primary", }, installment: { wrapper: "bg-amber-100 text-amber-600 dark:bg-amber-900/10 dark:text-amber-500", dot: "bg-amber-500", }, boleto: { wrapper: "bg-info/10 text-info dark:bg-info/5 dark:text-info", dot: "bg-info", }, card: { wrapper: "bg-violet-100 text-violet-600 dark:bg-violet-900/10 dark:text-violet-500", dot: "bg-violet-600 dark:bg-violet-500", }, }; const formatCurrencyValue = (value: number | null | undefined) => currencyFormatter.format(Math.abs(value ?? 0)); const buildEventLabel = (event: CalendarEvent) => { switch (event.type) { case "transaction": case "boleto": return event.transaction.name; case "installment": return event.transaction.name; case "card": return event.card.name; default: return ""; } }; const buildEventComplement = (event: CalendarEvent) => { switch (event.type) { case "transaction": case "boleto": return formatCurrencyValue(event.transaction.amount); case "installment": return `${event.installmentCount}x de ${formatCurrencyValue(event.installmentValue)}`; case "card": return event.card.totalDue !== null ? formatCurrencyValue(event.card.totalDue) : null; default: return null; } }; const isPaid = (event: CalendarEvent) => { if (event.type === "boleto") return Boolean(event.transaction.isSettled); if (event.type === "card") return event.card.isPaid; return false; }; const DayEventPreview = ({ event }: { event: CalendarEvent }) => { const complement = buildEventComplement(event); const label = buildEventLabel(event); const style = EVENT_TYPE_STYLES[event.type]; return (