diff --git a/frontend/app/[calculator]/layout.tsx b/frontend/app/[calculator]/layout.tsx new file mode 100644 index 0000000..499faff --- /dev/null +++ b/frontend/app/[calculator]/layout.tsx @@ -0,0 +1,11 @@ +// app/[calculator]/layout.tsx +// Layout для страниц калькуляторов с сохранением chat_id + +export default function CalculatorLayout({ + children, +}: { + children: React.ReactNode; +}) { + return <>{children}>; +} + diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx index d3c321d..627a143 100644 --- a/frontend/app/page.tsx +++ b/frontend/app/page.tsx @@ -1,6 +1,11 @@ +// app/page.tsx +// Главная страница с выбором калькулятора + import { redirect } from 'next/navigation'; +import { getAvailableCalculators } from '@/lib/calculators'; export default function Home() { - // Редирект на калькулятор мыла по умолчанию + // Редирект на калькулятор мыла по умолчанию, если есть chat_id + // Иначе показываем список калькуляторов redirect('/soap'); } diff --git a/frontend/components/CalculatorNav.tsx b/frontend/components/CalculatorNav.tsx new file mode 100644 index 0000000..605f0fc --- /dev/null +++ b/frontend/components/CalculatorNav.tsx @@ -0,0 +1,54 @@ +// components/CalculatorNav.tsx +// Навигация между калькуляторами + +'use client'; + +import { usePathname, useSearchParams } from 'next/navigation'; + +export default function CalculatorNav() { + const pathname = usePathname(); + const searchParams = useSearchParams(); + const chatId = searchParams.get('chat_id'); + + // Сохраняем chat_id при переходах + const queryString = chatId ? `?chat_id=${chatId}` : ''; + + const calculators = [ + { id: 'soap', name: 'Мыло' }, + { id: 'candle', name: 'Свеча' }, + ]; + + const handleCalculatorChange = (calcId: string) => { + window.location.href = `/${calcId}${queryString}`; + }; + + return ( +