msupply-foundation / open-msupply

Open mSupply represents our most recent advancement in the Logistics Management Information System (LMIS), expanding on more than two decades of development inherited from the well-established legacy of the original mSupply.
https://msupply.foundation/open-msupply/
Other
20 stars 12 forks source link

Small refactor -- replace CurrencyInput component #3218

Open CarlosNZ opened 6 months ago

CarlosNZ commented 6 months ago

The suggestion

Currently the CurrencyInput component uses a 3rd-party library ('react-currency-input-field') for the currency input fields. It's a bit unweidly as there is a lot of custom styling added onto it to make it fit in with the UI.

Suggestion is to remove this library and change the CurrencyInput to wrap around the new NumericInputComponent. And we'd make a small adjustment to allow it to format for currency values, including fixed dp display, etc. This can all be achieved using Intl.NumberFormat, and can be locale-aware. The core mechanism of NumericInputComponent already formats numbers for locales, so it would be a small extension to get it to format currency as well.

Why should we invest time in this?

There is already a "TO-DO" comment in the Currency component to do something like this:

Screenshot 2024-03-07 at 2 21 23 PM

Also:

Are there any risks associated with this change?

Should be easy to test and try edge cases for number/currency input, so no major risk.

How much effort is required?

~1 day.

Agreed Solution

Chris-Petty commented 6 months ago

Whoops clicked wrong issue!