{c.name}
{c.lead &&{cleanText(c.lead)}
}import { useMemo } from 'react';
import { Link, useParams } from 'react-router-dom';
import urgentImage from '../assets/figma/service-urgent-3d.webp';
import { api } from '../api.js';
import BookingSection from '../components/BookingSection.jsx';
import Breadcrumbs from '../components/Breadcrumbs.jsx';
import ContactsSection from '../components/ContactsSection.jsx';
import { DoctorRow } from '../components/DoctorCard.jsx';
import { useLeadModal } from '../context/LeadModalContext.jsx';
import { useSiteData } from '../context/SiteData.jsx';
import { priceLabel, telHref } from '../lib/format.js';
import { servicePath, specialtyPath, priceSectionPath } from '../lib/links.js';
import { servicePriceSection } from '../lib/serviceNavigation.js';
import { DIRECTION_MEDIA, SERVICE_IMAGES, directionOf, serviceSpecialty } from '../lib/media.js';
import { URGENT_TITLE, parseBlocks } from '../lib/serviceContent.js';
import { cleanText } from '../lib/text.js';
import { useApi } from '../lib/useApi.js';
import { usePageTitle } from '../lib/usePageTitle.js';
import { serviceMetadata, serviceSchema, jsonForHTML } from '../lib/seo.js';
import { useInitialApiData } from '../context/ApiData.jsx';
import StubPage from './StubPage.jsx';
import './ServicePage.css';
const noData = () => Promise.resolve({ data: null, meta: {} });
// /services/<направление>/ — список услуг направления;
// /services/<направление>/<услуга>/ и направления без вложенных услуг — страница услуги.
export default function ServicePage() {
const params = useParams();
const path = (params['*'] || '').replace(/^\/+|\/+$/g, '');
const nested = path.includes('/');
const direction = directionOf(path);
const service = useApi((signal) => api.service(path, { signal }), [path], `service:${path}`);
const parent = useApi((signal) => (nested ? api.service(direction, { signal }) : noData()), [direction, nested], `service:${direction}`);
const siteURL = useInitialApiData('siteURL') || (typeof window !== 'undefined' ? window.location.origin : '');
usePageTitle(service.data?.name, service.data ? serviceMetadata(service.data, siteURL) : undefined);
if (!path) return
Не удалось загрузить услугу. Обновите страницу.
; if (!service.data || service.data.path !== path) returnЗагружаем…
; const s = service.data; if (s.children?.length) return{cleanText(c.lead)}
}{lead}
} {(parent || service.price_from) && (Направление {parent.short_name || parent.name}
)}