import { TFunction } from 'i18next';
import {
  AllTransactionMoidTid,
  AllTransactionSearchCl,
  AllTransactionServiceCode,
  AllTransactionStatusCode,
  CashReceiptPurposeType,
  CashReceiptTransactionType,
  CashReceiptProcessResult,
  BillingPaymentMethod,
  BillingProcessResult,
  BillingRequestStatus,
  BillingSearchType,
  EscrowDeliveryStatus,
  EscrowSearchType,
  EscrowSettlementStatus
} from '@/entities/transaction/model/types';

export const getAllTransactionMoidTidOptionsGroup = (t: TFunction) => [
  {name: t('transaction.constants.orderNumber'), value: AllTransactionMoidTid.MOID},
  {name: t('transaction.constants.tid'), value: AllTransactionMoidTid.TID},
];

export const getAllTransactionStatusCodeBtnGroup = (t: TFunction) => [
  {name: t('transaction.constants.all'), value: AllTransactionStatusCode.ALL},
  {name: t('transaction.constants.approvalComplete'), value: AllTransactionStatusCode.APPROVAL},
  {name: t('transaction.constants.totalCancel'), value: AllTransactionStatusCode.CANCEL},
  {name: t('transaction.constants.refund'), value: AllTransactionStatusCode.REFUND}
];

export const getAllTransactionServiceCodeOptionsGroup = (t: TFunction) => [
  {name: t('transaction.constants.all'), value: AllTransactionServiceCode.ALL},
  {name: t('transaction.constants.creditCard'), value: AllTransactionServiceCode.CREDIT_CARD},
  {name: t('transaction.constants.virtualAccount'), value: AllTransactionServiceCode.VIRTUAL_ACCOUNT},
  {name: t('transaction.constants.accountTransfer'), value: AllTransactionServiceCode.ACCOUNT_TRANSFER},
  {name: t('transaction.constants.accountSimpleTransfer'), value: AllTransactionServiceCode.ACCOUNT_SIMPLE_TRANSFER},
  {name: t('transaction.constants.mobilePayment'), value: AllTransactionServiceCode.MOBILE_PAYMENT},
  {name: t('transaction.constants.ssgMoney'), value: AllTransactionServiceCode.SSGMONEY},
  {name: t('transaction.constants.ssgBank'), value: AllTransactionServiceCode.SSGBANK},
  {name: t('transaction.constants.cultureLand'), value: AllTransactionServiceCode.CULT},
  {name: t('transaction.constants.tmoneyPay'), value: AllTransactionServiceCode.TMONEY},
];

export const getAllTransactionStatusCode = (t: TFunction) => [
  {
    serviceCode: '',
    list: [
      {code: '', name: t('transaction.constants.all')},
      {code: '0', name: t('transaction.constants.approvalComplete')},
      {code: '1', name: t('transaction.constants.totalCancel')},
      {code: '2', name: t('transaction.constants.refund')}
    ]
  },
  {
    serviceCode: '01',
    list: [
      {code: '', name: t('transaction.constants.all')},
      {code: '0', name: t('transaction.constants.approval')},
      {code: '1', name: t('transaction.constants.totalCancelShort')},
      {code: '2', name: t('transaction.constants.cancelShort')}
    ]
  },
  {
    serviceCode: '02',
    list: [
      {code: '', name: t('transaction.constants.all')},
      {code: '0', name: t('transaction.constants.approval')},
      {code: '1', name: t('transaction.constants.cancel')},
      {code: '2', name: t('transaction.constants.refund')},
    ]
  },
  {
    serviceCode: '03',
    list: [
      {code: '', name: t('transaction.constants.all')},
      {code: '0', name: t('transaction.constants.deposit')},
      {code: '2', name: t('transaction.constants.refund')},
      {code: '3', name: t('transaction.constants.waitingDeposit')},
      {code: '4', name: t('transaction.constants.issueCancel')},
    ]
  },
  {
    serviceCode: '05',
    list: [
      {code: '', name: t('transaction.constants.all')},
      {code: '0', name: t('transaction.constants.approval')},
      {code: '1', name: t('transaction.constants.cancel')},
      {code: '2', name: t('transaction.constants.refund')},
    ]
  },
  {
    serviceCode: '14',
    list: [
      {code: '', name: t('transaction.constants.all')},
      {code: '0', name: t('transaction.constants.approval')},
      {code: '1', name: t('transaction.constants.cancel')},
      {code: '2', name: t('transaction.constants.refund')},
    ]
  },
  {
    serviceCode: '21',
    list: [
      {code: '', name: t('transaction.constants.all')},
      {code: '0', name: t('transaction.constants.approval')},
      {code: '1', name: t('transaction.constants.cancel')},
      {code: '2', name: t('transaction.constants.refund')},
    ]
  },
  {
    serviceCode: '24',
    list: [
      {code: '', name: t('transaction.constants.all')},
      {code: '0', name: t('transaction.constants.approval')},
      {code: '1', name: t('transaction.constants.cancel')},
      {code: '2', name: t('transaction.constants.refund')},
    ]
  },
  {
    serviceCode: '26',
    list: [
      {code: '', name: t('transaction.constants.all')},
      {code: '0', name: t('transaction.constants.approval')},
      {code: '1', name: t('transaction.constants.cancel')},
      {code: '2', name: t('transaction.constants.refund')},
    ]
  },
  {
    serviceCode: '31',
    list: [
      {code: '', name: t('transaction.constants.all')},
      {code: '0', name: t('transaction.constants.approval')},
      {code: '1', name: t('transaction.constants.totalCancelShort')},
      {code: '2', name: t('transaction.constants.cancelShort')},
    ]
  },
];

export const AllTransactionCardBankCodeOptionsGroup = {

};



export const getCashReceiptPurposeTypeBtnGroup = (t: TFunction) => [
  {name: t('transaction.constants.all'), value: CashReceiptPurposeType.ALL},
  {name: t('transaction.handWrittenIssuance.incomeDeduction'), value: CashReceiptPurposeType.INCOME_DEDUCTION},
  {name: t('transaction.handWrittenIssuance.expenseProof'), value: CashReceiptPurposeType.EXPENSE_PROOF},
];

export const getCashReceiptTransactionTypeBtnGroup = (t: TFunction) => [
  {name: t('transaction.constants.all'), value: CashReceiptTransactionType.ALL},
  {name: t('transaction.constants.approval'), value: CashReceiptTransactionType.APPROVAL},
  {name: t('transaction.constants.cancel'), value: CashReceiptTransactionType.CANCEL},
];

export const getCashReceiptProcessResultBtnGroup = (t: TFunction) => [
  {name: t('transaction.constants.all'), value: CashReceiptProcessResult.ALL},
  {name: t('transaction.constants.request'), value: CashReceiptProcessResult.REQUEST},
  {name: t('transaction.constants.requestCancel'), value: CashReceiptProcessResult.REQUEST_CANCEL},
  {name: t('transaction.constants.requestComplete'), value: CashReceiptProcessResult.REQUEST_COMPLETE},
  {name: t('transaction.constants.issueComplete'), value: CashReceiptProcessResult.ISSUE_COMPLETE},
  {name: t('transaction.constants.requestFail'), value: CashReceiptProcessResult.REQUEST_FAIL},
  {name: t('transaction.constants.issueFail'), value: CashReceiptProcessResult.ISSUE_FAIL},
];

export const getEscrowSearchTypeOptionsGroup = (t: TFunction) => [
  {name: t('transaction.constants.orderNumber'), value: EscrowSearchType.ORDER_NUMBER },
  {name: t('transaction.constants.tid'), value: EscrowSearchType.TID }
];

export const getEscrowDeliveryStatusBtnGroup = (t: TFunction) => [
  {name: t('transaction.constants.all'), value: EscrowDeliveryStatus.ALL},
  {name: t('transaction.constants.paymentComplete'), value: EscrowDeliveryStatus.PAY_COMPLETE},
  {name: t('transaction.constants.deliveryRegistration'), value: EscrowDeliveryStatus.DELIVERY_INSERT},
  {name: t('transaction.constants.deliveryComplete'), value: EscrowDeliveryStatus.DELIVERY_COMPLETE},
  {name: t('transaction.constants.purchaseConfirm'), value: EscrowDeliveryStatus.PURCHASE_CONFIRM},
  {name: t('transaction.constants.purchaseReject'), value: EscrowDeliveryStatus.PURCHASE_REJECT},
  {name: t('transaction.constants.refundProcessing'), value: EscrowDeliveryStatus.RETURN_PROCESSING},
  {name: t('transaction.constants.depositComplete'), value: EscrowDeliveryStatus.DEPOSIT_COMPLETE},
];

export const getEscrowSettlementStatusBtnGroup = (t: TFunction) => [
  {name: t('transaction.constants.all'), value: EscrowSettlementStatus.ALL},
  {name: t('transaction.constants.creditCard'), value: EscrowSettlementStatus.CREDIT_CARD},
  {name: t('transaction.constants.virtualAccount'), value: EscrowSettlementStatus.REAL_ACCOUNT},
  {name: t('transaction.constants.accountTransfer'), value: EscrowSettlementStatus.ACCOUNT_TRANSFER},
];

export const getBillingSearchTypeOptionsGroup = (t: TFunction) => [
  {name: t('transaction.constants.orderNumber'), value: BillingSearchType.ORDER_NUMBER },
  {name: t('transaction.constants.tid'), value: BillingSearchType.TID }
];

export const getBillingRequestStatusBtnGroup = (t: TFunction) => [
  {name: t('transaction.constants.all'), value: BillingRequestStatus.ALL},
  {name: t('transaction.constants.inProgress'), value: BillingRequestStatus.IN_PROGRESS},
  {name: t('transaction.constants.success'), value: BillingRequestStatus.SUCCESS},
  {name: t('transaction.constants.requestCancel'), value: BillingRequestStatus.REQUEST_CANCEL},
];

export const getBillingProcessResultBtnGroup = (t: TFunction) => [
  {name: t('transaction.constants.all'), value: BillingProcessResult.ALL},
  {name: t('transaction.constants.success'), value: BillingProcessResult.SUCCESS},
  {name: t('transaction.constants.failure'), value: BillingProcessResult.FAILURE},
];

export const getBillingPaymentMethodBtnGroup = (t: TFunction) => [
  {name: t('transaction.constants.all'), value: BillingPaymentMethod.ALL},
  {name: t('transaction.constants.creditCard'), value: BillingPaymentMethod.CREDIT_CARD},
  {name: t('transaction.constants.virtualAccount'), value: BillingPaymentMethod.VIRTUAL_ACCOUNT},
  {name: t('transaction.constants.mobilePayment'), value: BillingPaymentMethod.MOBILE_PAYMENT},
];

export const getPaymentMethodName = (t: TFunction, paymentMethod?: string): string => {
  if (!paymentMethod) return '';

  const methodMap: Record<string, string> = {
    '신용카드': t('transaction.constants.creditCard'),
    '가상계좌': t('transaction.constants.virtualAccount'),
    '계좌이체': t('transaction.constants.accountTransfer'),
    '간편계좌이체': t('transaction.constants.accountSimpleTransfer'),
    '휴대폰': t('transaction.constants.mobilePayment'),
    'SSG머니': t('transaction.constants.ssgMoney'),
    'SSG은행계좌': t('transaction.constants.ssgBank'),
    '문화상품권': t('transaction.constants.cultureLand'),
    '티머니페이': t('transaction.constants.tmoneyPay'),
    'Credit Card': t('transaction.constants.creditCard'),
    'Virtual Account': t('transaction.constants.virtualAccount'),
    'Account Transfer': t('transaction.constants.accountTransfer'),
    'Simple Account Transfer': t('transaction.constants.accountSimpleTransfer'),
    'Mobile Payment': t('transaction.constants.mobilePayment'),
    'SSG Money': t('transaction.constants.ssgMoney'),
    'SSG Bank Account': t('transaction.constants.ssgBank'),
    'Culture Voucher': t('transaction.constants.cultureLand'),
    'Tmoney Pay': t('transaction.constants.tmoneyPay'),
  };

  return methodMap[paymentMethod] || paymentMethod;
};
