From 72fc8ed0cc6ebcda69cd34214bba2fcf0641cd69 Mon Sep 17 00:00:00 2001 From: suweinberg <suweinberg@paypal.com> Date: Fri, 11 Oct 2024 10:37:47 -0700 Subject: [PATCH] format amount --- src/components/modal/v2/parts/views/ProductList/Content.jsx | 3 ++- src/server/message/parts/MutatedText.jsx | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/modal/v2/parts/views/ProductList/Content.jsx b/src/components/modal/v2/parts/views/ProductList/Content.jsx index 254b4ab639..b6151b3dfd 100644 --- a/src/components/modal/v2/parts/views/ProductList/Content.jsx +++ b/src/components/modal/v2/parts/views/ProductList/Content.jsx @@ -2,6 +2,7 @@ import { h, Fragment } from 'preact'; import { useServerData } from '../../../lib'; import Tile from '../../Tile'; +import { currencyFormat } from '../../../lib/hooks/currency'; import styles from './styles.scss'; export const ProductList = ({ content: { instructions, disclosure, productTiles }, useV5Design, setViewName }) => { @@ -43,7 +44,7 @@ export const ProductList = ({ content: { instructions, disclosure, productTiles availableTiles.credit?.map(({ header, body, viewName }) => ( <Tile header={header} - body={body} + body={currencyFormat(body)} viewName={viewName} setViewName={setViewName} useV5Design={useV5Design} diff --git a/src/server/message/parts/MutatedText.jsx b/src/server/message/parts/MutatedText.jsx index 1b158697a6..5e63446f25 100644 --- a/src/server/message/parts/MutatedText.jsx +++ b/src/server/message/parts/MutatedText.jsx @@ -40,7 +40,7 @@ const MutatedText = ({ tagData, options }) => { // truncate zeros for non-qualifying messages const matchNQ = formattedStr.match( // eslint-disable-next-line security/detect-unsafe-regex - /((\$|£)?(\d{1,5}(\.|,)){1,3}00(€|(.|\s*)EUR)?(-|(\s(\D{1,3})\s))(\$|£)?(\d{1,5}(\.|,|\s)){1,3}00(€|(.|\s*)EUR)?)/g + /((\$|£)?(\d{1,5}(\.|,)){1,3}00(€|(.|\s*)EUR)?((-|(\s(\D{1,3})\s))(\$|£)?(\d{1,5}(\.|,|\s)){1,3}00(€|(.|\s*)EUR)?|\+))/g ); if (matchNQ !== null) { matchNQ.forEach(foundString => { @@ -49,7 +49,8 @@ const MutatedText = ({ tagData, options }) => { .replace(/(\.|,)00$/g, '') .replace(/(\.|,)00€/g, '€') .replace(/(\.|,)00(.|\s*)EUR/g, '€') - .replace(/(\s*EUR)/g, '€'); + .replace(/(\s*EUR)/g, '€') + .replace(/(\.|,)00(\+)/g, '+'); formattedStr = formattedStr.replace(foundString, filteredString); }); }