0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Updated number formatter to use locale method

no refs

Updates number formatter to use native `toLocaleString` instead of custom regex
This commit is contained in:
Rish 2021-03-08 22:59:13 +05:30
parent 3067456a0e
commit 2e41b24240

View file

@ -192,7 +192,10 @@ export const getCurrencySymbol = (currency) => {
}; };
export const formatNumber = (amount) => { export const formatNumber = (amount) => {
return amount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); if (amount === undefined || amount === null) {
return '';
}
return amount.toLocaleString();
}; };
export const createPopupNotification = ({type, status, autoHide, duration, closeable, state, message, meta = {}}) => { export const createPopupNotification = ({type, status, autoHide, duration, closeable, state, message, meta = {}}) => {