// ─── Approval Workflow Level ────────────────────────────────────

export interface ApprovalWorkflowLevel {
  id: number;
  workflow_id: number;
  level: number;
  min_amount: string;
  max_amount: string;
  approver_type: string;
  role_id: number | null;
  user_id: number | null;
  auto_approve: boolean;
  role?: {
    id: number;
    name: string;
  } | null;
  user?: {
    id: number;
    name: string;
  } | null;
}

export interface ApprovalWorkflowLevelPayload {
  level: number;
  min_amount?: number;
  max_amount?: number;
  approver_type: string;
  role_id?: number | null;
  user_id?: number | null;
  auto_approve?: boolean;
}

// ─── Approval Workflow ──────────────────────────────────────────

export interface ApprovalWorkflow {
  id: number;
  name: string;
  name_ar: string | null;
  document_type: string;
  is_active: boolean;
  levels: ApprovalWorkflowLevel[];
  created_at: string;
  updated_at: string;
}

export interface CreateApprovalWorkflow {
  name: string;
  name_ar?: string | null;
  document_type: string;
  is_active?: boolean;
  levels?: ApprovalWorkflowLevelPayload[];
}

export interface UpdateApprovalWorkflow extends Partial<CreateApprovalWorkflow> {}

// ─── Approval Log ───────────────────────────────────────────────

export interface ApprovalLog {
  id: number;
  document_type: string;
  document_id: number;
  level: number;
  user_id: number;
  action: string;
  comments: string | null;
  user?: {
    id: number;
    name: string;
  } | null;
  created_at: string;
  updated_at: string;
}
