From 13ffb8754b7dfce2291a7a0ceb88690bbf65baf6 Mon Sep 17 00:00:00 2001 From: oskar Date: Fri, 31 Jul 2026 16:22:50 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20wsp=C3=B3=C5=82dzielony=20LangSwitc?= =?UTF-8?q?her=20tak=C5=BCe=20w=20nag=C5=82=C3=B3wkach=20podstron?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Przełącznik siedział w Header.tsx, który renderuje się tylko na landingu — PrivacyPolicyPage i PlatformPage mają własne
. Z /en/privacy i /en/platforma nie dało się wrócić na PL inaczej niż przez stronę główną albo ręczną edycję URL-a. Wyciągnięty do src/components/LangSwitcher.tsx i wstawiony w oba nagłówki obok linku powrotnego. Co-Authored-By: Claude Opus 5 (1M context) --- src/components/Header.tsx | 35 ++-------------------- src/components/LangSwitcher.tsx | 44 ++++++++++++++++++++++++++++ src/components/PlatformPage.tsx | 10 +++++-- src/components/PrivacyPolicyPage.tsx | 10 +++++-- 4 files changed, 60 insertions(+), 39 deletions(-) create mode 100644 src/components/LangSwitcher.tsx diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 2eede96..db1ccaa 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,39 +1,8 @@ import React, { useState, useEffect } from 'react'; import { Menu, X } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; -import { localizePath, setLang, useLang, type Lang } from '../i18n'; - -const LANGS: Lang[] = ['pl', 'en']; - -// PL / EN toggle. Buttons rather than links: switching is a client-side -// navigation (setLang), so a real href would reload the whole document. -const LangSwitcher = ({ onSwitch }: { onSwitch?: () => void }) => { - const lang = useLang(); - - return ( -
- {LANGS.map((code, i) => ( - - {i > 0 && } - - - ))} -
- ); -}; +import { localizePath, useLang } from '../i18n'; +import LangSwitcher from './LangSwitcher'; const Header = () => { const lang = useLang(); diff --git a/src/components/LangSwitcher.tsx b/src/components/LangSwitcher.tsx new file mode 100644 index 0000000..8ea7db4 --- /dev/null +++ b/src/components/LangSwitcher.tsx @@ -0,0 +1,44 @@ +import React from 'react'; +import { setLang, useLang, type Lang } from '../i18n'; + +const LANGS: Lang[] = ['pl', 'en']; + +/** + * PL / EN toggle. Buttons rather than links: switching is a client-side + * navigation (setLang), so a real href would reload the whole document. + * + * Shared by the landing Header and the standalone pages' own headers — without + * it on those pages, /en/privacy and /en/platforma have no way back to Polish + * short of editing the URL. + * + * @param onSwitch runs after the language changes — used to close the mobile menu. + */ +const LangSwitcher = ({ onSwitch }: { onSwitch?: () => void }) => { + const lang = useLang(); + + return ( +
+ {LANGS.map((code, i) => ( + + {i > 0 && } + + + ))} +
+ ); +}; + +export default LangSwitcher; diff --git a/src/components/PlatformPage.tsx b/src/components/PlatformPage.tsx index 3e8076f..e2da998 100644 --- a/src/components/PlatformPage.tsx +++ b/src/components/PlatformPage.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { ArrowRight, Building2, CheckCircle2, ChevronRight, Home } from 'lucide-react'; import Footer from './Footer'; import { localizePath, useLang } from '../i18n'; +import LangSwitcher from './LangSwitcher'; // Standalone product page at /platforma (and /en/platforma). The copy is not // localized yet — the site only translates contact.* and privacy.* — but the @@ -16,9 +17,12 @@ const PlatformPage = () => { humanAI - - ← Wróć na stronę główną - +
+ + ← Wróć na stronę główną + + +
diff --git a/src/components/PrivacyPolicyPage.tsx b/src/components/PrivacyPolicyPage.tsx index 240f83e..5de2e1f 100644 --- a/src/components/PrivacyPolicyPage.tsx +++ b/src/components/PrivacyPolicyPage.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { localizePath, useLang, useT } from '../i18n'; import Footer from './Footer'; +import LangSwitcher from './LangSwitcher'; const PrivacyPolicyPage = () => { const t = useT(); @@ -14,9 +15,12 @@ const PrivacyPolicyPage = () => { humanAI - - {t.privacy.backToHome} - +
+ + {t.privacy.backToHome} + + +