Edit order pricing inline

This commit is contained in:
Ruslan Bakiev
2026-04-04 11:16:16 +07:00
parent 7dc0f59ffb
commit 8c5e95b730
8 changed files with 245 additions and 18 deletions

View File

@@ -1,9 +1,34 @@
export function orderLineStateText(totalPrice?: number | null) {
return totalPrice == null
? 'Цена уточняется менеджером'
: 'Цена согласована менеджером';
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() || 'Доставка уточняется менеджером';
return deliveryTerms?.trim() || 'Условия доставки уточняются менеджером';
}
export function orderLogisticsStateText(deliveryFee?: number | null) {
const deliveryFeeLabel = formatPrice(deliveryFee);
return deliveryFeeLabel || 'Стоимость логистики уточняется менеджером';
}