admin/components/consumer/input/consumerInputUtils.ts
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

26 lines
826 B
TypeScript

import { createElement, type ReactNode } from 'react'
import { formatTomanInWords } from '@/helpers/numberToPersianWords'
import { texts } from '@/texts'
function isTomanAmountLabel(label?: string): boolean {
return typeof label === 'string' && label.includes(texts.common.toman)
}
export function buildConsumerAmountDescription(value: unknown, label: string | undefined, existing?: ReactNode): ReactNode {
if (!isTomanAmountLabel(label)) return existing
const amountInWords = formatTomanInWords(value)
if (!amountInWords && !existing) return undefined
if (!amountInWords) return existing
if (!existing) return amountInWords
return createElement(
'span',
null,
createElement('span', { className: 'block' }, amountInWords),
createElement('span', { className: 'mt-1 block' }, existing)
)
}