1405/04/27
-responive bugs
This commit is contained in:
@@ -39,7 +39,7 @@ export function getProductDisplayImage(product?: {
|
||||
return resolveProductImageSrc(product)
|
||||
}
|
||||
|
||||
import { formatGoldAmount } from '@/utils/usePrice'
|
||||
import { formatGoldAmount, usePriceWithoutType } from '@/utils/usePrice'
|
||||
|
||||
export function formatMetalTotal(
|
||||
metal: WalletMetalTotal,
|
||||
@@ -71,3 +71,44 @@ export function resolveAssetsRialValue(
|
||||
?.metal_totals?.[0]?.total_weight
|
||||
return cash + Number(metalWeight ?? 0) * liveGoldPrice
|
||||
}
|
||||
|
||||
export function getProductInventoryQuantity(
|
||||
cards: WalletInventoryCard[],
|
||||
productId?: number | null,
|
||||
mainWalletGold?: number | null,
|
||||
): number {
|
||||
const card = cards.find((item) => Number(item.product_id) === Number(productId))
|
||||
return card ? Number(card.quantity ?? 0) : Number(mainWalletGold ?? 0)
|
||||
}
|
||||
|
||||
export function formatProductWalletBalanceText(
|
||||
product:
|
||||
| { id?: number; title?: string | null; unit?: string | null; group_type?: string | null }
|
||||
| null,
|
||||
cards: WalletInventoryCard[] = [],
|
||||
mainWalletGold?: number | null,
|
||||
): string {
|
||||
const card = cards.find((item) => Number(item.product_id) === Number(product?.id))
|
||||
const quantity = card ? Number(card.quantity ?? 0) : Number(mainWalletGold ?? 0)
|
||||
const unit = card?.unit ?? product?.unit?.trim() ?? 'گرم'
|
||||
const title = product?.title?.trim() || 'محصول'
|
||||
const formatted = unit === 'عدد'
|
||||
? usePriceWithoutType(quantity, false)
|
||||
: formatGoldAmount(quantity)
|
||||
|
||||
return `موجودی کیف ${title}: ${formatted} ${unit}`
|
||||
}
|
||||
|
||||
export function getCashWalletBalance(
|
||||
walletInfo?: Record<string, unknown> | null,
|
||||
wallets?: unknown,
|
||||
): number {
|
||||
const direct = Number(walletInfo?.cash ?? walletInfo?.count_cash_wallets ?? 0)
|
||||
if (direct) return direct
|
||||
|
||||
if (Array.isArray(wallets)) {
|
||||
return wallets.reduce((sum, wallet) => sum + Number(wallet?.cash ?? 0), 0)
|
||||
}
|
||||
|
||||
return Number((wallets as { cash?: number } | null)?.cash ?? 0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user