Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
20 lines
1.1 KiB
TypeScript
20 lines
1.1 KiB
TypeScript
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}` : ''}` }));
|
||
}
|