28 lines
920 B
TypeScript
28 lines
920 B
TypeScript
import { usePriceWithoutType } from '@/utils/usePrice'
|
|
|
|
/** پیشفرض تاریخی UI وقتی تنظیم خالی است (۱۰۰ هزار تومان = ۱٬۰۰۰٬۰۰۰ ریال) */
|
|
export const DEFAULT_WALLET_MIN_RIAL = 1_000_000
|
|
|
|
export function parseWalletMinRial(
|
|
raw: string | number | null | undefined,
|
|
fallback = DEFAULT_WALLET_MIN_RIAL,
|
|
): number {
|
|
if (raw == null || String(raw).trim() === '') {
|
|
return fallback
|
|
}
|
|
const n = Number(String(raw).replace(/,/g, '').trim())
|
|
if (!Number.isFinite(n) || n < 0) {
|
|
return fallback
|
|
}
|
|
return Math.floor(n)
|
|
}
|
|
|
|
export function formatWalletMinHint(
|
|
kind: 'withdraw' | 'deposit',
|
|
amountRial: number,
|
|
formatPrice: (value: number) => string = usePriceWithoutType,
|
|
): string {
|
|
const label = kind === 'withdraw' ? 'برداشتی' : 'واریزی'
|
|
return `حداقل مبلغ ${label} ${formatPrice(amountRial)} ریال می باشد.`
|
|
}
|