Edit order pricing inline
This commit is contained in:
@@ -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 || 'Стоимость логистики уточняется менеджером';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user