type PaymentMethod = "Cash" | "Card" | "Credit";

type PaymentRowLike = {
  method: PaymentMethod;
  amount: string;
};

/** Button label reflecting active payment row methods (split / single). */
export function confirmPayLabel(
  rows: PaymentRowLike[],
  t: (key: string) => string
): string {
  const methods = rows
    .filter((r) => (parseFloat(r.amount.replace(/,/g, "")) || 0) > 0)
    .map((r) => r.method);
  const unique = Array.from(new Set(methods));

  if (unique.length === 0) return t("confirmPay");
  if (unique.length > 1) return t("confirmPaySplit");
  if (unique[0] === "Cash") return t("confirmPayCash");
  if (unique[0] === "Card") return t("confirmPayCard");
  return t("confirmPayCredit");
}
