From 2f4e0d59aafd14970945616b19eba4e657ed8cc2 Mon Sep 17 00:00:00 2001 From: Yuu Ottosoka Date: Sat, 13 Sep 2025 20:40:20 +0300 Subject: [PATCH] refactor: simplify yclients API integration and improve UI components remove unused abonements API configuration and endpoints add escape key handler for drawer component implement text truncation for service descriptions sync swiper navigation between service tabs and content add static gym rental service to services list --- astro.config.mjs | 2 - nginx/nginx.conf | 3 - src/components/Drawer.tsx | 16 ++++ .../services/CharachteristicCard.tsx | 11 ++- src/components/services/Services.tsx | 4 +- src/libs/api/yclients.ts | 91 ++++++++----------- 6 files changed, 65 insertions(+), 62 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index d6ff6b3..52836e0 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -24,8 +24,6 @@ export default defineConfig({ schema: { YCLIENTS_API_URL: envField.string({ context: 'server', access: 'public' }), YCLIENTS_TOKEN: envField.string({ context: 'server', access: 'secret' }), - YCLIENTS_ABONEMENTS_API_URL: envField.string({ context: 'server', access: 'public' }), - YCLIENTS_ABONEMENTS_TOKEN: envField.string({ context: 'server', access: 'secret' }), }, }, }) diff --git a/nginx/nginx.conf b/nginx/nginx.conf index f17825c..a1a6187 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -18,9 +18,6 @@ http { gzip_proxied expired no-cache no-store private auth; gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; - # Fix Yandex.Metrika Topics API attestation error - add_header Permissions-Policy "browsing-topics=()" always; - error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; diff --git a/src/components/Drawer.tsx b/src/components/Drawer.tsx index 8a87043..aa85040 100644 --- a/src/components/Drawer.tsx +++ b/src/components/Drawer.tsx @@ -27,6 +27,22 @@ const Drawer: React.FC = ({ isOpen, onClose, loading = false, child document.body.style.overflow = isOpen ? 'hidden' : 'auto' }, [isOpen]) + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key === 'Escape' && isOpen) { + onClose() + } + } + + if (isOpen) { + document.addEventListener('keydown', handleKeyDown) + } + + return () => { + document.removeEventListener('keydown', handleKeyDown) + } + }, [isOpen]) + return (
} +const textEllipsis = (text: string, maxLength: number) => { + if (text.length <= maxLength) { + return text + } + return text.substring(0, maxLength) + '...' +} + export const CharachteristicCard: React.FC = ({ title, description, price, link }) => { return (

{title}

- {description && } + {description && ( + + )}
{price && ( diff --git a/src/components/services/Services.tsx b/src/components/services/Services.tsx index c95c766..0746997 100644 --- a/src/components/services/Services.tsx +++ b/src/components/services/Services.tsx @@ -13,17 +13,19 @@ export type ServicesProps = { export const Services: React.FC = ({ services }) => { const swiperRef = useRef(null) + const tagSwiper = useRef(null) const [serviceId, setServiceId] = useState(0) const selectedService = services[serviceId] const isSelected = (index: number) => index === serviceId const updateServiceHandler = useCallback((index: number) => { setServiceId(index) swiperRef.current?.swiper.slideTo(0) + tagSwiper.current?.swiper.slideTo(index) }, []) return (
- + {services.map((service, index) => (