Files
BarevClub/packages/web/src/params.ts
T
2026-10-25 22:55:29 +04:00

20 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { TFunction } from '@barev/i18n';
/** Краткое описание параметров заказа: «Генеральная · 2 комнаты · 2 санузла» */
export function paramsSummary(t: TFunction, serviceCode: string, params: Record<string, unknown>): string {
if (serviceCode !== 'cleaning') return '';
const parts = [t(`params.cleaning.cleaningType.${String(params.cleaningType)}`), t('params.cleaning.rooms.count', { count: Number(params.rooms ?? 1) })];
const baths = Number(params.bathrooms ?? 1);
if (baths > 1) parts.push(t('params.cleaning.bathrooms.count', { count: baths }));
return parts.join(' · ');
}
/** Выбранные доп. услуги: [{ code, qty, label: «Мытьё окон × 3» }] */
export function paramsExtras(t: TFunction, params: Record<string, unknown>) {
const extras = params.extras;
if (!extras || typeof extras !== 'object') return [];
return Object.entries(extras as Record<string, number>)
.filter(([, qty]) => qty > 0)
.map(([code, qty]) => ({ code, qty, label: `${t(`extras.${code}.name`)}${qty > 1 ? ` × ${qty}` : ''}` }));
}