Normalize user-facing payment method to cash/card/eft/voucher
Per feedback, stop trying to surface every gateway-reported wallet type (apple_pay, google_pay, yoco, ...) as its own filter/display value on the user payment history page. Both /mypayments and /mypayments/methods now fold anything outside the four manual-entry methods into "card", both in the returned data and in the filter query, so Apple Pay/Google Pay payments show up under Card. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,24 +18,18 @@ interface PaymentItem {
|
||||
|
||||
const formatRand = (n: number) => `R ${Math.abs(n).toFixed(2)}`;
|
||||
|
||||
// Payment.method is free-text — online payments arrive tagged with whatever wallet type the
|
||||
// gateway reports (e.g. apple_pay, google_pay), not just the manual-entry methods below.
|
||||
// The API normalizes Payment.method to this set before it ever reaches the dashboard — any
|
||||
// gateway-reported wallet type (apple_pay, google_pay, yoco, ...) is folded into "card".
|
||||
const METHOD_LABELS: Record<string, string> = {
|
||||
cash: "Cash",
|
||||
card: "Card",
|
||||
eft: "EFT",
|
||||
voucher: "Voucher",
|
||||
apple_pay: "Apple Pay",
|
||||
google_pay: "Google Pay",
|
||||
};
|
||||
|
||||
const formatMethod = (method: string | null | undefined) => {
|
||||
if (!method) return "Payment";
|
||||
if (METHOD_LABELS[method]) return METHOD_LABELS[method];
|
||||
return method
|
||||
.replace(/[_-]+/g, " ")
|
||||
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
||||
.replace(/\b\w/g, c => c.toUpperCase());
|
||||
return METHOD_LABELS[method] || method;
|
||||
};
|
||||
|
||||
export default function UserPaymentsPage() {
|
||||
|
||||
Reference in New Issue
Block a user