import type {
  ApprovalEscalationTargetType,
  ApprovalTimeoutAction
} from '../types';

export interface ReminderPolicyItem {
  id: string;
  organizationId: string;
  workflowId: string;
  workflowName: string;
  stepNumber: number;
  slaHours: number;
  reminderOffsetsHours: number[];
  calendarMode: 'calendar_days';
  timeoutAction: ApprovalTimeoutAction;
  isActive: boolean;
  createdAt: string;
  updatedAt: string;
}

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

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 PendingApprovalQueueResponse {
  success: boolean;
  time: string;
  message: string;
  items: PendingApprovalQueueItem[];
  summary: {
    pending: number;
    dueToday: number;
    overdue: number;
    escalated: number;
  };
}

export interface ReminderPoliciesResponse {
  success: boolean;
  time: string;
  message: string;
  items: ReminderPolicyItem[];
}

export interface EscalationPoliciesResponse {
  success: boolean;
  time: string;
  message: string;
  items: EscalationPolicyItem[];
}

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

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

export interface ApprovalAutomationRunResponse {
  success: boolean;
  message: string;
  processedCount: number;
  processedAt: string;
}

export interface MutationSuccessResponse {
  success: boolean;
  message: string;
}
