Major refactorering to get a hold on all these events

This commit is contained in:
Janus Knudsen 2025-08-09 00:31:44 +02:00
parent 2a766cf685
commit 59b3c64c55
18 changed files with 1901 additions and 357 deletions

View file

@ -1,11 +1,16 @@
// Calendar type definitions
export type ViewType = 'day' | 'week' | 'month';
export type CalendarView = ViewType; // Alias for compatibility
// Time period view types (how much time to display)
export type ViewPeriod = 'day' | 'week' | 'month';
export type CalendarType = 'date' | 'resource';
// Calendar mode types (how to organize the data)
export type CalendarMode = 'date' | 'resource';
export type EventType = 'meeting' | 'meal' | 'work' | 'milestone';
// Legacy aliases for backwards compatibility
export type DateViewType = ViewPeriod;
export type ViewType = DateViewType;
export type CalendarView = ViewType;
export type CalendarType = CalendarMode;
export type SyncStatus = 'synced' | 'pending' | 'error';
@ -27,37 +32,22 @@ export interface CalendarEvent {
title: string;
start: string; // ISO 8601
end: string; // ISO 8601
type: EventType;
type: string; // Flexible event type - can be any string value
allDay: boolean;
syncStatus: SyncStatus;
// Resource information (only present in resource calendar mode)
resourceName?: string;
resourceDisplayName?: string;
resourceEmployeeId?: string;
resource?: {
name: string;
displayName: string;
employeeId: string;
};
recurringId?: string;
resources?: string[];
metadata?: Record<string, any>;
}
export interface CalendarConfig {
// View settings
view: ViewType;
weekDays: number; // 4-7 days for week view
firstDayOfWeek: number; // 0 = Sunday, 1 = Monday
// Time settings
dayStartHour: number; // Calendar starts at hour
dayEndHour: number; // Calendar ends at hour
workStartHour: number; // Work hours start
workEndHour: number; // Work hours end
snapInterval: number; // Minutes: 5, 10, 15, 30, 60
// Display settings
hourHeight: number; // Pixels per hour
showCurrentTime: boolean;
showWorkHours: boolean;
fitToWidth: boolean; // Fit columns to calendar width vs horizontal scroll
// Scrollbar styling
scrollbarWidth: number; // Width of scrollbar in pixels
scrollbarColor: string; // Scrollbar thumb color
@ -116,7 +106,7 @@ export interface GridPosition {
export interface Period {
start: string;
end: string;
view: ViewType;
mode?: CalendarMode; // Optional: which calendar mode this period is for
}
export interface EventData {
@ -124,7 +114,30 @@ export interface EventData {
meta: {
start: string;
end: string;
view: ViewType;
total: number;
mode?: CalendarMode; // Which calendar mode this data is for
};
}
}
/**
* Context interfaces for different calendar modes
*/
export interface DateModeContext {
mode: 'date';
currentWeek: Date;
period: ViewPeriod;
weekDays: number;
firstDayOfWeek: number;
}
export interface ResourceModeContext {
mode: 'resource';
selectedDate: Date;
resources: Resource[];
maxResources: number;
}
/**
* Union type for type-safe mode contexts
*/
export type CalendarModeContext = DateModeContext | ResourceModeContext;