fix some bugs
This commit is contained in:
@@ -13,3 +13,17 @@ export function resolveTradeWeightUnit(settingValue?: string | number | null) {
|
||||
export function weightFieldLabelForUnit(unit?: string | null) {
|
||||
return isKilogramUnit(unit) ? 'وزن به کیلوگرم' : 'وزن به گرم'
|
||||
}
|
||||
|
||||
export function formatAmountWithUnit(
|
||||
value: number | null | undefined,
|
||||
unit?: string | null,
|
||||
decimals = 3
|
||||
): string {
|
||||
if (value == null || Number.isNaN(Number(value))) {
|
||||
return '-'
|
||||
}
|
||||
|
||||
const resolvedUnit = (unit ?? TRADE_WEIGHT_UNIT_GRAM).trim() || TRADE_WEIGHT_UNIT_GRAM
|
||||
|
||||
return `${Number(Number(value).toFixed(decimals))} ${resolvedUnit}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user