import type { TFunction } from "i18next";

import { creditLedgerReasonLabel } from "@/modules/settlement/settlement-status-label";

export function walletStatusLabel(status: string, t: (key: string) => string): string {
  switch (status) {
    case "processing":
      return t("statusProcessing");
    case "success":
      return t("statusSuccess");
    case "failed":
      return t("statusFailed");
    case "pending_reconcile":
      return t("statusPendingReconcile");
    case "reversed":
      return t("statusReversed");
    case "manually_processed":
      return t("statusCaseClosed");
    case "posted":
      return t("statusPosted");
    default:
      return status;
  }
}

export function walletTxnBizTypeLabel(
  bizType: string,
  ledgerSource: string | null | undefined,
  t: (key: string) => string,
  tSettlement: TFunction<"settlementCenter">,
): string {
  if (ledgerSource === "credit_ledger") {
    return creditLedgerReasonLabel(bizType, tSettlement);
  }

  switch (bizType) {
    case "transfer_in":
      return t("transferIn");
    case "transfer_out":
      return t("transferOut");
    case "transfer_out_refund":
      return t("transferOutRefund");
    case "bet_deduct":
      return t("bizBetDeduct");
    case "bet_reverse":
      return t("bizBetReverse");
    case "settle_payout":
      return t("bizSettlePayout");
    case "jackpot_manual_payout":
      return t("bizJackpotPayout");
    case "settlement_adjustment":
      return t("bizSettlementAdjustment");
    default:
      return bizType;
  }
}