const PRICE_FORMATTER = new Intl.NumberFormat('ru-RU', { minimumFractionDigits: 0, maximumFractionDigits: 2, }); export function formatPrice(value?: number | null) { if (value == null) { return null; } return `${PRICE_FORMATTER.format(value)} ₽`; } export function orderLineStateText(unitPrice?: number | null, lineTotal?: number | null) { if (unitPrice == null) { return 'Цена за единицу уточняется менеджером'; } const unitPriceLabel = formatPrice(unitPrice); const lineTotalLabel = formatPrice(lineTotal); return lineTotalLabel ? `Цена за единицу: ${unitPriceLabel} · Сумма позиции: ${lineTotalLabel}` : `Цена за единицу: ${unitPriceLabel}`; } export function orderDeliveryStateText(deliveryTerms?: string | null) { return deliveryTerms?.trim() || 'Условия доставки уточняются менеджером'; } export function orderLogisticsStateText(deliveryFee?: number | null) { const deliveryFeeLabel = formatPrice(deliveryFee); return deliveryFeeLabel || 'Стоимость логистики уточняется менеджером'; }