export interface ApprovalWorkflowRecord {
  id: string;
  organizationId: string;
  code: string;
  name: string;
  entityType: string;
  isActive: boolean;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
}

export interface ApprovalStepRecord {
  id: string;
  organizationId: string;
  workflowId: string;
  stepNumber: number;
  roleCode: string;
  roleName: string;
  isRequired: boolean;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
}

export interface ApprovalWorkflowListItem extends ApprovalWorkflowRecord {
  stepCount: number;
}

export interface ApprovalWorkflowDetail extends ApprovalWorkflowRecord {
  steps: ApprovalStepRecord[];
}

export interface ApprovalRequestRecord {
  id: string;
  organizationId: string;
  workflowId: string;
  entityType: string;
  entityId: string;
  currentStep: number;
  status: string;
  requestedBy: string;
  requestedAt: string;
  completedAt: string | null;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
}

export interface ApprovalActionRecord {
  id: string;
  organizationId: string;
  approvalRequestId: string;
  stepNumber: number;
  action: string;
  remark: string | null;
  actedBy: string;
  actedAt: string;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
}

export interface ApprovalListItem extends ApprovalRequestRecord {
  workflowCode: string;
  workflowName: string;
  currentStepRoleCode: string | null;
  currentStepRoleName: string | null;
  requestedByName: string | null;
  entityCode: string | null;
  entityTitle: string | null;
}

export interface ApprovalTimelineItem extends ApprovalActionRecord {
  actorName: string | null;
}

export interface ApprovalDetailRecord {
  request: ApprovalRequestRecord;
  workflow: ApprovalWorkflowRecord;
  steps: ApprovalStepRecord[];
  currentStep: ApprovalStepRecord | null;
  timeline: ApprovalTimelineItem[];
  entityCode: string | null;
  entityTitle: string | null;
}

export interface ApprovalFilters {
  page?: number;
  limit?: number;
  search?: string;
  status?: string;
  entityType?: string;
  entityId?: string;
  sort?: string;
}

export interface SubmitApprovalPayload {
  workflowCode?: string;
  entityType: string;
  entityId: string;
  remark?: string;
}

export interface ApprovalActionPayload {
  remark?: string;
}

export interface ApprovalWorkflowMutationPayload {
  code: string;
  name: string;
  entityType: string;
  isActive?: boolean;
}

export interface ApprovalStepMutationPayload {
  stepNumber: number;
  roleCode: string;
  roleName: string;
  isRequired?: boolean;
}

export interface ApprovalListResponse {
  success: boolean;
  time: string;
  message: string;
  totalItems: number;
  offset: number;
  limit: number;
  items: ApprovalListItem[];
}

export interface ApprovalDetailResponse {
  success: boolean;
  time: string;
  message: string;
  approval: ApprovalDetailRecord;
}

export interface ApprovalWorkflowListResponse {
  success: boolean;
  time: string;
  message: string;
  items: ApprovalWorkflowListItem[];
}

export interface ApprovalWorkflowDetailResponse {
  success: boolean;
  time: string;
  message: string;
  workflow: ApprovalWorkflowDetail;
}

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