'use client' import { ChevronLeft, ChevronRight } from 'lucide-react' import { civilDateDaysBetween, formatBahiaCivilDate, formatIsoAsBahiaDateTimeInput, } from '@/lib/campaignTime' import { activityAgendaPeriodLabel, type ActivityAgendaView } from '@/utilities/activityUi' import type { ActivityAgendaEvent } from '@/utilities/activityViewModels' /** * C110 — the adjacent-period reveal: while the finger drags the grid, this * panel sits glued to the seam (a child of the transformed container, at * `left: 100%` for next / `right: 100%` for prev) and its edge slides into * the revealed strip. It shows the direction chevron, the adjacent period * label and an abstract grid frame (the "quadro do grid" of the accept — * deliberately NOT a second FullCalendar, which is a cut rabbit hole), with * the adjacent period's events entering as bars/dots/rows as they load * asynchronously. `aria-hidden`: the gesture is the interaction; the commit * replaces the whole preview with the real grid. */ const SLOT_START_MINUTES = 7 * 60 const SLOT_END_MINUTES = 22 * 60 const SLOT_SPAN_MINUTES = SLOT_END_MINUTES - SLOT_START_MINUTES const MAX_PREVIEW_EVENTS = 6 const weekInitials = ['Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb', 'Dom'] as const export type ActivityAgendaAdjacentRange = { start: string end: string anchorDate: string } const timedTopPercent = (startAt: string): number => { const civil = formatIsoAsBahiaDateTimeInput(startAt) const match = /T(\d{2}):(\d{2})/.exec(civil) if (!match) return 0 const minutes = Number(match[1]) * 60 + Number(match[2]) const clamped = Math.min(Math.max(minutes - SLOT_START_MINUTES, 0), SLOT_SPAN_MINUTES) return (clamped / SLOT_SPAN_MINUTES) * 100 } const monthCellPosition = ( rangeStart: string, startAt: string, ): { column: number; row: number } | null => { const startCivil = formatBahiaCivilDate(new Date(rangeStart)) const eventCivil = formatBahiaCivilDate(new Date(startAt)) const dayIndex = civilDateDaysBetween(startCivil, eventCivil) if (dayIndex < 0 || dayIndex > 41) return null return { column: dayIndex % 7, row: Math.floor(dayIndex / 7) } } export const ActivityAgendaSwipePreview = ({ view, direction, range, events, }: { view: ActivityAgendaView direction: 'next' | 'prev' range: ActivityAgendaAdjacentRange events: ActivityAgendaEvent[] }) => { const label = activityAgendaPeriodLabel(view, range.start, range.end, range.anchorDate) const seam = direction === 'next' ? 'activity-agenda-swipe-preview--next' : 'activity-agenda-swipe-preview--prev' const visibleEvents = events.slice(0, MAX_PREVIEW_EVENTS) return ( ) }