/**
 * Email Template Types
 * 
 * Type definitions for all email template data structures
 */

export interface BaseEmailData {
  recipientName: string;
  requestId: string;
  requestTitle?: string;
  viewDetailsLink: string;
  companyName: string;
}

export interface Form16EmailData {
  recipientName: string;
  /** Email title shown in header + subject */
  title: string;
  /** Already-sanitized HTML (escaped) message body */
  messageHtml: string;
  /** Optional: request UUID for link + context */
  requestId?: string;
  /** Optional: deep link to /request/:requestId */
  viewDetailsLink?: string;
  /** Brand name */
  companyName: string;
  /** Controls header color */
  variant?: 'info' | 'success' | 'warning' | 'error';
}

export interface RequestCreatedData extends BaseEmailData {
  initiatorName: string;
  firstApproverName: string;
  requestType: string;
  priority: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
  requestDate: string;
  requestTime: string;
  totalApprovers: number;
  expectedTAT: number;
}

export interface ApprovalRequestData extends BaseEmailData {
  approverName: string;
  initiatorName: string;
  requestDate: string;
  requestTime: string;
  requestType: string;
  requestDescription: string;
  priority: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
  customMessage?: string;
}

export interface MultiApproverRequestData extends ApprovalRequestData {
  approverLevel: number;
  totalApprovers: number;
  approversList: ApprovalChainItem[];
}

export interface ApprovalChainItem {
  name: string;
  status: 'approved' | 'pending' | 'current' | 'awaiting';
  date?: string;
  levelNumber: number;
}

export interface ApprovalConfirmationData extends BaseEmailData {
  initiatorName: string;
  approverName: string;
  approvalDate: string;
  approvalTime: string;
  requestType: string;
  approverComments?: string;
  isFinalApproval: boolean;
  nextApproverName?: string;
}

export interface RejectionNotificationData extends BaseEmailData {
  initiatorName: string;
  approverName: string;
  rejectionDate: string;
  rejectionTime: string;
  requestType: string;
  rejectionReason: string;
  isReturnedForRevision?: boolean;
}

export interface TATReminderData extends BaseEmailData {
  approverName: string;
  initiatorName: string;
  assignedDate: string;
  tatDeadline: string;
  timeRemaining: string;
  thresholdPercentage: number;  // Dynamic: 40%, 50%, 75%, 80%, etc.
  urgencyLevel?: 'low' | 'medium' | 'high';  // Based on threshold
}

export interface TATBreachedData extends BaseEmailData {
  approverName: string;
  initiatorName: string;
  priority: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
  assignedDate: string;
  tatDeadline: string;
  timeOverdue: string;
}

export interface WorkflowPausedData extends BaseEmailData {
  pausedByName: string;
  pausedDate: string;
  pausedTime: string;
  resumeDate: string;
  pauseReason: string;
}

export interface WorkflowResumedData extends BaseEmailData {
  resumedByText: string;
  resumedDate: string;
  resumedTime: string;
  pausedDuration: string;
  currentApprover: string;
  newTATDeadline: string;
  isApprover: boolean;
}

export interface ParticipantAddedData extends BaseEmailData {
  participantName: string;
  participantRole: 'Approver' | 'Spectator';
  addedByName: string;
  initiatorName: string;
  requestType: string;
  currentStatus: string;
  addedDate: string;
  addedTime: string;
  requestDescription: string;
}

export interface ApproverSkippedData extends BaseEmailData {
  skippedApproverName: string;
  skippedByName: string;
  skippedDate: string;
  skippedTime: string;
  nextApproverName: string;
  skipReason: string;
}

export interface RequestClosedData extends BaseEmailData {
  initiatorName: string;
  createdDate: string;
  closedDate: string;
  closedTime: string;
  totalDuration: string;
  conclusionRemark?: string;
  totalApprovers: number;
  totalApprovals: number;
  workNotesCount: number;
  documentsCount: number;
}

export interface SpectatorAddedData extends BaseEmailData {
  spectatorName: string;
  addedByName?: string;
  initiatorName: string;
  requestType?: string;
  currentStatus?: string;
  addedDate?: string;
  addedTime?: string;
  requestDescription?: string;
}

// Dealer Claim Specific Templates
export interface DealerProposalSubmittedData extends BaseEmailData {
  dealerName: string;
  activityName: string;
  activityType: string;
  proposalBudget: number;
  expectedCompletionDate: string;
  dealerComments?: string;
  costBreakupSummary?: string; // Summary or table of cost items
  submittedDate: string;
  submittedTime: string;
  nextApproverName?: string;
}

export interface ActivityCreatedData extends BaseEmailData {
  activityName: string;
  activityType: string;
  activityDate?: string;
  location: string;
  dealerName: string;
  dealerCode: string;
  initiatorName: string;
  departmentLeadName?: string;
  ioNumber?: string;
  createdDate: string;
  createdTime: string;
  nextSteps?: string;
}

export interface CompletionDocumentsSubmittedData extends BaseEmailData {
  dealerName: string;
  activityName: string;
  activityCompletionDate: string;
  numberOfParticipants?: number;
  totalClosedExpenses: number;
  expenseBreakdown?: string; // Summary or table of expenses
  documentsCount?: number;
  submittedDate: string;
  submittedTime: string;
  nextApproverName?: string;
}

export interface EInvoiceGeneratedData extends BaseEmailData {
  invoiceNumber: string;
  invoiceDate: string;
  dmsNumber?: string;
  invoiceAmount: number;
  dealerName: string;
  dealerCode: string;
  activityName: string;
  ioNumber?: string;
  generatedDate: string;
  generatedTime: string;
  downloadLink?: string;
}

export interface CreditNoteSentData extends BaseEmailData {
  creditNoteNumber: string;
  creditNoteDate: string;
  creditNoteAmount: number;
  dealerName: string;
  dealerCode: string;
  dealerEmail: string;
  activityName: string;
  requestNumber: string;
  reason?: string;
  invoiceNumber?: string;
  sentDate: string;
  sentTime: string;
  downloadLink?: string;
}

export interface DealerProposalRequiredData extends BaseEmailData {
  dealerName: string;
  initiatorName: string;
  activityName: string;
  activityType: string;
  activityDate?: string;
  location?: string;
  estimatedBudget?: number;
  requestDate: string;
  requestTime: string;
  requestDescription: string;
  priority: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
  tatHours?: number;
  dueDate?: string;
  customMessage?: string;
}

export interface AdditionalDocumentAddedData extends BaseEmailData {
  documentName: string;
  fileSize: string;
  addedByName: string;
  addedDate: string;
  addedTime: string;
  requestNumber?: string;
  source?: string; // 'Documents Tab' or 'Work Notes'
}

