Рефакторинг

This commit is contained in:
2026-09-08 17:38:13 +03:00
parent e2691c2d02
commit b1956a3b04
18 changed files with 778 additions and 775 deletions

View File

@ -0,0 +1,37 @@
// lib/common/utils/pricing.util.js
export const QUALITIES = [
{ id: 'low', label: 'Эконом' },
{ id: 'medium', label: 'Стандарт' },
{ id: 'high', label: 'Максимум' }
];
export const COLOR_MODES = [
{ id: 'bw', label: 'Чб' },
{ id: 'color', label: 'Цвет' }
];
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, ['копия', 'копии', 'копий']);