I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
This commit is contained in:
@@ -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<AddressFormValues>) => void;
|
||||
required?: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation('gyms');
|
||||
const postalInvalid = values.postalCode.length > 0 && !PL_POSTAL_CODE.test(values.postalCode);
|
||||
return (
|
||||
<>
|
||||
<Field label="Ulica i numer">
|
||||
<Field label={t('address.street')}>
|
||||
<Input
|
||||
value={values.addressLine1}
|
||||
onChange={(e) => onChange({ addressLine1: e.target.value })}
|
||||
placeholder="np. Mokotowska 12A"
|
||||
placeholder={t('address.streetPh')}
|
||||
required={required}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Lokal">
|
||||
<Field label={t('address.premises')}>
|
||||
<Input
|
||||
value={values.addressLine2}
|
||||
onChange={(e) => onChange({ addressLine2: e.target.value })}
|
||||
placeholder="np. piętro 2, lokal 5"
|
||||
placeholder={t('address.premisesPh')}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Kod pocztowy">
|
||||
<Field label={t('address.postalCode')}>
|
||||
<Input
|
||||
value={values.postalCode}
|
||||
onChange={(e) => onChange({ postalCode: formatPostalCodeInput(e.target.value) })}
|
||||
@@ -87,26 +89,26 @@ export function AddressFields({
|
||||
required={required}
|
||||
/>
|
||||
{postalInvalid && (
|
||||
<p className="mt-1 text-[0.8rem] text-danger">Format kodu: 00-001</p>
|
||||
<p className="mt-1 text-[0.8rem] text-danger">{t('address.postalFormatError')}</p>
|
||||
)}
|
||||
</Field>
|
||||
<Field label="Miasto">
|
||||
<Field label={t('address.city')}>
|
||||
<Input
|
||||
value={values.city}
|
||||
onChange={(e) => onChange({ city: e.target.value })}
|
||||
placeholder="np. Warszawa"
|
||||
placeholder={t('address.cityPh')}
|
||||
autoComplete="address-level2"
|
||||
required={required}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Kraj">
|
||||
<Field label={t('address.country')}>
|
||||
<Select
|
||||
value={values.countryCode}
|
||||
onChange={(e) => onChange({ countryCode: e.target.value })}
|
||||
>
|
||||
{COUNTRIES.map((c) => (
|
||||
<option key={c.code} value={c.code}>
|
||||
{c.label}
|
||||
{t(c.labelKey)}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
|
||||
@@ -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 (
|
||||
<div className="space-y-2">
|
||||
{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 (
|
||||
<div key={name} className="flex items-center gap-2">
|
||||
<div key={i} className="flex items-center gap-2">
|
||||
<span className="w-28 shrink-0 text-dim text-[0.875rem]">{name}</span>
|
||||
<input
|
||||
type="checkbox"
|
||||
aria-label={`${name}: dostępny`}
|
||||
aria-label={`${name}: ${t('avail.available')}`}
|
||||
checked={enabled}
|
||||
onChange={(e) => setDay(i, e.target.checked ? { start, end } : null)}
|
||||
className="size-4 accent-[var(--accent)]"
|
||||
/>
|
||||
<Select
|
||||
aria-label={`${name}: od`}
|
||||
aria-label={`${name}: ${t('avail.from')}`}
|
||||
value={start}
|
||||
disabled={!enabled}
|
||||
onChange={(e) => setDay(i, { start: e.target.value, end })}
|
||||
@@ -50,7 +53,7 @@ export function AvailabilityEditor({
|
||||
</Select>
|
||||
<span className="text-dim">–</span>
|
||||
<Select
|
||||
aria-label={`${name}: do`}
|
||||
aria-label={`${name}: ${t('avail.to')}`}
|
||||
value={end}
|
||||
disabled={!enabled}
|
||||
onChange={(e) => setDay(i, { start, end: e.target.value })}
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
import type { ExerciseProgress } from '../api/types';
|
||||
import { fmtDate, fmtVolume } from '../lib/format';
|
||||
import { localizedName } from '../lib/localizedName';
|
||||
import { MUSCLE_NAMES } from '../lib/labels';
|
||||
import { muscleName } from '../lib/labels';
|
||||
import { Badge, Tabs } from './ui';
|
||||
|
||||
const TOOLTIP_STYLE = {
|
||||
@@ -72,9 +72,7 @@ export default function ExerciseProgressCards({ exercises }: { exercises: Exerci
|
||||
</strong>
|
||||
{isPr && <Badge color="green">PR</Badge>}
|
||||
</div>
|
||||
<div className="text-[0.8125rem] text-dim">
|
||||
{MUSCLE_NAMES[ex.muscle] || ex.muscle}
|
||||
</div>
|
||||
<div className="text-[0.8125rem] text-dim">{muscleName(ex.muscle)}</div>
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center gap-3">
|
||||
<div className="text-right">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Search, X } from 'lucide-react';
|
||||
import type { Gym } from '../api/types';
|
||||
|
||||
@@ -15,6 +16,7 @@ export function GymPicker({
|
||||
value: string;
|
||||
onChange: (id: string) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [query, setQuery] = useState('');
|
||||
const [open, setOpen] = useState(false);
|
||||
const selected = gyms.find((g) => g.id === value);
|
||||
@@ -37,9 +39,9 @@ export function GymPicker({
|
||||
<input
|
||||
role="combobox"
|
||||
aria-expanded={open}
|
||||
aria-label="Szukaj siłowni"
|
||||
aria-label={t('picker.gymAria')}
|
||||
className="w-full bg-transparent py-2.5 text-[0.95rem] focus:outline-none"
|
||||
placeholder={selected && !open ? '' : 'Szukaj siłowni…'}
|
||||
placeholder={selected && !open ? '' : t('picker.gymPh')}
|
||||
value={open ? query : (selected?.name ?? '')}
|
||||
onChange={(e) => {
|
||||
setQuery(e.target.value);
|
||||
@@ -50,7 +52,7 @@ export function GymPicker({
|
||||
{selected && !open && (
|
||||
<button
|
||||
type="button"
|
||||
aria-label="Wyczyść wybór siłowni"
|
||||
aria-label={t('picker.gymClear')}
|
||||
onClick={() => onChange('')}
|
||||
className="shrink-0 cursor-pointer text-dim hover:text-ink"
|
||||
>
|
||||
@@ -61,12 +63,14 @@ export function GymPicker({
|
||||
{open && (
|
||||
<div
|
||||
role="listbox"
|
||||
aria-label="Lista siłowni"
|
||||
aria-label={t('picker.gymList')}
|
||||
className="absolute z-20 mt-1.5 max-h-56 w-full overflow-y-auto rounded-xl border border-line bg-card shadow-xl"
|
||||
>
|
||||
{filtered.length === 0 ? (
|
||||
<div className="px-3.5 py-3 text-[0.875rem] text-dim">
|
||||
{query.trim() ? `Brak siłowni o nazwie „${query.trim()}”` : 'Brak dostępnych siłowni'}
|
||||
{query.trim()
|
||||
? t('picker.gymNoResults', { query: query.trim() })
|
||||
: t('picker.gymEmpty')}
|
||||
</div>
|
||||
) : (
|
||||
filtered.map((g) => (
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Check } from 'lucide-react';
|
||||
import type { GymRole } from '../api/types';
|
||||
import { GYM_ROLE_META, GYM_ROLE_ORDER, GYM_ROLE_PILL_ACTIVE } from '../lib/roles';
|
||||
@@ -33,6 +34,7 @@ export function GymRolePicker({
|
||||
showExplain = true,
|
||||
className,
|
||||
}: GymRolePickerProps) {
|
||||
const { t } = useTranslation();
|
||||
const [explained, setExplained] = useState<GymRole | null>(null);
|
||||
const locked = value.length <= minRoles;
|
||||
|
||||
@@ -63,9 +65,9 @@ export function GymRolePicker({
|
||||
type="button"
|
||||
role="checkbox"
|
||||
aria-checked={active}
|
||||
aria-label={`${GYM_ROLE_META[role].label} — ${labelPrefix}`}
|
||||
aria-description={GYM_ROLE_META[role].summary}
|
||||
title={disabled ? lockTitle : GYM_ROLE_META[role].summary}
|
||||
aria-label={`${t(GYM_ROLE_META[role].labelKey)} — ${labelPrefix}`}
|
||||
aria-description={t(GYM_ROLE_META[role].summaryKey)}
|
||||
title={disabled ? lockTitle : t(GYM_ROLE_META[role].summaryKey)}
|
||||
disabled={disabled}
|
||||
onClick={() => toggle(role)}
|
||||
className={cn(
|
||||
@@ -74,7 +76,7 @@ export function GymRolePicker({
|
||||
)}
|
||||
>
|
||||
<Check className={cn('h-4 w-4', active ? '' : 'opacity-0')} />
|
||||
{GYM_ROLE_META[role].label}
|
||||
{t(GYM_ROLE_META[role].labelKey)}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
@@ -83,22 +85,19 @@ export function GymRolePicker({
|
||||
<div className="mt-2.5 min-h-[2.5rem] rounded-xl border border-line bg-input/40 px-3 py-2.5 text-[0.875rem]">
|
||||
{meta ? (
|
||||
<>
|
||||
<span className="font-semibold text-ink">{meta.label}: </span>
|
||||
<span className="text-dim">{meta.summary}</span>
|
||||
<span className="font-semibold text-ink">{t(meta.labelKey)}: </span>
|
||||
<span className="text-dim">{t(meta.summaryKey)}</span>
|
||||
<ul className="mt-1.5 space-y-0.5 text-dim">
|
||||
{meta.grants.map((g) => (
|
||||
{meta.grantKeys.map((g) => (
|
||||
<li key={g} className="flex gap-1.5">
|
||||
<span className="text-accent-text">•</span>
|
||||
<span>{g}</span>
|
||||
<span>{t(g)}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
) : (
|
||||
<span className="text-dim">
|
||||
Wybierz rolę, aby zobaczyć, co dokładnie daje. Ćwiczący = trenuje, Trener = prowadzi
|
||||
podopiecznych, Właściciel = zarządza siłownią.
|
||||
</span>
|
||||
<span className="text-dim">{t('roles.picker.hint')}</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -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<string | null>(initialOpenSessionId ?? null);
|
||||
|
||||
return (
|
||||
@@ -78,7 +78,7 @@ export default function HistoryTable({ sessions, initialOpenSessionId }: History
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
<Badge color={st.color}>{st.label}</Badge>
|
||||
<Badge color={st.color}>{t(st.labelKey)}</Badge>
|
||||
{open ? (
|
||||
<ChevronUp className="h-4 w-4 text-dim" />
|
||||
) : (
|
||||
|
||||
@@ -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) — <a href>, nie <NavLink>. */
|
||||
@@ -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 (
|
||||
<nav
|
||||
className={cn('flex flex-col gap-0.5', collapsed ? 'px-2' : 'px-3')}
|
||||
aria-label="Nawigacja główna"
|
||||
aria-label={t('nav.mainNav')}
|
||||
>
|
||||
{items.map((item) => {
|
||||
const rowClass = (isActive: boolean) =>
|
||||
@@ -100,7 +102,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">{t(item.labelKey)}</span>;
|
||||
|
||||
if (item.external) {
|
||||
return (
|
||||
@@ -108,8 +110,8 @@ function NavLinks({
|
||||
key={item.to}
|
||||
href={item.to}
|
||||
onClick={onNavigate}
|
||||
title={collapsed ? item.label : undefined}
|
||||
aria-label={collapsed ? item.label : undefined}
|
||||
title={collapsed ? t(item.labelKey) : undefined}
|
||||
aria-label={collapsed ? t(item.labelKey) : undefined}
|
||||
className={rowClass(false)}
|
||||
>
|
||||
{icon}
|
||||
@@ -124,8 +126,8 @@ function NavLinks({
|
||||
to={item.to}
|
||||
end={item.end}
|
||||
onClick={onNavigate}
|
||||
title={collapsed ? item.label : undefined}
|
||||
aria-label={collapsed ? item.label : undefined}
|
||||
title={collapsed ? t(item.labelKey) : undefined}
|
||||
aria-label={collapsed ? t(item.labelKey) : undefined}
|
||||
className={({ isActive }) => rowClass(isActive)}
|
||||
>
|
||||
{({ isActive }) => (
|
||||
@@ -151,13 +153,14 @@ function NavLinks({
|
||||
}
|
||||
|
||||
function NavSections({ collapsed, onNavigate }: { collapsed: boolean; onNavigate?: () => void }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className={cn('flex flex-col', collapsed ? 'gap-2' : 'gap-4')}>
|
||||
{SECTIONS.map((section) => (
|
||||
<div key={section.label}>
|
||||
<div key={section.labelKey}>
|
||||
{!collapsed && (
|
||||
<div className="mb-1 px-6 text-[10.5px] font-bold uppercase tracking-[0.13em] text-dim/80">
|
||||
{section.label}
|
||||
{t(section.labelKey)}
|
||||
</div>
|
||||
)}
|
||||
<NavLinks items={section.items} collapsed={collapsed} onNavigate={onNavigate} />
|
||||
@@ -168,6 +171,7 @@ function NavSections({ collapsed, onNavigate }: { collapsed: boolean; onNavigate
|
||||
}
|
||||
|
||||
export default function Layout() {
|
||||
const { t } = useTranslation();
|
||||
const { user, logout } = useAuth();
|
||||
const navigate = useNavigate();
|
||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||
@@ -186,7 +190,10 @@ export default function Layout() {
|
||||
const isTrainer = useIsTrainer();
|
||||
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('nav.roleAdmin') : null,
|
||||
isTrainer ? t('nav.roleTrainer') : t('nav.roleMember'),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' · ');
|
||||
|
||||
@@ -210,7 +217,7 @@ export default function Layout() {
|
||||
<LanguageToggle />
|
||||
<Button variant="secondary" size="sm" className="flex-1" onClick={doLogout}>
|
||||
<LogOut className="w-4 h-4" />
|
||||
Wyloguj
|
||||
{t('nav.logout')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -225,8 +232,8 @@ export default function Layout() {
|
||||
<button
|
||||
type="button"
|
||||
onClick={doLogout}
|
||||
aria-label="Wyloguj"
|
||||
title="Wyloguj"
|
||||
aria-label={t('nav.logout')}
|
||||
title={t('nav.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" />
|
||||
@@ -248,13 +255,13 @@ export default function Layout() {
|
||||
<div className="flex items-center gap-2.5">
|
||||
<Brandmark size={26} />
|
||||
<span className="font-display text-[1.05rem] font-bold tracking-[-0.02em]">
|
||||
FitOS Admin
|
||||
{t('appName')}
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setDrawerOpen(false)}
|
||||
aria-label="Zamknij menu"
|
||||
aria-label={t('topbar.closeMenu')}
|
||||
className="-m-2 cursor-pointer p-2 text-dim hover:text-ink"
|
||||
>
|
||||
<X className="h-5 w-5" />
|
||||
@@ -284,8 +291,8 @@ export default function Layout() {
|
||||
<button
|
||||
type="button"
|
||||
onClick={toggleCollapsed}
|
||||
aria-label="Rozwiń menu"
|
||||
title="Rozwiń menu"
|
||||
aria-label={t('nav.expandMenu')}
|
||||
title={t('nav.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" />
|
||||
@@ -295,14 +302,14 @@ export default function Layout() {
|
||||
<div className="flex min-w-0 items-center gap-2.5">
|
||||
<Brandmark size={26} />
|
||||
<span className="font-display text-[1.05rem] font-bold tracking-[-0.02em]">
|
||||
FitOS Admin
|
||||
{t('appName')}
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={toggleCollapsed}
|
||||
aria-label="Zwiń menu"
|
||||
title="Zwiń menu"
|
||||
aria-label={t('nav.collapseMenu')}
|
||||
title={t('nav.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" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Search, X } from 'lucide-react';
|
||||
import type { User } from '../api/types';
|
||||
|
||||
@@ -11,9 +12,9 @@ export function UserPicker({
|
||||
users,
|
||||
value,
|
||||
onChange,
|
||||
ariaLabel = 'Szukaj użytkownika',
|
||||
listLabel = 'Lista użytkowników',
|
||||
emptyLabel = 'Brak użytkowników',
|
||||
ariaLabel,
|
||||
listLabel,
|
||||
emptyLabel,
|
||||
}: {
|
||||
users: User[];
|
||||
value: string;
|
||||
@@ -22,8 +23,10 @@ export function UserPicker({
|
||||
listLabel?: string;
|
||||
emptyLabel?: string;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [query, setQuery] = useState('');
|
||||
const [open, setOpen] = useState(false);
|
||||
const aria = ariaLabel ?? t('picker.userAria');
|
||||
const selected = users.find((u) => u.id === value);
|
||||
const q = query.trim().toLowerCase();
|
||||
const filtered = q
|
||||
@@ -49,9 +52,9 @@ export function UserPicker({
|
||||
<input
|
||||
role="combobox"
|
||||
aria-expanded={open}
|
||||
aria-label={ariaLabel}
|
||||
aria-label={aria}
|
||||
className="w-full bg-transparent py-2.5 text-[0.95rem] focus:outline-none"
|
||||
placeholder={selected && !open ? '' : `${ariaLabel}…`}
|
||||
placeholder={selected && !open ? '' : `${aria}…`}
|
||||
value={open ? query : selected ? userLabel(selected) : ''}
|
||||
onChange={(e) => {
|
||||
setQuery(e.target.value);
|
||||
@@ -62,7 +65,7 @@ export function UserPicker({
|
||||
{selected && !open && (
|
||||
<button
|
||||
type="button"
|
||||
aria-label="Wyczyść wybór użytkownika"
|
||||
aria-label={t('picker.userClear')}
|
||||
onClick={() => onChange('')}
|
||||
className="shrink-0 cursor-pointer text-dim hover:text-ink"
|
||||
>
|
||||
@@ -73,12 +76,14 @@ export function UserPicker({
|
||||
{open && (
|
||||
<div
|
||||
role="listbox"
|
||||
aria-label={listLabel}
|
||||
aria-label={listLabel ?? t('picker.userList')}
|
||||
className="absolute z-20 mt-1.5 max-h-56 w-full overflow-y-auto rounded-xl border border-line bg-card shadow-xl"
|
||||
>
|
||||
{filtered.length === 0 ? (
|
||||
<div className="px-3.5 py-3 text-[0.875rem] text-dim">
|
||||
{q ? `Brak użytkowników dla „${query.trim()}”` : emptyLabel}
|
||||
{q
|
||||
? t('picker.userNoResults', { query: query.trim() })
|
||||
: (emptyLabel ?? t('picker.userEmpty'))}
|
||||
</div>
|
||||
) : (
|
||||
filtered.map((u) => (
|
||||
|
||||
@@ -2,11 +2,19 @@ import type { ReactNode } from 'react';
|
||||
import { cn } from '../../lib/utils';
|
||||
|
||||
function ErrorText({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return <div data-slot="alert" className={cn('mt-2 text-[0.9rem] text-danger', className)}>{children}</div>;
|
||||
return (
|
||||
<div data-slot="alert" className={cn('mt-2 text-[0.9rem] text-danger', className)}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SuccessText({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return <div data-slot="alert" className={cn('mt-2 text-[0.9rem] text-accent-text', className)}>{children}</div>;
|
||||
return (
|
||||
<div data-slot="alert" className={cn('mt-2 text-[0.9rem] text-accent-text', className)}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { ErrorText, SuccessText };
|
||||
|
||||
@@ -21,7 +21,8 @@ const badgeVariants = cva(
|
||||
);
|
||||
|
||||
export interface BadgeProps
|
||||
extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'color'>,
|
||||
extends
|
||||
Omit<React.HTMLAttributes<HTMLSpanElement>, 'color'>,
|
||||
VariantProps<typeof badgeVariants> {}
|
||||
|
||||
function Badge({ className, color, ...props }: BadgeProps) {
|
||||
|
||||
@@ -26,7 +26,8 @@ const buttonVariants = cva(
|
||||
);
|
||||
|
||||
export interface ButtonProps
|
||||
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||||
extends
|
||||
React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||||
Omit<VariantProps<typeof buttonVariants>, 'size'> {
|
||||
size?: 'md' | 'sm';
|
||||
}
|
||||
|
||||
@@ -6,7 +6,10 @@ const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElemen
|
||||
<div
|
||||
ref={ref}
|
||||
data-slot="card"
|
||||
className={cn('bg-(image:--card-grad) border border-line rounded-xl shadow-card p-5 sm:p-6 mb-4', className)}
|
||||
className={cn(
|
||||
'bg-(image:--card-grad) border border-line rounded-xl shadow-card p-5 sm:p-6 mb-4',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { ArrowLeft, X } from 'lucide-react';
|
||||
import { buttonVariants } from './button';
|
||||
import { H2, H3, Muted } from './typography';
|
||||
@@ -138,7 +139,7 @@ export function ListRow({
|
||||
export function Chip({
|
||||
children,
|
||||
onRemove,
|
||||
removeLabel = 'Usuń',
|
||||
removeLabel,
|
||||
className = '',
|
||||
}: {
|
||||
children: ReactNode;
|
||||
@@ -146,6 +147,7 @@ export function Chip({
|
||||
removeLabel?: string;
|
||||
className?: string;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<span
|
||||
data-slot="chip"
|
||||
@@ -156,7 +158,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" />
|
||||
|
||||
@@ -52,12 +52,23 @@ const DialogContent = React.forwardRef<
|
||||
DialogContent.displayName = 'DialogContent';
|
||||
|
||||
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div data-slot="dialog-header" className={cn('mb-4 flex items-center justify-between gap-3', className)} {...props} />
|
||||
<div
|
||||
data-slot="dialog-header"
|
||||
className={cn('mb-4 flex items-center justify-between gap-3', className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
DialogHeader.displayName = 'DialogHeader';
|
||||
|
||||
const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div data-slot="dialog-footer" className={cn('mt-5 flex flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-end', className)} {...props} />
|
||||
<div
|
||||
data-slot="dialog-footer"
|
||||
className={cn(
|
||||
'mt-5 flex flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-end',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
DialogFooter.displayName = 'DialogFooter';
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { X } from 'lucide-react';
|
||||
import { Button } from './button';
|
||||
import {
|
||||
@@ -32,7 +33,10 @@ export function Modal({
|
||||
<h3 className="text-[1.05rem] font-semibold">{title}</h3>
|
||||
</DialogTitle>
|
||||
<DialogClose asChild>
|
||||
<button aria-label="Zamknij" className="p-1.5 -m-1.5 text-dim hover:text-ink cursor-pointer">
|
||||
<button
|
||||
aria-label="Zamknij"
|
||||
className="p-1.5 -m-1.5 text-dim hover:text-ink cursor-pointer"
|
||||
>
|
||||
<X className="w-5 h-5" />
|
||||
</button>
|
||||
</DialogClose>
|
||||
@@ -53,7 +57,7 @@ export function ConfirmDialog({
|
||||
onConfirm,
|
||||
title,
|
||||
description,
|
||||
confirmLabel = 'Potwierdź',
|
||||
confirmLabel,
|
||||
danger,
|
||||
busy,
|
||||
}: {
|
||||
@@ -66,15 +70,21 @@ 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'} onClick={onConfirm} disabled={busy} className="w-full sm:w-auto">
|
||||
{confirmLabel}
|
||||
<Button
|
||||
variant={danger ? 'danger' : 'primary'}
|
||||
onClick={onConfirm}
|
||||
disabled={busy}
|
||||
className="w-full sm:w-auto"
|
||||
>
|
||||
{confirmLabel ?? t('confirm')}
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
@@ -18,12 +18,19 @@ const inputVariants = cva(
|
||||
);
|
||||
|
||||
export interface InputProps
|
||||
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'>,
|
||||
extends
|
||||
Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'>,
|
||||
VariantProps<typeof inputVariants> {}
|
||||
|
||||
const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
||||
({ className, size, type, ...props }, ref) => (
|
||||
<input type={type} data-slot="input" className={cn(inputVariants({ size }), className)} ref={ref} {...props} />
|
||||
<input
|
||||
type={type}
|
||||
data-slot="input"
|
||||
className={cn(inputVariants({ size }), className)}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
);
|
||||
Input.displayName = 'Input';
|
||||
|
||||
@@ -6,7 +6,10 @@ const Label = React.forwardRef<HTMLLabelElement, React.LabelHTMLAttributes<HTMLL
|
||||
<label
|
||||
ref={ref}
|
||||
data-slot="label"
|
||||
className={cn('block mb-1.5 text-dim text-[11px] font-bold uppercase tracking-[0.1em]', className)}
|
||||
className={cn(
|
||||
'block mb-1.5 text-dim text-[11px] font-bold uppercase tracking-[0.1em]',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
|
||||
@@ -2,7 +2,10 @@ import { cn } from '../../lib/utils';
|
||||
|
||||
function Progress({ percent, className }: { percent: number; className?: string }) {
|
||||
return (
|
||||
<div data-slot="progress" className={cn('h-2 overflow-hidden rounded-full bg-input', className)}>
|
||||
<div
|
||||
data-slot="progress"
|
||||
className={cn('h-2 overflow-hidden rounded-full bg-input', className)}
|
||||
>
|
||||
<div
|
||||
className="h-full rounded-full bg-(image:--progress-grad) transition-[width] duration-300"
|
||||
style={{ width: `${Math.max(0, Math.min(100, percent))}%` }}
|
||||
|
||||
@@ -2,7 +2,9 @@ import * as React from 'react';
|
||||
import { cn } from '../../lib/utils';
|
||||
|
||||
function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div data-slot="skeleton" className={cn('skeleton-shimmer rounded-xl', className)} {...props} />;
|
||||
return (
|
||||
<div data-slot="skeleton" className={cn('skeleton-shimmer rounded-xl', className)} {...props} />
|
||||
);
|
||||
}
|
||||
|
||||
export { Skeleton };
|
||||
|
||||
@@ -18,12 +18,18 @@ const textareaVariants = cva(
|
||||
);
|
||||
|
||||
export interface TextareaProps
|
||||
extends React.TextareaHTMLAttributes<HTMLTextAreaElement>,
|
||||
extends
|
||||
React.TextareaHTMLAttributes<HTMLTextAreaElement>,
|
||||
VariantProps<typeof textareaVariants> {}
|
||||
|
||||
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
||||
({ className, size, ...props }, ref) => (
|
||||
<textarea data-slot="textarea" className={cn(textareaVariants({ size }), className)} ref={ref} {...props} />
|
||||
<textarea
|
||||
data-slot="textarea"
|
||||
className={cn(textareaVariants({ size }), className)}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
);
|
||||
Textarea.displayName = 'Textarea';
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { cn } from '../../lib/utils';
|
||||
|
||||
export function H1({ className, children }: { className?: string; children: ReactNode }) {
|
||||
return <h1 className={cn('text-[1.75rem] font-bold tracking-[-0.02em] mb-4', className)}>{children}</h1>;
|
||||
return (
|
||||
<h1 className={cn('text-[1.75rem] font-bold tracking-[-0.02em] mb-4', className)}>
|
||||
{children}
|
||||
</h1>
|
||||
);
|
||||
}
|
||||
|
||||
export function H2({ className, children }: { className?: string; children: ReactNode }) {
|
||||
return <h2 className={cn('text-[1.25rem] font-bold tracking-[-0.01em] mb-3', className)}>{children}</h2>;
|
||||
return (
|
||||
<h2 className={cn('text-[1.25rem] font-bold tracking-[-0.01em] mb-3', className)}>
|
||||
{children}
|
||||
</h2>
|
||||
);
|
||||
}
|
||||
|
||||
export function H3({ className, children }: { className?: string; children: ReactNode }) {
|
||||
@@ -17,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>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user