Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFT-208 Format money to have comma as separator #635

Merged
merged 2 commits into from
Mar 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions front_end/src/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ export const monthsToTitleCase = months.map(
(x) => x[0].toUpperCase() + x.slice(1),
);

export const formatMoney = (amount) => {
return (amount / 100).toFixed(2);
};

function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie !== "") {
Expand All @@ -40,11 +36,22 @@ function getCookie(name) {
return cookieValue;
}

const NumberFormat = new Intl.NumberFormat("en-GB");
var currencyFormat = new Intl.NumberFormat("en-GB", {
style: "currency",
currency: "GBP",
minimumFractionDigits: 2,
maximumFractionDigits: 2,
});

export const formatMoney = (value) => {
return currencyFormat.format(value / 100);
};

const numberFormat = new Intl.NumberFormat("en-GB");

export const formatValue = (value) => {
let pounds = Math.round(value);
return NumberFormat.format(pounds);
return numberFormat.format(pounds);
};

/**
Expand Down