remove toPersianDigits
This commit is contained in:
@@ -5,4 +5,4 @@ export function useCardNumber(val: number) {
|
||||
export function useShabaNumber(val: number) {
|
||||
const str = val.toString()
|
||||
return `IR${str.substring(0,4)}\xa0\xa0\xa0${str.substring(4,8)}\xa0\xa0\xa0${str.substring(8,12)}\xa0\xa0\xa0${str.substring(12,16)}\xa0\xa0\xa0${str.substring(16,20)}\xa0\xa0\xa0${str.substring(20,24)}`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
const PERSIAN_DIGITS = '۰۱۲۳۴۵۶۷۸۹'
|
||||
|
||||
function formatGroupedPrice(price: string | number | null | undefined, digit: boolean) {
|
||||
let value = price === null || price === undefined ? '' : String(price)
|
||||
if (digit) {
|
||||
value = value.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
||||
}
|
||||
return value.replace(/\d/g, (d) => PERSIAN_DIGITS[Number(d)] ?? d)
|
||||
return value
|
||||
}
|
||||
|
||||
export function formatNumber(value: string | number | null | undefined, grouped = false): string {
|
||||
return formatGroupedPrice(value, grouped)
|
||||
}
|
||||
|
||||
export function usePrice(price: number, digit = true, unit = 'ریال') {
|
||||
@@ -87,6 +89,6 @@ export function getTransactionGoldAmount(item: TransactionPriceSource): number {
|
||||
|
||||
export function formatGoldAmount(amount?: number | null): string {
|
||||
const num = Number(amount)
|
||||
if (!Number.isFinite(num)) return '۰'
|
||||
if (!Number.isFinite(num)) return '0'
|
||||
return formatGroupedPrice(Number(num.toFixed(3)), false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user