import { isStaging, QA_CUSTOM_DEV_INSTANCE_ID } from 'src/constants/env';

import {
  EXPENSE_AMOUNT,
  PANALAB_INSTANCE_ID,
  panalabLimitForms,
  panalabSpecialForms,
  TRAVEL_EXPENSES_TOTAL_AMOUNT,
} from './constants';

export const isTestingInstance = (instanceId: number) =>
  isStaging && instanceId === QA_CUSTOM_DEV_INSTANCE_ID;

export const isPanalabSpecialForm = (instanceId: number, formName: string) =>
  panalabSpecialForms.includes(formName) &&
  (instanceId === PANALAB_INSTANCE_ID || isTestingInstance(instanceId));

export const isPanalabSpecialLimitForm = (
  instanceId: number,
  formName: string,
) =>
  panalabLimitForms.includes(formName) &&
  (instanceId === PANALAB_INSTANCE_ID || isTestingInstance(instanceId));

export const isViaticumAmountField = (
  description: string,
  instanceId: number,
) =>
  description.startsWith(EXPENSE_AMOUNT) &&
  (instanceId === PANALAB_INSTANCE_ID || isTestingInstance(instanceId));

export const isViaticumTotalAmountField = (
  description: string,
  instanceId: number,
) =>
  description.startsWith('Monto Total de') &&
  (instanceId === PANALAB_INSTANCE_ID || isTestingInstance(instanceId));

export const isViaticumFormTotalAmount = (description: string) =>
  description === TRAVEL_EXPENSES_TOTAL_AMOUNT;
