// Frontend mirror of selected backend enums (backend/src/constants.js).
// Keep in sync when new values are added on the server.

// Pairing failure cause tags — used by the Failed Pairings screen filter.
export const PairingFailureCause = Object.freeze({
  NO_MITRA_AVAILABLE: 'no_mitra_available',
  ALL_MITRAS_REJECTED: 'all_mitras_rejected',
  TARGETED_MITRA_OFFLINE: 'targeted_mitra_offline',
  TARGETED_MITRA_REJECTED: 'targeted_mitra_rejected',
  TARGETED_MITRA_TIMEOUT: 'targeted_mitra_timeout',
  PAYMENT_SESSION_EXPIRED: 'payment_session_expired',
  CUSTOMER_CANCELLED: 'customer_cancelled',
  EXTENSION_REJECTED: 'extension_rejected',
  EXTENSION_SAFEGUARD_TRIPPED: 'extension_safeguard_tripped',
})

export const PairingFailureCauseLabel = Object.freeze({
  [PairingFailureCause.NO_MITRA_AVAILABLE]: 'No mitra available',
  [PairingFailureCause.ALL_MITRAS_REJECTED]: 'All mitras rejected',
  [PairingFailureCause.TARGETED_MITRA_OFFLINE]: 'Targeted mitra offline',
  [PairingFailureCause.TARGETED_MITRA_REJECTED]: 'Targeted mitra rejected',
  [PairingFailureCause.TARGETED_MITRA_TIMEOUT]: 'Targeted mitra timeout',
  [PairingFailureCause.PAYMENT_SESSION_EXPIRED]: 'Payment session expired',
  [PairingFailureCause.CUSTOMER_CANCELLED]: 'Customer cancelled',
  [PairingFailureCause.EXTENSION_REJECTED]: 'Extension rejected',
  [PairingFailureCause.EXTENSION_SAFEGUARD_TRIPPED]: 'Extension safeguard tripped',
})

// Operator actions on a failed-pairing row.
export const PairingFailureOperatorAction = Object.freeze({
  REFUNDED: 'refunded',
  CREDITED: 'credited',
  NO_ACTION: 'no_action',
})

export const PairingFailureOperatorActionLabel = Object.freeze({
  [PairingFailureOperatorAction.REFUNDED]: 'Refunded',
  [PairingFailureOperatorAction.CREDITED]: 'Credited',
  [PairingFailureOperatorAction.NO_ACTION]: 'No Action',
})

// Default action when the mitra fails to respond to an extension request in time.
export const ExtensionTimeoutAction = Object.freeze({
  AUTO_APPROVE: 'auto_approve',
  AUTO_REJECT: 'auto_reject',
})

// Session / pricing modes. Mirrors backend `SessionMode` enum.
export const SessionMode = Object.freeze({
  CHAT: 'chat',
  CALL: 'call',
})

// Mirror of backend error codes returned on optimistic-lock conflict / validation.
export const ApiErrorCode = Object.freeze({
  STALE_WRITE: 'STALE_WRITE',
  VALIDATION: 'VALIDATION',
  NOT_FOUND: 'NOT_FOUND',
})
