mirror of
https://framagit.org/enfance-libre/statistiques
synced 2025-12-08 01:33:44 +00:00
16 lines
513 B
TypeScript
16 lines
513 B
TypeScript
|
|
import { StatPublishOptions } from "../../statPropsPublishOptions";
|
||
|
|
|
||
|
|
export function formatValue(value: number, publishOptions: StatPublishOptions) {
|
||
|
|
const valueStr = value.toLocaleString("fr-FR", {
|
||
|
|
useGrouping: false,
|
||
|
|
maximumFractionDigits:
|
||
|
|
publishOptions.valueMaxFractioDigits === undefined
|
||
|
|
? 1
|
||
|
|
: publishOptions.valueMaxFractioDigits,
|
||
|
|
});
|
||
|
|
const formattedValue = `${valueStr}${
|
||
|
|
publishOptions.unit === undefined ? "" : publishOptions.unit
|
||
|
|
}`;
|
||
|
|
return formattedValue;
|
||
|
|
}
|