fix(dashboard): support more decimals for tx rates (#13407)
* Percentage formatter set maximum digits to 4 * Modify Tax Region Forms to allow 4 digits tax rates * Add changeset * Revert placeholder value to use only 2 decimals * fix(dashboard): support more decimals for tx rates * changeset * bypass scale * refactor * fix removal of deprecated input * cleanup deprecated percentage input * small mistake in onchange * add deprecated percentage input back * import * remove file extension * frane comment --------- Co-authored-by: AmbroziuBaban <ambroziubaban@gmail.com>
This commit is contained in:
19
packages/admin/dashboard/src/lib/number-helper.ts
Normal file
19
packages/admin/dashboard/src/lib/number-helper.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Gets the number of decimal places in a number
|
||||
* @param num - The number for which we are getting the number of decimal places
|
||||
* @returns The number of decimal places
|
||||
*
|
||||
* @example
|
||||
* getDecimalPlaces(123.456) // 3
|
||||
* getDecimalPlaces(42) // 0
|
||||
* getDecimalPlaces(10.0000) // 0
|
||||
*/
|
||||
export function getNumberOfDecimalPlaces(num: number): number {
|
||||
// Convert to string and check if it contains a decimal point
|
||||
const str = num.toString()
|
||||
if (str.indexOf(".") === -1) {
|
||||
return 0
|
||||
}
|
||||
// Return the length of the part after the decimal point
|
||||
return str.split(".")[1].length
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
const formatter = new Intl.NumberFormat([], {
|
||||
style: "percent",
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 4,
|
||||
})
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user