// Order detail page — service-agnostic shell + per-service detail renderers. // To add a new service: define a *Detail component and register it in // SERVICE_DETAIL_RENDERERS by service type key returned from detectServiceType(). const { useState: useODState } = React; function odParseLinks(s) { if (!s) return []; return String(s).split(',') .map(l => l.trim().replace(/^['"\[\] ]+|['"\[\] ]+$/g, '')) .filter(l => l.startsWith('http')); } function detectServiceType(order) { const pn = String(order.position_name || ''); if (/^\d+\/\d+$/.test(pn)) return 'avito-pf'; if (pn === 'Авито ПФ') return 'avito-pf'; return 'generic'; } function serviceDisplayName(serviceType, order) { if (serviceType === 'avito-pf') return 'Авито ПФ'; return order.position_name || '—'; } // --- Avito PF specific details --- function AvitoPFDetail({ order }) { const links = odParseLinks(order.links); const m = String(order.position_name || '').match(/^(\d+)\/(\d+)$/); const days = m ? Number(m[1]) : null; const viewsPerDay = m ? Number(m[2]) : null; const totalViews = (viewsPerDay != null && days != null && links.length > 0) ? viewsPerDay * days * links.length : (viewsPerDay != null && days != null ? viewsPerDay * days : null); const params = [ days != null && { label: 'Дней накрутки', value: `${days}` }, viewsPerDay != null && { label: 'Просмотров в день', value: `${viewsPerDay}` }, { label: 'Запросы контактов', value: order.contacts ? 'Да' : 'Нет' }, links.length > 0 && { label: 'Объявлений в заказе', value: `${links.length}` }, totalViews != null && { label: 'Всего просмотров', value: totalViews.toLocaleString('ru-RU') }, { label: 'Цена за просмотр', value: (viewsPerDay && days && links.length) ? `${Math.round(order.price / totalViews)} ₽` : '—' }, ].filter(Boolean); return (
Заказ не выбран.