I18n: ekstrakcja UI wspolnego w apce (komponenty ui, dialogi, toast, Layout, topbar, AuthShell — namespace'y common/nav/plans(set), tlumaczenia PL/EN)

This commit is contained in:
tisachi
2026-10-17 11:35:35 +02:00
parent 25b9a2f8bf
commit 101a8fdc88
28 changed files with 360 additions and 133 deletions

View File

@@ -1,4 +1,5 @@
import type { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { Dumbbell, Handshake, Ruler } from 'lucide-react';
import { Card, ThemeToggle, LanguageToggle } from './ui';
import { Brandmark } from './Brandmark';
@@ -6,6 +7,12 @@ import { Brandmark } from './Brandmark';
/* Layout stron auth: panel brandingowy (gradient w akcencie + wzór siatki, claim)
+ panel formularza. Na mobile — jeden słupek (branding u góry). */
export default function AuthShell({ children }: { children: ReactNode }) {
const { t } = useTranslation('auth');
const FEATURES = [
{ icon: Handshake, title: t('featureCoachingTitle'), desc: t('featureCoachingDesc') },
{ icon: Dumbbell, title: t('featureSetsTitle'), desc: t('featureSetsDesc') },
{ icon: Ruler, title: t('featureMeasuresTitle'), desc: t('featureMeasuresDesc') },
];
return (
<div className="relative flex min-h-dvh items-center justify-center p-4">
<div className="fixed right-4 top-4 z-10 flex items-center gap-2">
@@ -35,34 +42,13 @@ export default function AuthShell({ children }: { children: ReactNode }) {
<h1 className="font-display text-[1.25rem] font-bold tracking-[-0.02em]">FitOS</h1>
</div>
<div className="relative font-display text-[1.7rem] font-bold leading-[1.14] tracking-[-0.025em] md:text-[1.95rem]">
Trening, który
<br />
się dowozi.
{t('claimTitle')}
</div>
<p className="relative m-0 max-w-[34ch] text-[0.875rem] leading-relaxed text-dim">
Od planowania po ostatnią serię.
{t('claimSubtitle')}
</p>
<ul
aria-label="Najważniejsze możliwości"
className="relative mt-auto flex flex-col gap-3 pt-4"
>
{[
{
icon: Handshake,
title: 'Coaching',
desc: 'Pod okiem doświadoczonego trenera.',
},
{
icon: Dumbbell,
title: 'Serie planowe',
desc: 'Tydzień → dzień → sesja → wynik.',
},
{
icon: Ruler,
title: 'Pomiary ciała',
desc: 'Waga i obwody w czasie: historia statystyk.',
},
].map(({ icon: Icon, title, desc }) => (
<ul aria-label={t('featuresLabel')} className="relative mt-auto flex flex-col gap-3 pt-4">
{FEATURES.map(({ icon: Icon, title, desc }) => (
<li key={title} className="flex items-start gap-2.5">
<Icon
size={16}

View File

@@ -1,4 +1,5 @@
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { NavLink, Outlet, useNavigate } from 'react-router-dom';
import {
Building2,
@@ -36,7 +37,7 @@ import { cn } from '../lib/utils';
interface NavItem {
to: string;
label: string;
labelKey: string;
icon: LucideIcon;
end: boolean;
badge?: number;
@@ -45,36 +46,36 @@ interface NavItem {
}
const NAV: NavItem[] = [
{ to: '/', label: 'Dashboard', icon: LayoutDashboard, end: true },
{ to: '/plans', label: 'Plany', icon: Dumbbell, end: false },
{ to: '/calendar', label: 'Mój kalendarz', icon: CalendarDays, end: false },
{ to: '/profile', label: 'Profil', icon: User, end: false },
{ to: '/', labelKey: 'dashboard', icon: LayoutDashboard, end: true },
{ to: '/plans', labelKey: 'plans', icon: Dumbbell, end: false },
{ to: '/calendar', labelKey: 'calendar', icon: CalendarDays, end: false },
{ to: '/profile', labelKey: 'profile', icon: User, end: false },
];
const GYM_NAV: NavItem = { to: '/gyms', label: 'Siłownie', icon: Building2, end: false };
const TRAINEES_NAV: NavItem = { to: '/trainees', label: 'Podopieczni', icon: Users, end: false };
const GYM_NAV: NavItem = { to: '/gyms', labelKey: 'gyms', icon: Building2, end: false };
const TRAINEES_NAV: NavItem = { to: '/trainees', labelKey: 'trainees', icon: Users, end: false };
const INVITATIONS_NAV: NavItem = {
to: '/invitations',
label: 'Zaproszenia',
labelKey: 'invitations',
icon: Mail,
end: false,
};
const MESSAGES_NAV: NavItem = {
to: '/messages',
label: 'Komunikator',
labelKey: 'messages',
icon: MessageSquare,
end: false,
};
const ANNOUNCEMENTS_NAV: NavItem = {
to: '/announcements',
label: 'Aktualności',
labelKey: 'announcements',
icon: Megaphone,
end: false,
};
// Panel admina — zawsze na końcu listy, tylko dla kont z isAdmin=true.
const ADMIN_NAV: NavItem = {
to: ADMIN_URL,
label: 'Panel admina',
labelKey: 'adminPanel',
icon: ShieldCheck,
end: false,
external: true,
@@ -100,12 +101,14 @@ function NavLinks({
collapsed: boolean;
onNavigate?: () => void;
}) {
const { t } = useTranslation('nav');
return (
<nav
className={cn('flex flex-col gap-0.5', collapsed ? 'px-2' : 'px-3')}
aria-label="Nawigacja główna"
aria-label={t('mainNav')}
>
{items.map((item) => {
const labelTxt = t(item.labelKey);
const rowClass = (isActive: boolean) =>
cn(
'relative flex h-[38px] items-center gap-2.5 rounded-[10px] text-[13.5px] font-semibold transition-colors duration-150',
@@ -113,7 +116,7 @@ function NavLinks({
isActive ? 'bg-accent/11 text-accent-text' : 'text-dim hover:bg-line/30 hover:text-ink',
);
const icon = <item.icon className="h-[17px] w-[17px] shrink-0" strokeWidth={1.9} />;
const label = !collapsed && <span className="min-w-0 truncate">{item.label}</span>;
const label = !collapsed && <span className="min-w-0 truncate">{labelTxt}</span>;
const navBar = (
<span
aria-hidden="true"
@@ -130,8 +133,8 @@ function NavLinks({
key={item.to}
href={item.to}
onClick={onNavigate}
title={collapsed ? item.label : undefined}
aria-label={collapsed ? item.label : undefined}
title={collapsed ? labelTxt : undefined}
aria-label={collapsed ? labelTxt : undefined}
className={rowClass(false)}
>
{icon}
@@ -146,8 +149,8 @@ function NavLinks({
to={item.to}
end={item.end}
onClick={onNavigate}
title={collapsed ? item.label : undefined}
aria-label={collapsed ? item.label : undefined}
title={collapsed ? labelTxt : undefined}
aria-label={collapsed ? labelTxt : undefined}
className={({ isActive }) => rowClass(isActive)}
>
{({ isActive }) => (
@@ -177,6 +180,7 @@ function NavLinks({
}
export default function Layout() {
const { t } = useTranslation('nav');
const { user, logout } = useAuth();
const navigate = useNavigate();
const [drawerOpen, setDrawerOpen] = useState(false);
@@ -210,7 +214,7 @@ export default function Layout() {
const activeSession = activeSessionData?.session ?? null;
// Aktywna sesja => stały skrót „Trening” w menu (po Kalendarzu), prowadzący do dnia sesji.
const trainingNav: NavItem | null = activeSession
? { to: `/day/${activeSession.dayId}`, label: 'Trening', icon: Play, end: false }
? { to: `/day/${activeSession.dayId}`, labelKey: 'training', icon: Play, end: false }
: null;
// „Siłownie” jest zawsze widoczne (wirtualne siłownie są dostępne dla każdego usera).
let navItems: NavItem[] = [...NAV.slice(0, 3), GYM_NAV, NAV[3]];
@@ -235,7 +239,7 @@ export default function Layout() {
const fullName =
[user?.firstName, user?.lastName].filter(Boolean).join(' ') || user?.email || '?';
const roles = [user?.isAdmin ? 'Admin' : null, isTrainer ? 'Trener' : 'Ćwiczący']
const roles = [user?.isAdmin ? t('roleAdmin') : null, isTrainer ? t('roleTrainer') : t('roleUser')]
.filter(Boolean)
.join(' · ');
@@ -259,7 +263,7 @@ export default function Layout() {
<LanguageToggle />
<Button variant="secondary" size="sm" className="flex-1" onClick={doLogout}>
<LogOut className="w-4 h-4" />
Wyloguj
{t('logout')}
</Button>
</div>
</div>
@@ -274,8 +278,8 @@ export default function Layout() {
<button
type="button"
onClick={doLogout}
aria-label="Wyloguj"
title="Wyloguj"
aria-label={t('logout')}
title={t('logout')}
className="grid h-[38px] w-[38px] cursor-pointer place-items-center rounded-[10px] border border-line bg-card text-dim shadow-card transition-colors hover:border-danger/45 hover:text-danger"
>
<LogOut className="h-5 w-5" />
@@ -304,7 +308,7 @@ export default function Layout() {
<button
type="button"
onClick={() => setDrawerOpen(false)}
aria-label="Zamknij menu"
aria-label={t('common:topbar.closeMenu')}
className="-m-2 cursor-pointer p-2 text-dim hover:text-ink"
>
<X className="h-5 w-5" />
@@ -338,8 +342,8 @@ export default function Layout() {
<button
type="button"
onClick={toggleCollapsed}
aria-label="Rozwiń menu"
title="Rozwiń menu"
aria-label={t('common:topbar.expandMenu')}
title={t('common:topbar.expandMenu')}
className="grid h-7 w-7 flex-none cursor-pointer place-items-center rounded-[10px] border border-line bg-card text-dim shadow-card transition-colors hover:text-ink"
>
<Menu className="h-4 w-4" />
@@ -355,8 +359,8 @@ export default function Layout() {
<button
type="button"
onClick={toggleCollapsed}
aria-label="Zwiń menu"
title="Zwiń menu"
aria-label={t('common:topbar.collapseMenu')}
title={t('common:topbar.collapseMenu')}
className="ml-auto grid h-7 w-7 flex-none cursor-pointer place-items-center rounded-[10px] border border-line bg-card text-dim shadow-card transition-colors hover:text-ink"
>
<Menu className="h-4 w-4" />

View File

@@ -1,4 +1,5 @@
import { createContext, useCallback, useContext, useRef, useState, type ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { AlertCircle, CheckCircle2, Info, X } from 'lucide-react';
export type ToastKind = 'success' | 'error' | 'info';
@@ -29,6 +30,7 @@ const TOAST_STYLES: Record<
};
export function ToastProvider({ children }: { children: ReactNode }) {
const { t } = useTranslation();
const [toasts, setToasts] = useState<Toast[]>([]);
const idRef = useRef(0);
@@ -52,19 +54,19 @@ export function ToastProvider({ children }: { children: ReactNode }) {
aria-live="polite"
className="pointer-events-none fixed bottom-[calc(3rem+max(env(safe-area-inset-bottom),0.75rem))] left-4 right-4 z-[70] flex flex-col gap-2 sm:left-auto sm:right-4 sm:w-80 md:bottom-4"
>
{toasts.map((t) => {
const { icon: Icon, cls } = TOAST_STYLES[t.kind];
{toasts.map((toast) => {
const { icon: Icon, cls } = TOAST_STYLES[toast.kind];
return (
<div
key={t.id}
key={toast.id}
role="status"
className="pointer-events-auto flex animate-in items-start gap-3 rounded-xl border border-line bg-card px-4 py-3 shadow-card duration-200 fade-in-0 slide-in-from-bottom-2"
>
<Icon className={`w-5 h-5 mt-0.5 shrink-0 ${cls}`} />
<div className="text-[0.9rem] flex-1">{t.message}</div>
<div className="text-[0.9rem] flex-1">{toast.message}</div>
<button
onClick={() => dismiss(t.id)}
aria-label="Zamknij powiadomienie"
onClick={() => dismiss(toast.id)}
aria-label={t('closeNotification')}
className="text-dim hover:text-ink cursor-pointer shrink-0"
>
<X className="w-4 h-4" />

View File

@@ -1,5 +1,6 @@
import type { ReactNode } from 'react';
import { useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import { ArrowLeft, ChevronLeft, ChevronRight, X } from 'lucide-react';
import { buttonVariants } from './button';
@@ -37,7 +38,7 @@ export function PageHeader({
export function BackButton({
to,
onClick,
children = 'Wstecz',
children,
className = '',
}: {
to?: string;
@@ -45,20 +46,21 @@ export function BackButton({
children?: ReactNode;
className?: string;
}) {
const { t } = useTranslation();
// na telefonie „Wstecz” siedzi w topmenu („<”) — tu tylko md+
const cls = cn(buttonVariants({ variant: 'ghost', size: 'sm' }), 'max-md:hidden', className);
if (to) {
return (
<Link to={to} className={cls}>
<ArrowLeft className="w-4 h-4" />
{children}
{children ?? t('back')}
</Link>
);
}
return (
<button type="button" onClick={onClick} className={cls}>
<ArrowLeft className="w-4 h-4" />
{children}
{children ?? t('back')}
</button>
);
}
@@ -165,7 +167,7 @@ export function MetaItem({
export function Chip({
children,
onRemove,
removeLabel = 'Usuń',
removeLabel,
className = '',
}: {
children: ReactNode;
@@ -173,6 +175,7 @@ export function Chip({
removeLabel?: string;
className?: string;
}) {
const { t } = useTranslation();
return (
<span
data-slot="chip"
@@ -183,7 +186,7 @@ export function Chip({
<button
type="button"
onClick={onRemove}
aria-label={removeLabel}
aria-label={removeLabel ?? t('remove')}
className="text-dim hover:text-danger cursor-pointer"
>
<X className="w-3.5 h-3.5" />
@@ -233,6 +236,7 @@ export function Tabs({
active: string;
onChange: (id: string) => void;
}) {
const { t } = useTranslation();
const scrollRef = useRef<HTMLDivElement>(null);
const [canPrev, setCanPrev] = useState(false);
const [canNext, setCanNext] = useState(false);
@@ -283,7 +287,7 @@ export function Tabs({
>
<button
type="button"
aria-label="Poprzednie zakładki"
aria-label={t('tabs.prev')}
tabIndex={canPrev ? 0 : -1}
onClick={() => scrollByGroup(-1)}
className="grid h-7 w-7 shrink-0 cursor-pointer place-items-center text-dim transition-colors hover:text-ink"
@@ -333,7 +337,7 @@ export function Tabs({
>
<button
type="button"
aria-label="Następne zakładki"
aria-label={t('tabs.next')}
tabIndex={canNext ? 0 : -1}
onClick={() => scrollByGroup(1)}
className="grid h-7 w-7 shrink-0 cursor-pointer place-items-center text-dim transition-colors hover:text-ink"

View File

@@ -1,5 +1,6 @@
import type { ReactNode } from 'react';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { X } from 'lucide-react';
import { Button } from './button';
import {
@@ -29,6 +30,7 @@ export function Modal({
/** Uchwyt bottom sheeta (mobile) — wizualna wskazówka przyciągania. */
handle?: boolean;
}) {
const { t } = useTranslation();
return (
<Dialog open={open} onOpenChange={(o) => !o && onClose()}>
<DialogContent className={wide ? 'sm:max-w-2xl' : undefined}>
@@ -44,7 +46,7 @@ export function Modal({
</DialogTitle>
<DialogClose asChild>
<button
aria-label="Zamknij"
aria-label={t('close')}
className="p-1.5 -m-1.5 text-dim hover:text-ink cursor-pointer"
>
<X className="w-5 h-5" />
@@ -67,7 +69,7 @@ export function ConfirmDialog({
onConfirm,
title,
description,
confirmLabel = 'Potwierdź',
confirmLabel,
danger,
busy,
}: {
@@ -80,12 +82,13 @@ export function ConfirmDialog({
danger?: boolean;
busy?: boolean;
}) {
const { t } = useTranslation();
return (
<Modal open={open} onClose={onClose} title={title}>
<p className="text-dim text-[0.95rem]">{description}</p>
<div className="flex flex-col-reverse sm:flex-row sm:items-center sm:justify-end gap-3 mt-5">
<Button variant="secondary" onClick={onClose} className="w-full sm:w-auto">
Anuluj
{t('cancel')}
</Button>
<Button
variant={danger ? 'danger' : 'primary'}
@@ -93,7 +96,7 @@ export function ConfirmDialog({
disabled={busy}
className="w-full sm:w-auto"
>
{confirmLabel}
{confirmLabel ?? t('confirm')}
</Button>
</div>
</Modal>
@@ -112,12 +115,13 @@ export function AlertModal({
title: string;
message: string;
}) {
const { t } = useTranslation();
return (
<Modal open={open} onClose={onClose} title={title}>
<p className="text-dim text-[0.95rem]">{message}</p>
<div className="flex flex-col-reverse sm:flex-row sm:justify-end gap-3 mt-5">
<Button onClick={onClose} className="w-full sm:w-auto">
OK
{t('ok')}
</Button>
</div>
</Modal>
@@ -140,6 +144,7 @@ export function NumberPadDialog({
onConfirm: (value: string) => void;
onClose: () => void;
}) {
const { t } = useTranslation();
const [draft, setDraft] = useState(value);
useEffect(() => {
if (open) setDraft(value);
@@ -175,7 +180,7 @@ export function NumberPadDialog({
key={d}
type="button"
onClick={() => press(d)}
aria-label={d === 'C' ? 'Wyczyść' : d === '⌫' ? 'Usuń cyfrę' : d}
aria-label={d === 'C' ? t('clear') : d === '⌫' ? t('deleteDigit') : d}
className="h-14 rounded-[10px] bg-input border border-line text-xl font-semibold text-ink shadow-(--inset-shadow) cursor-pointer hover:border-accent/55 hover:text-accent-text active:bg-line/40 transition-all duration-150"
>
{d}
@@ -184,10 +189,10 @@ export function NumberPadDialog({
</div>
<div className="flex flex-col-reverse sm:flex-row sm:items-center sm:justify-end gap-3">
<Button variant="secondary" onClick={onClose} className="w-full sm:w-auto">
Anuluj
{t('cancel')}
</Button>
<Button onClick={() => onConfirm(draft)} className="w-full sm:w-auto">
Wpisz
{t('input')}
</Button>
</div>
</Modal>
@@ -210,13 +215,14 @@ export function DifficultyDialog({
const parsed = v === '' ? NaN : parseInt(v);
return String(isNaN(parsed) ? 3 : Math.max(1, Math.min(5, parsed)));
};
const { t } = useTranslation();
const [draft, setDraft] = useState(() => normalize(value));
useEffect(() => {
if (open) setDraft(normalize(value));
}, [open, value]);
return (
<Modal open={open} onClose={onClose} title="Trudność">
<Modal open={open} onClose={onClose} title={t('difficulty')}>
<div className="text-center mb-5">
<div className="text-5xl font-bold tabular-nums text-ink">{draft}</div>
</div>
@@ -228,20 +234,20 @@ export function DifficultyDialog({
step={1}
value={parseInt(draft)}
onChange={(e) => setDraft(e.target.value)}
aria-label="Trudność (suwak)"
aria-label={t('difficultySlider')}
className="w-full accent-accent cursor-pointer"
/>
<div className="flex justify-between text-dim text-[0.85rem] mt-2">
<span>łatwo</span>
<span>trudno</span>
<span>{t('difficultyLow')}</span>
<span>{t('difficultyHigh')}</span>
</div>
</div>
<div className="flex flex-col-reverse sm:flex-row sm:items-center sm:justify-end gap-3">
<Button variant="secondary" onClick={onClose} className="w-full sm:w-auto">
Anuluj
{t('cancel')}
</Button>
<Button onClick={() => onConfirm(draft)} className="w-full sm:w-auto">
Wpisz
{t('input')}
</Button>
</div>
</Modal>
@@ -249,11 +255,12 @@ export function DifficultyDialog({
}
/* Metadata for the set fields edited in SetEditDialog. */
const SET_FIELD_META: { key: 'reps' | 'rir' | 'difficulty'; label: string; hint: string }[] = [
{ key: 'reps', label: 'Powtórzenia', hint: 'liczba powtórzeń' },
{ key: 'rir', label: 'RIR', hint: '0–10 (reps in reserve)' },
{ key: 'difficulty', label: 'Trudność', hint: '1–5' },
];
const SET_FIELD_META: { key: 'reps' | 'rir' | 'difficulty'; labelKey: string; hintKey: string }[] =
[
{ key: 'reps', labelKey: 'plans:set.reps', hintKey: 'plans:set.repsHint' },
{ key: 'rir', labelKey: 'plans:set.rir', hintKey: 'plans:set.rirHint' },
{ key: 'difficulty', labelKey: 'common:difficulty', hintKey: 'plans:set.difficultyHint' },
];
export type SetFieldValues = { reps: string; rir: string; difficulty: string; note: string };
@@ -286,6 +293,7 @@ export function SetEditDialog({
onSave: (values: SetFieldValues) => void;
onClose: () => void;
}) {
const { t } = useTranslation();
const [drafts, setDrafts] = useState<SetFieldValues>(values);
const [editingField, setEditingField] = useState<'reps' | 'rir' | 'difficulty' | null>(null);
useEffect(() => {
@@ -312,27 +320,29 @@ export function SetEditDialog({
return (
<>
<Modal open={open} onClose={onClose} title={title ?? `Uzupełnij serię ${setIndex + 1}`}>
<Modal
open={open}
onClose={onClose}
title={title ?? t('plans:set.fillTitle', { n: setIndex + 1 })}
>
{rest && rest.remaining > 0 && (
<div className="mb-3 rounded-[10px] border border-line bg-input px-3.5 py-3">
<div className="flex items-center gap-2">
<span className="live-dot" aria-hidden="true" />
<span className="text-[0.8125rem] text-dim">przerwa</span>
<span className="text-[0.8125rem] text-dim">{t('plans:set.rest')}</span>
<b className="font-display text-[1rem] font-bold tabular-nums text-ink">
{fmtRestSec(rest.remaining)}
</b>
<span className="text-[0.8125rem] text-dim">/ {fmtRestSec(rest.total)}</span>
</div>
{rest.resetsOnSave && (
<p className="text-dim text-[0.8125rem] mt-1.5">
Zapisanie serii zrestartuje odliczanie przerwy.
</p>
<p className="text-dim text-[0.8125rem] mt-1.5">{t('plans:set.restReset')}</p>
)}
</div>
)}
{hasNorm && (
<Button variant="secondary" size="sm" onClick={fillNorm} className="mb-3 w-full">
Norma spełniona
{t('plans:set.normDone')}
</Button>
)}
<div className="space-y-2 mb-4">
@@ -343,7 +353,7 @@ export function SetEditDialog({
onClick={() => setEditingField(f.key)}
className="w-full flex items-center justify-between rounded-[10px] border border-line bg-input px-3.5 py-3 shadow-(--inset-shadow) cursor-pointer hover:border-accent/55 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60"
>
<span className="text-[0.9rem] font-semibold text-ink">{f.label}</span>
<span className="text-[0.9rem] font-semibold text-ink">{t(f.labelKey)}</span>
<span
className={`text-[1.1rem] font-bold ${drafts[f.key] ? 'text-ink' : 'text-dim'}`}
>
@@ -355,13 +365,13 @@ export function SetEditDialog({
{/* Opcjonalny komentarz trenującego — widoczny także trenerowi w historii sesji. */}
<div className="mb-4">
<span className="text-[0.9rem] font-semibold text-ink">
Komentarz <span className="font-normal text-dim">(opcjonalnie)</span>
{t('plans:set.comment')} <span className="font-normal text-dim">{t('plans:set.optional')}</span>
</span>
<textarea
aria-label="Komentarz do serii"
aria-label={t('plans:set.commentAria')}
rows={2}
maxLength={2000}
placeholder="np. ostatnia seria była ciężka"
placeholder={t('plans:set.commentPlaceholder')}
value={drafts.note}
onChange={(e) => setDrafts((d) => ({ ...d, note: e.target.value }))}
className="mt-1.5 w-full resize-y rounded-[10px] border border-line bg-input px-3.5 py-2.5 text-[0.9rem] text-ink placeholder:text-dim focus:border-accent/55 focus:outline-none focus:ring-2 focus:ring-accent/60"
@@ -369,10 +379,10 @@ export function SetEditDialog({
</div>
<div className="flex flex-col-reverse sm:flex-row sm:items-center sm:justify-end gap-3">
<Button variant="secondary" onClick={onClose} className="w-full sm:w-auto">
Anuluj
{t('cancel')}
</Button>
<Button onClick={() => onSave(drafts)} className="w-full sm:w-auto">
Zapisz
{t('save')}
</Button>
</div>
</Modal>
@@ -390,9 +400,9 @@ export function SetEditDialog({
) : (
<NumberPadDialog
open
title={editing.label}
title={t(editing.labelKey)}
value={drafts[editing.key]}
hint={editing.hint}
hint={t(editing.hintKey)}
onConfirm={(v) => {
setDrafts((d) => ({ ...d, [editing.key]: v }));
setEditingField(null);

View File

@@ -1,4 +1,5 @@
import type { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { cn } from '../../lib/utils';
export function H1({ className, children }: { className?: string; children: ReactNode }) {
@@ -25,6 +26,7 @@ export function Muted({ className, children }: { className?: string; children: R
return <span className={cn('text-dim', className)}>{children}</span>;
}
export function Loading({ children = 'Ładowanie…' }: { children?: ReactNode }) {
return <div className="text-dim">{children}</div>;
export function Loading({ children }: { children?: ReactNode }) {
const { t } = useTranslation();
return <div className="text-dim">{children ?? t('loading')}</div>;
}

View File

@@ -1,12 +1,11 @@
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { ChevronLeft, ChevronRight } from 'lucide-react';
import { Button } from './button';
import { formatMonth } from '../../lib/format';
import { fmtDate } from '../../lib/format';
import { cn } from '../../lib/utils';
const WEEK_DOWS = ['Pn', 'Wt', 'Śr', 'Cz', 'Pt', 'So', 'Nd'];
function localDayKey(d: Date): string {
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
}
@@ -56,6 +55,8 @@ export function WeekPicker({
/** Dodatkowe klasy dla roota (np. max-w-none, żeby wypełnić kontener). */
className?: string;
}) {
const { t } = useTranslation();
const dows = t('weekPicker.dows', { returnObjects: true }) as string[];
const now = new Date();
const [view, setView] = useState<[number, number]>(() => {
if (value) {
@@ -91,7 +92,7 @@ export function WeekPicker({
size="sm"
variant="ghost"
onClick={() => shift(-1)}
aria-label="Poprzedni miesiąc"
aria-label={t('topbar.prevMonth')}
className="max-md:h-11 max-md:w-11 max-md:justify-center"
>
<ChevronLeft className="w-4 h-4" />
@@ -103,14 +104,14 @@ export function WeekPicker({
size="sm"
variant="ghost"
onClick={() => shift(1)}
aria-label="Następny miesiąc"
aria-label={t('topbar.nextMonth')}
className="max-md:h-11 max-md:w-11 max-md:justify-center"
>
<ChevronRight className="w-4 h-4" />
</Button>
</div>
<div className="grid grid-cols-7 gap-1" role="group" aria-label="Wybór tygodnia startu">
{WEEK_DOWS.map((d) => (
<div className="grid grid-cols-7 gap-1" role="group" aria-label={t('weekPicker.groupAria')}>
{dows.map((d) => (
<div key={d} className="text-center text-dim text-[0.75rem] py-1">
{d}
</div>
@@ -144,8 +145,10 @@ export function WeekPicker({
</div>
{value && (
<p className="text-dim text-[0.8rem] mt-2">
Start: tydzień {fmtDate(value)} –{' '}
{fmtDate(localDayKey(addDaysLocal(parseIsoLocal(value), 6)))}
{t('weekPicker.startWeek', {
from: fmtDate(value),
to: fmtDate(localDayKey(addDaysLocal(parseIsoLocal(value), 6))),
})}
</p>
)}
</div>

View File

@@ -10,17 +10,72 @@ import plCommon from './locales/pl/common.json';
import plAuth from './locales/pl/auth.json';
import plErrors from './locales/pl/errors.json';
import plBody from './locales/pl/body.json';
import plNav from './locales/pl/nav.json';
import plPlans from './locales/pl/plans.json';
import plDashboard from './locales/pl/dashboard.json';
import plGyms from './locales/pl/gyms.json';
import plMessages from './locales/pl/messages.json';
import plFeed from './locales/pl/feed.json';
import plProfile from './locales/pl/profile.json';
import plTrainees from './locales/pl/trainees.json';
import enCommon from './locales/en/common.json';
import enAuth from './locales/en/auth.json';
import enErrors from './locales/en/errors.json';
import enBody from './locales/en/body.json';
import enNav from './locales/en/nav.json';
import enPlans from './locales/en/plans.json';
import enDashboard from './locales/en/dashboard.json';
import enGyms from './locales/en/gyms.json';
import enMessages from './locales/en/messages.json';
import enFeed from './locales/en/feed.json';
import enProfile from './locales/en/profile.json';
import enTrainees from './locales/en/trainees.json';
export const NAMESPACES = ['common', 'auth', 'errors', 'body'] as const;
export const NAMESPACES = [
'common',
'auth',
'errors',
'body',
'nav',
'plans',
'dashboard',
'gyms',
'messages',
'feed',
'profile',
'trainees',
] as const;
export type Namespace = (typeof NAMESPACES)[number];
const resources = {
pl: { common: plCommon, auth: plAuth, errors: plErrors, body: plBody },
en: { common: enCommon, auth: enAuth, errors: enErrors, body: enBody },
pl: {
common: plCommon,
auth: plAuth,
errors: plErrors,
body: plBody,
nav: plNav,
plans: plPlans,
dashboard: plDashboard,
gyms: plGyms,
messages: plMessages,
feed: plFeed,
profile: plProfile,
trainees: plTrainees,
},
en: {
common: enCommon,
auth: enAuth,
errors: enErrors,
body: enBody,
nav: enNav,
plans: enPlans,
dashboard: enDashboard,
gyms: enGyms,
messages: enMessages,
feed: enFeed,
profile: enProfile,
trainees: enTrainees,
},
} as const;
const initial = detectInitialLanguage();

View File

@@ -11,6 +11,42 @@
"difficulty": "Difficulty",
"difficultyLow": "easy",
"difficultyHigh": "hard",
"difficultySlider": "Difficulty (slider)",
"toggleTheme": "Toggle theme",
"toggleLanguage": "Change language"
"toggleLanguage": "Change language",
"ok": "OK",
"remove": "Remove",
"loading": "Loading…",
"back": "Back",
"searchShort": "Search…",
"all": "All",
"noData": "No data",
"topbar": {
"openMenu": "Open menu",
"closeMenu": "Close menu",
"expandMenu": "Expand menu",
"collapseMenu": "Collapse menu",
"filters": "Filters",
"add": "Add",
"actions": "Actions",
"search": "Search",
"searchPlans": "Search plan",
"searchGyms": "Search gym",
"searchTrainees": "Search trainee",
"searchInvitations": "Search invitation",
"searchMessages": "Search conversation",
"prevMonth": "Previous month",
"nextMonth": "Next month",
"prevMonthWithData": "Previous month with data",
"nextMonthWithData": "Next month with data"
},
"tabs": {
"prev": "Previous tabs",
"next": "Next tabs"
},
"weekPicker": {
"dows": ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
"groupAria": "Start week selection",
"startWeek": "Start: week {{from}} – {{to}}"
}
}

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1,18 @@
{
"dashboard": "Dashboard",
"plans": "Plans",
"calendar": "My calendar",
"profile": "Profile",
"gyms": "Gyms",
"trainees": "Trainees",
"invitations": "Invitations",
"messages": "Messages",
"announcements": "Updates",
"adminPanel": "Admin panel",
"training": "Training",
"logout": "Log out",
"roleAdmin": "Admin",
"roleTrainer": "Trainer",
"roleUser": "Trainee",
"mainNav": "Main navigation"
}

View File

@@ -0,0 +1,18 @@
{
"set": {
"fillTitle": "Complete set {{n}}",
"editTitle": "Edit set {{n}}",
"rest": "rest",
"restReset": "Saving the set will restart the rest countdown.",
"normDone": "Target met",
"reps": "Reps",
"rir": "RIR",
"repsHint": "number of reps",
"rirHint": "0–10 (reps in reserve)",
"difficultyHint": "1–5",
"comment": "Comment",
"optional": "(optional)",
"commentAria": "Comment for the set",
"commentPlaceholder": "e.g. the last set was hard"
}
}

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1 @@
{}

View File

@@ -11,6 +11,42 @@
"difficulty": "Trudność",
"difficultyLow": "łatwo",
"difficultyHigh": "trudno",
"difficultySlider": "Trudność (suwak)",
"toggleTheme": "Przełącz motyw",
"toggleLanguage": "Zmień język"
"toggleLanguage": "Zmień język",
"ok": "OK",
"remove": "Usuń",
"loading": "Ładowanie…",
"back": "Wstecz",
"searchShort": "Szukaj…",
"all": "Wszystkie",
"noData": "Brak danych",
"topbar": {
"openMenu": "Otwórz menu",
"closeMenu": "Zamknij menu",
"expandMenu": "Rozwiń menu",
"collapseMenu": "Zwiń menu",
"filters": "Filtry",
"add": "Dodawanie",
"actions": "Akcje",
"search": "Wyszukiwarka",
"searchPlans": "Szukaj planu",
"searchGyms": "Szukaj siłowni",
"searchTrainees": "Szukaj podopiecznego",
"searchInvitations": "Szukaj zaproszenia",
"searchMessages": "Szukaj rozmowy",
"prevMonth": "Poprzedni miesiąc",
"nextMonth": "Następny miesiąc",
"prevMonthWithData": "Poprzedni miesiąc z danymi",
"nextMonthWithData": "Następny miesiąc z danymi"
},
"tabs": {
"prev": "Poprzednie zakładki",
"next": "Następne zakładki"
},
"weekPicker": {
"dows": ["Pn", "Wt", "Śr", "Cz", "Pt", "So", "Nd"],
"groupAria": "Wybór tygodnia startu",
"startWeek": "Start: tydzień {{from}} – {{to}}"
}
}

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1,18 @@
{
"dashboard": "Dashboard",
"plans": "Plany",
"calendar": "Mój kalendarz",
"profile": "Profil",
"gyms": "Siłownie",
"trainees": "Podopieczni",
"invitations": "Zaproszenia",
"messages": "Komunikator",
"announcements": "Aktualności",
"adminPanel": "Panel admina",
"training": "Trening",
"logout": "Wyloguj",
"roleAdmin": "Admin",
"roleTrainer": "Trener",
"roleUser": "Ćwiczący",
"mainNav": "Nawigacja główna"
}

View File

@@ -0,0 +1,18 @@
{
"set": {
"fillTitle": "Uzupełnij serię {{n}}",
"editTitle": "Edytuj serię {{n}}",
"rest": "przerwa",
"restReset": "Zapisanie serii zrestartuje odliczanie przerwy.",
"normDone": "Norma spełniona",
"reps": "Powtórzenia",
"rir": "RIR",
"repsHint": "liczba powtórzeń",
"rirHint": "0–10 (reps in reserve)",
"difficultyHint": "1–5",
"comment": "Komentarz",
"optional": "(opcjonalnie)",
"commentAria": "Komentarz do serii",
"commentPlaceholder": "np. ostatnia seria była ciężka"
}
}

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1 @@
{}

View File

@@ -1,4 +1,5 @@
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Calendar, ChevronLeft, ChevronRight } from 'lucide-react';
import { Button } from '../components/ui';
import { formatMonth, MONTH_SHORT } from '../lib/format';
@@ -39,6 +40,7 @@ export function MonthPickerCore({
availableMonths,
allowAll = false,
}: MonthPickerCoreProps) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const [panelYear, setPanelYear] = useState<number | null>(null);
@@ -67,7 +69,7 @@ export function MonthPickerCore({
variant="ghost"
disabled={!prevMonth}
onClick={() => prevMonth && setMonth(prevMonth)}
aria-label={allowAll ? 'Poprzedni miesiąc' : 'Poprzedni miesiąc z danymi'}
aria-label={allowAll ? t('topbar.prevMonth') : t('topbar.prevMonthWithData')}
>
<ChevronLeft className="w-4 h-4" />
</Button>
@@ -87,14 +89,14 @@ export function MonthPickerCore({
className="max-md:flex-1"
>
<Calendar className="w-4 h-4" />
{month === '' && allowAll ? 'Wszystkie' : formatMonth(month)}
{month === '' && allowAll ? t('all') : formatMonth(month)}
</Button>
<Button
size="sm"
variant="ghost"
disabled={!nextMonth}
onClick={() => nextMonth && setMonth(nextMonth)}
aria-label={allowAll ? 'Następny miesiąc' : 'Następny miesiąc z danymi'}
aria-label={allowAll ? t('topbar.nextMonth') : t('topbar.nextMonthWithData')}
>
<ChevronRight className="w-4 h-4" />
</Button>
@@ -120,7 +122,7 @@ export function MonthPickerCore({
month === '' ? 'bg-accent/15 text-accent-text' : 'text-ink hover:bg-line/30'
}`}
>
Wszystkie
{t('all')}
</button>
{/* filtr po roku: lata z danymi (nowe → stare) */}
<div className="flex flex-wrap gap-1.5 mb-3">
@@ -164,7 +166,7 @@ export function MonthPickerCore({
</div>
</>
) : availableMonths.length === 0 ? (
<p className="text-dim text-[0.85rem] px-1">Brak danych</p>
<p className="text-dim text-[0.85rem] px-1">{t('noData')}</p>
) : (
<>
{/* filtr po roku: lata z danymi (nowe → stare) */}

View File

@@ -1,4 +1,5 @@
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { ChevronLeft, Filter, Menu, MoreHorizontal, Plus, Search, X } from 'lucide-react';
import { useTopbarStore } from './store';
@@ -8,25 +9,26 @@ import { cn } from '../lib/utils';
import { GroupButton, useIsMobile } from './GroupButton';
import type { TopbarAction } from './types';
const SEARCH_LABELS: Record<SearchableSection, string> = {
plans: 'Szukaj planu',
gyms: 'Szukaj siłowni',
trainees: 'Szukaj podopiecznego',
invitations: 'Szukaj zaproszenia',
messages: 'Szukaj rozmowy',
const SEARCH_KEYS: Record<SearchableSection, string> = {
plans: 'topbar.searchPlans',
gyms: 'topbar.searchGyms',
trainees: 'topbar.searchTrainees',
invitations: 'topbar.searchInvitations',
messages: 'topbar.searchMessages',
};
function SectionSearchInput({ section }: { section: SearchableSection }) {
const { t } = useTranslation();
const query = useListSearch((s) => s.queries[section]);
const setQuery = useListSearch((s) => s.setQuery);
return (
<Input
type="search"
size="sm"
placeholder="Szukaj…"
placeholder={t('searchShort')}
value={query}
onChange={(e) => setQuery(section, e.target.value)}
aria-label={SEARCH_LABELS[section]}
aria-label={t(SEARCH_KEYS[section])}
/>
);
}
@@ -88,6 +90,7 @@ function useVisualViewportBottom() {
* Konfigurację rejestruje aktywna strona (useTopbar).
*/
export function Topbar({ onMenuOpen }: { onMenuOpen?: () => void }) {
const { t } = useTranslation();
const config = useTopbarStore((s) => s.config);
const openGroup = useTopbarStore((s) => s.openGroup);
const setOpenGroup = useTopbarStore((s) => s.setOpenGroup);
@@ -146,7 +149,7 @@ export function Topbar({ onMenuOpen }: { onMenuOpen?: () => void }) {
<button
type="button"
onClick={onMenuOpen}
aria-label="Otwórz menu"
aria-label={t('topbar.openMenu')}
/* telefon: te samo wykończenie co pigułka tytułu (tło+blur, border,
zaokrąglenie), kreski w kolorze tekstu nagłówka */
className="grid h-[34px] w-[34px] flex-none cursor-pointer place-items-center rounded-[10px] border border-line/60 bg-bg/72 text-ink shadow-[0_8px_24px_-10px_rgba(0,0,0,0.55)] backdrop-blur-md transition-colors hover:text-accent-text max-md:h-9 max-md:w-9 md:hidden"
@@ -228,7 +231,7 @@ export function Topbar({ onMenuOpen }: { onMenuOpen?: () => void }) {
<button
type="button"
onClick={() => (config.onBack ? config.onBack() : navigate(config.back!))}
aria-label="Wstecz"
aria-label={t('back')}
className="grid h-[34px] w-[34px] flex-none cursor-pointer place-items-center rounded-[10px] border border-line bg-card text-dim shadow-card transition-colors hover:text-ink md:hidden"
>
<ChevronLeft className="h-4 w-4" />
@@ -239,7 +242,7 @@ export function Topbar({ onMenuOpen }: { onMenuOpen?: () => void }) {
{hasFilters && (
<GroupButton
icon={Filter}
label="Filtry"
label={t('topbar.filters')}
active={config?.filterActive}
open={openGroup === 'filters'}
onToggle={() => toggle('filters')}
@@ -268,7 +271,7 @@ export function Topbar({ onMenuOpen }: { onMenuOpen?: () => void }) {
{plusActions.length > 0 && (
<GroupButton
icon={Plus}
label="Dodawanie"
label={t('topbar.add')}
open={openGroup === 'add'}
onToggle={() => toggle('add')}
>
@@ -280,7 +283,7 @@ export function Topbar({ onMenuOpen }: { onMenuOpen?: () => void }) {
{otherActions.length > 0 && (
<GroupButton
icon={MoreHorizontal}
label="Akcje"
label={t('topbar.actions')}
open={openGroup === 'actions'}
onToggle={() => toggle('actions')}
flatOnMobile={config?.flatActionsMobile}
@@ -295,7 +298,7 @@ export function Topbar({ onMenuOpen }: { onMenuOpen?: () => void }) {
{config?.search && (
<GroupButton
icon={Search}
label="Wyszukiwarka"
label={t('topbar.search')}
active={searchQuery !== ''}
open={openGroup === 'search'}
onToggle={() => toggle('search')}
@@ -311,7 +314,7 @@ export function Topbar({ onMenuOpen }: { onMenuOpen?: () => void }) {
{menuOpen && (
<button
type="button"
aria-label="Zamknij menu"
aria-label={t('topbar.closeMenu')}
onClick={() => setOpenGroup(null)}
className="topbar-expand grid h-[34px] w-[34px] flex-none cursor-pointer place-items-center rounded-[10px] border border-line bg-card text-dim shadow-card transition-colors hover:text-danger md:hidden"
>