Files
web-app/src/lib/common/utils/pricing.util.js

38 lines
1.0 KiB
JavaScript
Raw Normal View History

2026-09-08 17:38:13 +03:00
// lib/common/utils/pricing.util.js
export const QUALITIES = [
{ id: 'low', label: 'Эконом' },
{ id: 'medium', label: 'Стандарт' },
{ id: 'high', label: 'Максимум' }
];
export const COLOR_MODES = [
2026-09-14 08:59:58 +03:00
{ id: 'bw', label: 'Черно-белая' },
{ id: 'color', label: 'Цветная' }
2026-09-08 17:38:13 +03:00
];
export const FORMATS = ['A4', 'A5'];
/**
* Расчет цены за страницу в зависимости от объема
*/
export function getPricePerPage(pagesCount) {
if (pagesCount >= 1000) return 4;
if (pagesCount >= 25) return 9;
return 10;
}
/**
* Плюрализация
*/
export function pluralize(n, forms) {
const mod10 = n % 10;
const mod100 = n % 100;
if (mod10 === 1 && mod100 !== 11) return forms[0];
if (mod10 >= 2 && mod10 <= 4 && (mod100 < 10 || mod100 > 14)) return forms[1];
return forms[2];
}
export const plFiles = (n) => pluralize(n, ['файл', 'файла', 'файлов']);
export const plCopies = (n) => pluralize(n, ['копия', 'копии', 'копий']);