From 6610170b5bd393e8d9ea3b1510cd6821fbca2c63 Mon Sep 17 00:00:00 2001 From: tisachi Date: Sat, 17 Oct 2026 16:00:36 +0200 Subject: [PATCH] =?UTF-8?q?I18n:=20panel=20admina=20(partia=206)=20-=20tlu?= =?UTF-8?q?maczenie=20calego=20UI:=20common=20rozbudowany=20(nav/topbar/fm?= =?UTF-8?q?t/counters/roles/equipmentKind/picker/muscles/statuses),=20nowe?= =?UTF-8?q?=20namespace'y=20gyms/users/catalog/logs/verifications/announce?= =?UTF-8?q?ments;=20lib=20format/labels/availability/equipment/roles=20na?= =?UTF-8?q?=20i18n.t=20(Intl=20wg=20jezyka);=20layout,=20topbar,=20MonthPi?= =?UTF-8?q?cker,=20modale=20i=20pickery;=20strony=20Login,=20Logs,=20Verif?= =?UTF-8?q?ications,=20Announcements,=20katalog=20(Equipment/Exercises/Foc?= =?UTF-8?q?usAreas),=20si=C5=82ownie=20(GymForm/GymsList/GymDetail=20z=20s?= =?UTF-8?q?ekcjami)=20i=20users=20(lista,=20wizard,=20profil=20z=20podstro?= =?UTF-8?q?nami,=20parametry=20ciala,=20historia,=20postepy,=20cz=C5=82onk?= =?UTF-8?q?ostwa,=20wnioski,=20kary);=20auth=20store=20i=20formaty=20dat/l?= =?UTF-8?q?icit=20przez=20jezyk;=20testy=20jednostkowe=2084/84=20zielone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/App.tsx | 6 +- admin/src/components/AddressFields.tsx | 36 ++- admin/src/components/AvailabilityEditor.tsx | 15 +- .../src/components/ExerciseProgressCards.tsx | 6 +- admin/src/components/GymPicker.tsx | 14 +- admin/src/components/GymRolePicker.tsx | 23 +- admin/src/components/HistoryTable.tsx | 6 +- admin/src/components/Layout.tsx | 73 +++-- admin/src/components/UserPicker.tsx | 21 +- admin/src/components/ui/alert.tsx | 12 +- admin/src/components/ui/badge.tsx | 3 +- admin/src/components/ui/button.tsx | 3 +- admin/src/components/ui/card.tsx | 5 +- admin/src/components/ui/content.tsx | 6 +- admin/src/components/ui/dialog.tsx | 15 +- admin/src/components/ui/dialogs.tsx | 20 +- admin/src/components/ui/input.tsx | 11 +- admin/src/components/ui/label.tsx | 5 +- admin/src/components/ui/progress.tsx | 5 +- admin/src/components/ui/skeleton.tsx | 4 +- admin/src/components/ui/textarea.tsx | 10 +- admin/src/components/ui/typography.tsx | 18 +- admin/src/i18n/index.ts | 51 ++- admin/src/i18n/locales/en/announcements.json | 25 ++ admin/src/i18n/locales/en/auth.json | 2 + admin/src/i18n/locales/en/catalog.json | 97 ++++++ admin/src/i18n/locales/en/common.json | 180 ++++++++++- admin/src/i18n/locales/en/gyms.json | 142 ++++++++ admin/src/i18n/locales/en/logs.json | 65 ++++ admin/src/i18n/locales/en/users.json | 140 ++++++++ admin/src/i18n/locales/en/verifications.json | 42 +++ admin/src/i18n/locales/pl/announcements.json | 25 ++ admin/src/i18n/locales/pl/auth.json | 2 + admin/src/i18n/locales/pl/catalog.json | 97 ++++++ admin/src/i18n/locales/pl/common.json | 199 +++++++++++- admin/src/i18n/locales/pl/gyms.json | 144 +++++++++ admin/src/i18n/locales/pl/logs.json | 65 ++++ admin/src/i18n/locales/pl/users.json | 140 ++++++++ admin/src/i18n/locales/pl/verifications.json | 42 +++ admin/src/lib/availability.ts | 22 +- admin/src/lib/equipment.ts | 43 +-- admin/src/lib/format.ts | 69 ++-- admin/src/lib/labels.ts | 27 +- admin/src/lib/roles.ts | 48 ++- admin/src/pages/Login.tsx | 35 +- admin/src/pages/Logs.tsx | 128 ++++---- admin/src/pages/Verifications.tsx | 127 +++++--- .../src/pages/announcements/Announcements.tsx | 70 ++-- admin/src/pages/catalog/Equipment.tsx | 96 +++--- admin/src/pages/catalog/Exercises.tsx | 167 +++++----- admin/src/pages/catalog/FocusAreas.tsx | 79 ++--- admin/src/pages/gyms/GymDetail.tsx | 302 +++++++++--------- admin/src/pages/gyms/GymForm.tsx | 36 +-- admin/src/pages/gyms/GymsList.tsx | 42 ++- admin/src/pages/users/UserBodyParameters.tsx | 64 ++-- admin/src/pages/users/UserClaims.tsx | 38 ++- admin/src/pages/users/UserDetail.tsx | 110 ++++--- admin/src/pages/users/UserForm.tsx | 87 ++--- admin/src/pages/users/UserHistory.tsx | 21 +- admin/src/pages/users/UserInfo.tsx | 111 ++++--- admin/src/pages/users/UserMemberships.tsx | 22 +- admin/src/pages/users/UserProgress.tsx | 20 +- .../src/pages/users/UserRestrictionModal.tsx | 36 ++- admin/src/pages/users/UsersList.tsx | 31 +- admin/src/store/auth.ts | 3 +- admin/src/store/list-search.ts | 8 +- admin/src/topbar/MonthPicker.tsx | 54 +--- admin/src/topbar/Topbar.tsx | 37 ++- 68 files changed, 2678 insertions(+), 1030 deletions(-) create mode 100644 admin/src/i18n/locales/en/announcements.json create mode 100644 admin/src/i18n/locales/en/catalog.json create mode 100644 admin/src/i18n/locales/en/gyms.json create mode 100644 admin/src/i18n/locales/en/logs.json create mode 100644 admin/src/i18n/locales/en/users.json create mode 100644 admin/src/i18n/locales/en/verifications.json create mode 100644 admin/src/i18n/locales/pl/announcements.json create mode 100644 admin/src/i18n/locales/pl/catalog.json create mode 100644 admin/src/i18n/locales/pl/gyms.json create mode 100644 admin/src/i18n/locales/pl/logs.json create mode 100644 admin/src/i18n/locales/pl/users.json create mode 100644 admin/src/i18n/locales/pl/verifications.json 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 (