Skip to content

Commit

Permalink
fix: [IOBP-1037] Remove asterisks from card transaction info (#6484)
Browse files Browse the repository at this point in the history
## Short description
This pull request add a new utility function and its integration into
the `PaymentsBizEventsTransactionInfoSection` component to handle the
removal of asterisks from payment information


## List of changes proposed in this pull request
- Add `removeAsterisks` function that replaces asterisks in a given
string with an empty string
- Apply the new `removeAsterisks` utility function to the wallet
information to remove asterisks from the blurred number display

## How to test
- Mock a `blurredNumber` with some `*` and the card number at the end
- Verify that `*` are not render
  • Loading branch information
LeleDallas authored Dec 3, 2024
1 parent d81d26d commit 4713bd2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { clipboardSetStringWithFeedback } from "../../../../utils/clipboard";
import { format } from "../../../../utils/dates";
import { capitalizeTextName } from "../../../../utils/strings";
import { WalletTransactionReceiptDivider } from "../../transaction/components/WalletTransactionReceiptDivider";
import { getPayerInfoLabel } from "../utils";
import { getPayerInfoLabel, removeAsterisks } from "../utils";

type PaymentsBizEventsTransactionInfoSectionProps = {
transaction?: NoticeDetailResponse;
Expand Down Expand Up @@ -196,13 +196,15 @@ const renderPaymentMethod = (walletInfo: WalletInfo) => {
return (
<ListItemInfo
label={I18n.t("transaction.details.info.paymentMethod")}
value={`${capitalize(walletInfo.brand)} •••• ${
value={`${capitalize(walletInfo.brand)} •••• ${removeAsterisks(
walletInfo.blurredNumber
}`}
)}`}
accessibilityLabel={I18n.t("wallet.methodDetails.a11y.credit.hpan", {
circuit: walletInfo.brand,
// we space the hpan to make the screen reader read it digit by digit
spacedHpan: walletInfo.blurredNumber.split("").join(" ")
spacedHpan: removeAsterisks(walletInfo.blurredNumber)
.split("")
.join(" ")
})}
paymentLogoIcon={walletInfo.brand as IOLogoPaymentType}
/>
Expand Down
3 changes: 3 additions & 0 deletions ts/features/payments/bizEventsTransaction/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,6 @@ export const restoreTransactionAtIndex = (
restoreItem,
...transactions.slice(index)
]);

export const removeAsterisks = (text: string): string =>
text.replace(/\*/g, "");

0 comments on commit 4713bd2

Please sign in to comment.