Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
26 lines
826 B
TypeScript
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)
|
|
)
|
|
}
|