export type ApprovalTimeoutAction = 'none' | 'auto_reject' | 'auto_cancel' | 'auto_escalate';
export type ApprovalCalendarMode = 'calendar_days';
export type ApprovalEscalationTargetType =
  | 'manager'
  | 'requester'
  | 'explicit_user'
  | 'role'
  | 'permission_group';

export interface ApprovalReminderPolicyRecord {
  id: string;
  organizationId: string;
  workflowId: string;
  workflowName: string;
  stepNumber: number;
  slaHours: number;
  reminderOffsetsHours: number[];
  calendarMode: ApprovalCalendarMode;
  timeoutAction: ApprovalTimeoutAction;
  isActive: boolean;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
  createdBy: string;
  updatedBy: string;
}

export interface ApprovalEscalationPolicyRecord {
  id: string;
  organizationId: string;
  workflowId: string;
  workflowName: string;
  stepNumber: number;
  triggerAfterHours: number;
  targetType: ApprovalEscalationTargetType;
  targetValue: string | null;
  isActive: boolean;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
  createdBy: string;
  updatedBy: string;
}

export interface ApprovalReminderPolicyPayload {
  workflowId: string;
  stepNumber: number;
  slaHours: number;
  reminderOffsetsHours: number[];
  calendarMode?: ApprovalCalendarMode;
  timeoutAction?: ApprovalTimeoutAction;
  isActive?: boolean;
}

export interface ApprovalEscalationPolicyPayload {
  workflowId: string;
  stepNumber: number;
  triggerAfterHours: number;
  targetType: ApprovalEscalationTargetType;
  targetValue?: string | null;
  isActive?: boolean;
}

export interface PendingApprovalQueueItem {
  approvalRequestId: string;
  workflowId: string;
  workflowName: string;
  entityType: string;
  entityId: string;
  requestedBy: string;
  requestedAt: string;
  currentStep: number;
  currentStepRoleCode: string | null;
  currentStepRoleName: string | null;
  currentStepStartedAt: string;
  waitingHours: number;
  slaHours: number | null;
  remainingHours: number | null;
  dueAt: string | null;
  isDueToday: boolean;
  isOverdue: boolean;
  isEscalated: boolean;
}

export interface PendingApprovalQueueSummary {
  pending: number;
  dueToday: number;
  overdue: number;
  escalated: number;
}

export interface PendingApprovalQueueResponse {
  items: PendingApprovalQueueItem[];
  summary: PendingApprovalQueueSummary;
}
