/**
 * WebSocket event types for real-time updates
 */

/**
 * All supported WebSocket event names
 */
export enum WebSocketEvent {
  // Task events
  TASK_CREATED = "task:created",
  TASK_UPDATED = "task:updated",
  TASK_DELETED = "task:deleted",

  // Event events
  EVENT_CREATED = "event:created",
  EVENT_UPDATED = "event:updated",
  EVENT_DELETED = "event:deleted",

  // Project events
  PROJECT_CREATED = "project:created",
  PROJECT_UPDATED = "project:updated",
  PROJECT_DELETED = "project:deleted",
}

/**
 * Base payload interface for all WebSocket events
 */
export interface BaseEventPayload {
  id: string;
  workspaceId: string;
}

/**
 * Task payload for WebSocket events
 */
export interface TaskEventPayload extends BaseEventPayload {
  title?: string;
  status?: string;
  priority?: string;
  assigneeId?: string | null;
  projectId?: string | null;
  dueDate?: string | null;
  [key: string]: unknown;
}

/**
 * Event (calendar) payload for WebSocket events
 */
export interface CalendarEventPayload extends BaseEventPayload {
  title?: string;
  startTime?: string;
  endTime?: string;
  allDay?: boolean;
  [key: string]: unknown;
}

/**
 * Project payload for WebSocket events
 */
export interface ProjectEventPayload extends BaseEventPayload {
  name?: string;
  status?: string;
  color?: string;
  [key: string]: unknown;
}

/**
 * Delete payload - only includes the entity ID
 */
export interface DeleteEventPayload {
  id: string;
}

/**
 * WebSocket event handler callbacks
 */
export interface WebSocketCallbacks {
  onTaskCreated?: (task: TaskEventPayload) => void;
  onTaskUpdated?: (task: TaskEventPayload) => void;
  onTaskDeleted?: (payload: DeleteEventPayload) => void;
  onEventCreated?: (event: CalendarEventPayload) => void;
  onEventUpdated?: (event: CalendarEventPayload) => void;
  onEventDeleted?: (payload: DeleteEventPayload) => void;
  onProjectCreated?: (project: ProjectEventPayload) => void;
  onProjectUpdated?: (project: ProjectEventPayload) => void;
  onProjectDeleted?: (payload: DeleteEventPayload) => void;
}
