Skip to content

Commit

Permalink
format amount
Browse files Browse the repository at this point in the history
  • Loading branch information
surekhaw committed Oct 11, 2024
1 parent 37176d3 commit 72fc8ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/modal/v2/parts/views/ProductList/Content.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down Expand Up @@ -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}
Expand Down
5 changes: 3 additions & 2 deletions src/server/message/parts/MutatedText.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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);
});
}
Expand Down

0 comments on commit 72fc8ed

Please sign in to comment.