61 lines
2.0 KiB
TypeScript
61 lines
2.0 KiB
TypeScript
import type { VMState } from "../index.js";
|
|
|
|
/**
|
|
* AK-P16a · calendar view view-model (M25 Block B). Pure (DoD A.3). Renders the
|
|
* caller's OWN events from all sources with a source marker (DoD 5): HiveGrid
|
|
* internal (booking/projekt/plantafel) and external-synced (Google). Bespoke grid
|
|
* UI waits on David D-P16 — this VM feeds both the functional shell now and the
|
|
* grid later. External event titles are the OWNER's own here (their own calendar);
|
|
* cross-user leak-protection lives at the availability boundary, not this view.
|
|
*/
|
|
|
|
export type CalendarEventSourceMarker = "hivegrid_internal" | "external_synced";
|
|
|
|
export interface CalendarViewEventRow {
|
|
readonly id: string;
|
|
readonly source: CalendarEventSourceMarker;
|
|
/** i18n key for the source marker label/colour (e.g. `calendar.source.external_synced`). */
|
|
readonly sourceKey: string;
|
|
readonly title: string;
|
|
/** ISO timestamps. */
|
|
readonly startsAt: string;
|
|
readonly endsAt: string;
|
|
readonly isAllDay: boolean;
|
|
/** Set for HiveGrid-internal events linked to a booking/projekt/plantafel. */
|
|
readonly linkType: string | null;
|
|
}
|
|
|
|
export interface CalendarViewData {
|
|
readonly events: readonly CalendarViewEventRow[];
|
|
/** Inclusive ISO date window the loader resolved the events for. */
|
|
readonly rangeStart: string;
|
|
readonly rangeEnd: string;
|
|
readonly emptyHeadlineKey: string;
|
|
readonly emptyBodyKey: string;
|
|
}
|
|
|
|
export type CalendarViewVM = VMState<CalendarViewData>;
|
|
|
|
export function calendarSourceKey(source: CalendarEventSourceMarker): string {
|
|
return `calendar.source.${source}`;
|
|
}
|
|
|
|
export interface BuildCalendarViewInput {
|
|
readonly events: readonly CalendarViewEventRow[];
|
|
readonly rangeStart: string;
|
|
readonly rangeEnd: string;
|
|
}
|
|
|
|
export function buildCalendarViewVM(input: BuildCalendarViewInput): CalendarViewVM {
|
|
return {
|
|
status: "ready",
|
|
data: {
|
|
events: input.events,
|
|
rangeStart: input.rangeStart,
|
|
rangeEnd: input.rangeEnd,
|
|
emptyHeadlineKey: "calendar.view.empty.headline",
|
|
emptyBodyKey: "calendar.view.empty.body",
|
|
},
|
|
};
|
|
}
|