/**
 * Type definitions for CreateRequest module
 */

import { FormData, RequestTemplate } from '@/hooks/useCreateRequestForm';

export interface Participant {
  userId?: string;
  userEmail: string;
  userName: string;
  participantType: 'INITIATOR' | 'APPROVER' | 'SPECTATOR';
  canComment: boolean;
  canViewDocuments: boolean;
  canDownloadDocuments: boolean;
  notificationEnabled: boolean;
  addedBy?: string;
}

export interface ApprovalLevel {
  levelNumber: number;
  levelName: string;
  approverId: string;
  approverEmail: string;
  approverName: string;
  tatHours: number;
  isFinalApprover: boolean;
}

export interface Approver {
  userId?: string;
  email: string;
  name?: string;
  tat?: number | string;
  tatType?: 'hours' | 'days';
  level?: number;
}

export interface Spectator {
  id?: string;
  userId?: string;
  email: string;
  name: string;
}

export interface CreateWorkflowPayload {
  templateId: string | null;
  templateType: 'CUSTOM' | 'TEMPLATE';
  title: string;
  description: string;
  priorityUi: 'express' | 'standard';
  approverCount: number;
  approvers: Array<{
    userId: string;
    email: string;
    name?: string;
    tat: number | string;
    tatType: 'hours' | 'days';
  }>;
  spectators: Array<{
    userId: string;
    name: string;
    email: string;
  }>;
  ccList: Array<{
    id?: string;
    name: string;
    email: string;
  }>;
  participants: Participant[];
  isDraft?: boolean;
}

export interface UpdateWorkflowPayload {
  title: string;
  description: string;
  priority: 'EXPRESS' | 'STANDARD';
  approvalLevels: ApprovalLevel[];
  participants: Participant[];
  deleteDocumentIds?: string[];
  isDraft?: boolean;
}

export interface ValidationModalState {
  open: boolean;
  type: 'error' | 'self-assign' | 'not-found';
  email: string;
  message: string;
}

export interface PolicyViolationModalState {
  open: boolean;
  violations: Array<{
    type: string;
    message: string;
    currentValue?: number;
    maxValue?: number;
  }>;
}

export interface DocumentErrorModalState {
  open: boolean;
  errors: Array<{
    fileName: string;
    reason: string;
  }>;
}

export interface PreviewDocument {
  fileName: string;
  fileType: string;
  fileUrl: string;
  fileSize?: number;
  file?: File;
  documentId?: string;
}

export interface SubmissionContext {
  formData: FormData;
  selectedTemplate: RequestTemplate | null;
  documents: File[];
  documentsToDelete: string[];
  user: any;
  isEditing: boolean;
  editRequestId: string;
}

