update 2025-06-02
This commit is contained in:
@@ -1,12 +1,28 @@
|
||||
const GlobalConfig = {
|
||||
apiHost: 'http://localhost:8000'
|
||||
apiHost: "http://localhost:8000",
|
||||
};
|
||||
|
||||
export default GlobalConfig;
|
||||
|
||||
export function addThousandSeparators(number, fractionDigits = 2) {
|
||||
return new Intl.NumberFormat('en-US', {
|
||||
minimumFractionDigits: fractionDigits,
|
||||
maximumFractionDigits: fractionDigits,
|
||||
}).format(number);
|
||||
}
|
||||
export function addThousandSeparators(value, fractionDigits = 2) {
|
||||
if (!value) return null; // Handle empty or null values
|
||||
|
||||
// Remove any non-numeric characters except commas and dots
|
||||
value = value.replace(/[^0-9,.]/g, "");
|
||||
|
||||
// If the value contains multiple dots, assume dots are thousand separators
|
||||
if ((value.match(/\./g) || []).length > 1) {
|
||||
value = value.replace(/\./g, "");
|
||||
}
|
||||
|
||||
// Convert to a proper decimal number
|
||||
let number = parseFloat(value.replace(",", "."));
|
||||
|
||||
if (isNaN(number)) return null; // Return null if conversion fails
|
||||
|
||||
// Format the number with thousand separators
|
||||
return new Intl.NumberFormat("en-US", {
|
||||
minimumFractionDigits: fractionDigits,
|
||||
maximumFractionDigits: fractionDigits,
|
||||
}).format(number);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user