diff --git a/src/app/(protected)/workorders/_components/wizard/mini-calendar.tsx b/src/app/(protected)/workorders/_components/wizard/mini-calendar.tsx new file mode 100644 index 00000000..4c4132fd --- /dev/null +++ b/src/app/(protected)/workorders/_components/wizard/mini-calendar.tsx @@ -0,0 +1,115 @@ +import { useState } from "react"; +import { ChevronLeft, ChevronRight } from "lucide-react"; +import { MONTH_NAMES, pad2, todayIso } from "@/domain/work-orders/utils/wizard-date-utils"; + +const WEEKDAY_HEADER = ["S", "M", "T", "W", "T", "F", "S"]; + +type MiniCalendarProps = { + value: string; + onChange: (iso: string) => void; +}; + +export function MiniCalendar({ value, onChange }: MiniCalendarProps) { + const init = /^\d{4}-\d{2}-\d{2}$/.test(value) ? value : todayIso(); + const [iy, im] = init.split("-").map(Number); + const [viewY, setViewY] = useState(iy); + const [viewM, setViewM] = useState(im); + + const firstWeekday = new Date(viewY, viewM - 1, 1).getDay(); + const daysInMonth = new Date(viewY, viewM, 0).getDate(); + const cells: (number | null)[] = [ + ...Array(firstWeekday).fill(null), + ...Array.from({ length: daysInMonth }, (_, i) => i + 1), + ]; + + const step = (delta: number) => { + let m = viewM + delta; + let y = viewY; + if (m < 1) { + m = 12; + y -= 1; + } + if (m > 12) { + m = 1; + y += 1; + } + setViewM(m); + setViewY(y); + }; + + const today = todayIso(); + + return ( +
+ No matches +
+ ) : ( + filtered.map((o) => ( + + )) + )} +
+
+ Auto-filled from records — edit if outdated +
++ Both are optional — leave blank to fill in later from the dispatch board. +
+ )} +
+