diff --git a/admin/src/App.tsx b/admin/src/App.tsx index 672c9ac..cfd4c59 100644 --- a/admin/src/App.tsx +++ b/admin/src/App.tsx @@ -1,5 +1,6 @@ import { useEffect } from 'react'; import { Routes, Route, Navigate } from 'react-router-dom'; +import { useTranslation } from 'react-i18next'; import { useAuth } from './store/auth'; import Layout from './components/Layout'; import Login from './pages/Login'; @@ -23,6 +24,7 @@ import Logs from './pages/Logs'; import VerificationsList, { VerificationDetail } from './pages/Verifications'; export default function App() { + const { t } = useTranslation(); const { user, ready, init } = useAuth(); useEffect(() => { @@ -30,7 +32,9 @@ export default function App() { }, [init]); if (!ready) { - return
Ładowanie…
; + return ( +
{t('loading')}
+ ); } return ( diff --git a/admin/src/components/AddressFields.tsx b/admin/src/components/AddressFields.tsx index d8e0e09..1e06056 100644 --- a/admin/src/components/AddressFields.tsx +++ b/admin/src/components/AddressFields.tsx @@ -1,3 +1,4 @@ +import { useTranslation } from 'react-i18next'; import { Field, Input, Select } from './ui'; /** @@ -5,13 +6,13 @@ import { Field, Input, Select } from './ui'; * kod pocztowy, miejscowość, kraj). Display string `location` składa serwer. */ -export const COUNTRIES: { code: string; label: string }[] = [ - { code: 'PL', label: 'Polska' }, - { code: 'DE', label: 'Niemcy' }, - { code: 'CZ', label: 'Czechy' }, - { code: 'SK', label: 'Słowacja' }, - { code: 'LT', label: 'Litwa' }, - { code: 'GB', label: 'Wielka Brytania' }, +export const COUNTRIES: { code: string; labelKey: string }[] = [ + { code: 'PL', labelKey: 'address.PL' }, + { code: 'DE', labelKey: 'address.DE' }, + { code: 'CZ', labelKey: 'address.CZ' }, + { code: 'SK', labelKey: 'address.SK' }, + { code: 'LT', labelKey: 'address.LT' }, + { code: 'GB', labelKey: 'address.GB' }, ]; /** Polskie kody pocztowe: 00-001. */ @@ -58,25 +59,26 @@ export function AddressFields({ onChange: (patch: Partial) => void; required?: boolean; }) { + const { t } = useTranslation('gyms'); const postalInvalid = values.postalCode.length > 0 && !PL_POSTAL_CODE.test(values.postalCode); return ( <> - + onChange({ addressLine1: e.target.value })} - placeholder="np. Mokotowska 12A" + placeholder={t('address.streetPh')} required={required} /> - + onChange({ addressLine2: e.target.value })} - placeholder="np. piętro 2, lokal 5" + placeholder={t('address.premisesPh')} /> - + onChange({ postalCode: formatPostalCodeInput(e.target.value) })} @@ -87,26 +89,26 @@ export function AddressFields({ required={required} /> {postalInvalid && ( -

Format kodu: 00-001

+

{t('address.postalFormatError')}

)}
- + onChange({ city: e.target.value })} - placeholder="np. Warszawa" + placeholder={t('address.cityPh')} autoComplete="address-level2" required={required} /> - + diff --git a/admin/src/components/AvailabilityEditor.tsx b/admin/src/components/AvailabilityEditor.tsx index 9cf9d7d..b54e4d4 100644 --- a/admin/src/components/AvailabilityEditor.tsx +++ b/admin/src/components/AvailabilityEditor.tsx @@ -1,4 +1,5 @@ -import { DAY_NAMES_FULL, TIME_SLOTS } from '../lib/availability'; +import { useTranslation } from 'react-i18next'; +import { dayFull, TIME_SLOTS } from '../lib/availability'; import { Select } from './ui'; import type { Availability, DayAvailability } from '../api/types'; @@ -12,6 +13,7 @@ export function AvailabilityEditor({ value: Availability; onChange: (value: Availability) => void; }) { + const { t } = useTranslation(); const setDay = (i: number, day: DayAvailability | null) => { const next = [...value]; next[i] = day; @@ -20,23 +22,24 @@ export function AvailabilityEditor({ return (
- {DAY_NAMES_FULL.map((name, i) => { + {[0, 1, 2, 3, 4, 5, 6].map((i) => { + const name = dayFull(i); const day = value[i]; const enabled = day != null; const start = day?.start ?? DEFAULT_START; const end = day?.end ?? DEFAULT_END; return ( -
+
{name} setDay(i, e.target.checked ? { start, end } : null)} className="size-4 accent-[var(--accent)]" /> – { setQuery(e.target.value); @@ -50,7 +52,7 @@ export function GymPicker({ {selected && !open && ( ); })} @@ -83,22 +85,19 @@ export function GymRolePicker({
{meta ? ( <> - {meta.label}: - {meta.summary} + {t(meta.labelKey)}: + {t(meta.summaryKey)}
    - {meta.grants.map((g) => ( + {meta.grantKeys.map((g) => (
  • • - {g} + {t(g)}
  • ))}
) : ( - - Wybierz rolę, aby zobaczyć, co dokładnie daje. Ćwiczący = trenuje, Trener = prowadzi - podopiecznych, Właściciel = zarządza siłownią. - + {t('roles.picker.hint')} )}
)} diff --git a/admin/src/components/HistoryTable.tsx b/admin/src/components/HistoryTable.tsx index 840ab6b..1409dcf 100644 --- a/admin/src/components/HistoryTable.tsx +++ b/admin/src/components/HistoryTable.tsx @@ -4,7 +4,7 @@ import { ChevronDown, ChevronUp, MessageSquare } from 'lucide-react'; import type { HistorySession } from '../api/types'; import { fmtDate, fmtDuration, fmtVolume } from '../lib/format'; import { localizedName } from '../lib/localizedName'; -import { MUSCLE_NAMES, SESSION_STATUS } from '../lib/labels'; +import { muscleName, SESSION_STATUS } from '../lib/labels'; import { Badge } from './ui'; interface HistoryTableProps { @@ -18,7 +18,7 @@ interface HistoryTableProps { * Port odpowiednika z aplikacji (`app/src/components/HistoryTable`) bez dodawania komentarzy. */ export default function HistoryTable({ sessions, initialOpenSessionId }: HistoryTableProps) { - const { i18n } = useTranslation(); + const { t, i18n } = useTranslation(); const [openSession, setOpenSession] = useState(initialOpenSessionId ?? null); return ( @@ -78,7 +78,7 @@ export default function HistoryTable({ sessions, initialOpenSessionId }: History
- {st.label} + {t(st.labelKey)} {open ? ( ) : ( diff --git a/admin/src/components/Layout.tsx b/admin/src/components/Layout.tsx index f7c7f5d..d421c91 100644 --- a/admin/src/components/Layout.tsx +++ b/admin/src/components/Layout.tsx @@ -1,5 +1,6 @@ import { useState } from 'react'; import { NavLink, Outlet, useNavigate } from 'react-router-dom'; +import { useTranslation } from 'react-i18next'; import { AppWindow, Building2, @@ -26,7 +27,7 @@ import { cn } from '../lib/utils'; interface NavItem { to: string; - label: string; + labelKey: string; icon: LucideIcon; end: boolean; /** Link na inny origin (np. aplikacja) — , nie . */ @@ -34,35 +35,35 @@ interface NavItem { } interface NavSection { - label: string; + labelKey: string; items: NavItem[]; } const SECTIONS: NavSection[] = [ { - label: 'Zarządzanie', + labelKey: 'nav.management', items: [ - { to: '/gyms', label: 'Siłownie', icon: Building2, end: false }, - { to: '/verifications', label: 'Weryfikacje', icon: ShieldCheck, end: false }, - { to: '/users', label: 'Użytkownicy', icon: Users, end: false }, - { to: '/announcements', label: 'Ogłoszenia', icon: Megaphone, end: false }, + { to: '/gyms', labelKey: 'nav.gyms', icon: Building2, end: false }, + { to: '/verifications', labelKey: 'nav.verifications', icon: ShieldCheck, end: false }, + { to: '/users', labelKey: 'nav.users', icon: Users, end: false }, + { to: '/announcements', labelKey: 'nav.announcements', icon: Megaphone, end: false }, ], }, { - label: 'Słowniki', + labelKey: 'nav.dictionaries', items: [ - { to: '/focus-areas', label: 'Obszary treningowe', icon: Target, end: false }, - { to: '/exercises', label: 'Rodzaje ćwiczeń', icon: Dumbbell, end: false }, - { to: '/equipment', label: 'Urządzenia', icon: Wrench, end: false }, + { to: '/focus-areas', labelKey: 'nav.focusAreas', icon: Target, end: false }, + { to: '/exercises', labelKey: 'nav.exercises', icon: Dumbbell, end: false }, + { to: '/equipment', labelKey: 'nav.equipment', icon: Wrench, end: false }, ], }, { - label: 'System', + labelKey: 'nav.system', items: [ - { to: '/logs', label: 'Logi', icon: ScrollText, end: true }, + { to: '/logs', labelKey: 'nav.logs', icon: ScrollText, end: true }, // Powrót do aplikacji użytkownika — zawsze na końcu, inny origin (aplikacja // wznowi sesję z własnego ciastka fitos_refresh, panelu nie dotyka). - { to: APP_URL, label: 'Aplikacja', icon: AppWindow, end: false, external: true }, + { to: APP_URL, labelKey: 'nav.application', icon: AppWindow, end: false, external: true }, ], }, ]; @@ -87,10 +88,11 @@ function NavLinks({ collapsed: boolean; onNavigate?: () => void; }) { + const { t } = useTranslation(); return (