Skip to content

Commit

Permalink
add formatter for currency to household input
Browse files Browse the repository at this point in the history
  • Loading branch information
abhcs committed Dec 12, 2023
1 parent 102b68f commit b50ee72
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pages/household/input/VariableEditor.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useSearchParams } from "react-router-dom";
import { capitalize } from "../../../api/language";
import { capitalize, localeCode } from "../../../api/language";
import {
currencyMap,
getNewHouseholdId,
Expand Down Expand Up @@ -232,7 +232,11 @@ function HouseholdVariableEntityInput(props) {
width: mobile ? 150 : 200,
}}
addonBefore={isCurrency ? currencyMap[variable.unit] : undefined}
min={isCurrency ? 0 : undefined}
formatter={
isCurrency
? (value) => (+value).toLocaleString(localeCode(metadata.countryId))
: undefined
}
precision={variable.valueType === "float" ? 2 : undefined}
defaultValue={defaultValue}
autoFocus={true}
Expand Down

0 comments on commit b50ee72

Please sign in to comment.