// Type definitions for Royal Enfield Approval Portal

export type Priority = 'express' | 'urgent' | 'standard';
export type Status = 'pending' | 'in-review' | 'approved' | 'rejected' | 'cancelled' | 'paused';
export type ApprovalStatus = 'pending' | 'waiting' | 'approved' | 'rejected' | 'cancelled' | 'paused';

export interface Initiator {
  name: string;
  role: string;
  department: string;
  email: string;
  phone: string;
  avatar: string;
}

export interface ApprovalStep {
  step: number;
  approver: string;
  role: string;
  status: ApprovalStatus;
  tatHours: number;
  elapsedHours?: number;
  actualHours?: number;
  assignedAt: string | null;
  comment: string | null;
  timestamp: string | null;
  description?: string;
  reminderHistory?: ReminderHistoryItem[];
}

export interface ReminderHistoryItem {
  type: 'auto' | 'manual';
  sentAt: string;
  sentBy: string;
}

export interface Document {
  name: string;
  size: string;
  type: string;
  uploadedBy: string;
  uploadedAt: string;
}

export interface Spectator {
  name: string;
  role: string;
  avatar: string;
}

export interface AuditTrailItem {
  type: string;
  action: string;
  details: string;
  user: string;
  timestamp: string;
}

export interface PauseInfo {
  isPaused: boolean;
  pausedAt?: string;
  pausedBy?: {
    userId: string;
    email: string;
    name: string;
  };
  pauseReason?: string;
  pauseResumeDate?: string;
  level?: {
    levelId: string;
    levelNumber: number;
    approverName: string;
  };
}

export interface BaseRequest {
  id: string;
  title: string;
  description: string;
  category: string;
  subcategory: string;
  status: Status;
  priority: Priority;
  amount: string;
  slaProgress: number;
  slaRemaining: string;
  slaEndDate: string;
  currentStep: number;
  totalSteps: number;
  initiator: Initiator;
  department: string;
  createdAt: string;
  updatedAt: string;
  dueDate: string;
  conclusionRemark: string;
  approvalFlow: ApprovalStep[];
  documents: Document[];
  spectators: Spectator[];
  auditTrail: AuditTrailItem[];
  tags: string[];
  pauseInfo?: PauseInfo;
}

export interface CustomRequest extends BaseRequest {
  template: 'custom';
  currentApprover?: string;
  approverLevel?: string;
  submittedDate?: string;
  estimatedCompletion?: string;
}

export interface ClaimDetails {
  activityName: string;
  activityType: string;
  activityDate: string;
  location: string;
  dealerCode: string;
  dealerName: string;
  dealerEmail: string;
  dealerPhone: string;
  dealerAddress: string;
  requestDescription: string;
  estimatedBudget: string;
  periodStart: string;
  periodEnd: string;
}

export interface ClaimManagementRequest extends BaseRequest {
  template: 'claim-management';
  templateType: 'claim-management';
  templateName: string;
  claimDetails: ClaimDetails;
}

export type Request = CustomRequest | ClaimManagementRequest;

export interface DealerInfo {
  code: string;
  name: string;
  email: string;
  phone: string;
  address: string;
  city: string;
  state: string;
  region: string;
  managerName: string;
}

export interface RequestFormData {
  title: string;
  description: string;
  category: string;
  subcategory: string;
  priority: Priority;
  budget?: string;
  department: string;
  initiatorRole?: string;
  approvers?: Array<{
    name?: string;
    email: string;
    role?: string;
    level?: number;
    tat?: number | string;
  }>;
  spectators?: Array<{
    name?: string;
    email: string;
    role?: string;
    department?: string;
  }>;
  tags?: string[];
  templateType?: string;
}

export interface ClaimFormData {
  activityName: string;
  activityType: string;
  activityDate: string;
  location: string;
  dealerCode: string;
  dealerName: string;
  dealerEmail?: string;
  dealerPhone?: string;
  dealerAddress?: string;
  requestDescription: string;
  estimatedBudget?: string;
  periodStartDate: string;
  periodEndDate: string;
  workflowSteps?: ApprovalStep[];
}

