UI: klikalna karta statystyk na profilu i porzadki na tablicy silowni
Statystyki profilu w jednej klikalnej karcie (bez wiersza Statystyki w menu, etykieta Tonaz); na tablicy: Tablica nad Bytnoscia, tytul i nazwa silowni w jednym wierszu, usunete opisy sekcji; przyciski filtrow/sortowania pokazuja tylko stan (kategoria w aria-label); MonthPicker jako pigulka; akcje profilu w grupie Zarzadzaj.
This commit is contained in:
@@ -12,13 +12,17 @@ import { cn } from '../lib/utils';
|
||||
export function FilterDropdown({
|
||||
icon,
|
||||
label,
|
||||
srLabel,
|
||||
active,
|
||||
options,
|
||||
selected,
|
||||
onSelect,
|
||||
}: {
|
||||
icon: ReactNode;
|
||||
/** Etykieta widoczna na przycisku — tylko bieżący stan (bez przedrostka kategorii). */
|
||||
label: string;
|
||||
/** Pełna etykieta dla czytników/selectorów (np. „Status: Wszystkie”) — oszczędza miejsce wizualnie. */
|
||||
srLabel?: string;
|
||||
active: boolean;
|
||||
options: { id: string; label: string }[];
|
||||
selected: string;
|
||||
@@ -31,6 +35,7 @@ export function FilterDropdown({
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => setOpen((o) => !o)}
|
||||
aria-label={srLabel}
|
||||
aria-haspopup="true"
|
||||
aria-expanded={open}
|
||||
/* accent tylko gdy wybrano nie-domyślną opcję; telefon: pełna szerokość */
|
||||
|
||||
@@ -320,14 +320,12 @@
|
||||
"consentOnToast": "Your nickname is now visible on the board",
|
||||
"consentOffToast": "Nickname hidden — the board shows you anonymously",
|
||||
"rankingTitle": "Training ranking",
|
||||
"rankingDesc": "Effectively completed sessions (last {{days}}) — nickname only with consent",
|
||||
"rankSessions_one": "{{count}} session",
|
||||
"rankSessions_other": "{{count}} sessions",
|
||||
"rankDays_one": "{{count}} day",
|
||||
"rankDays_other": "{{count}} days",
|
||||
"emptyRanking": "No sessions in this period or nobody opted in to show a nickname.",
|
||||
"emptyRanking": "No information",
|
||||
"aggregateTitle": "Gym aggregate",
|
||||
"aggregateDesc": "Anonymous totals of everyone training in this period",
|
||||
"aggTonnage": "Tonnage",
|
||||
"aggSessions": "Sessions",
|
||||
"aggExercisers": "Exercisers",
|
||||
@@ -335,10 +333,8 @@
|
||||
"equivBus": "city bus (12.5 t)",
|
||||
"equivCar": "car (1.5 t)",
|
||||
"musclesTitle": "Muscle groups of the gym",
|
||||
"musclesDesc": "Sets and tonnage in the selected period (everyone anonymous)",
|
||||
"emptyMuscles": "No sets in this period.",
|
||||
"recordsTitle": "1RM records",
|
||||
"recordsDesc": "Max estimated 1RM (Epley) from the whole history — author only with consent",
|
||||
"anon": "anonymous",
|
||||
"emptyRecords": "No measurable records."
|
||||
},
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
"minutes": "{{n}} min",
|
||||
"tonnageInRange": "Tonnage (range)",
|
||||
"tonnageKgName": "Tonnage",
|
||||
"weeklyTonnage": "12-week tonnage",
|
||||
"weeklyTonnage": "Tonnage",
|
||||
"musclesTitle": "What you train the most",
|
||||
"musclesDesc": "Sets and tonnage by muscle — a set counts toward the exercise's primary muscle.",
|
||||
"weekdayTitle": "Training days",
|
||||
|
||||
@@ -334,7 +334,6 @@
|
||||
"consentOnToast": "Twój nick jest teraz widoczny na tablicy",
|
||||
"consentOffToast": "Nick ukryty — tablica pokazuje Cię anonimowo",
|
||||
"rankingTitle": "Ranking treningów",
|
||||
"rankingDesc": "Skutecznie zrealizowane sesje (ostatnie {{days}}) — nick tylko za zgodą",
|
||||
"rankSessions_one": "{{count}} sesja",
|
||||
"rankSessions_few": "{{count}} sesje",
|
||||
"rankSessions_many": "{{count}} sesji",
|
||||
@@ -343,9 +342,8 @@
|
||||
"rankDays_few": "{{count}} dni",
|
||||
"rankDays_many": "{{count}} dni",
|
||||
"rankDays_other": "{{count}} dni",
|
||||
"emptyRanking": "Brak treningów w tym okresie albo nikt nie wyraził zgody na nick.",
|
||||
"emptyRanking": "Brak informacji",
|
||||
"aggregateTitle": "Zbiorowość siłowni",
|
||||
"aggregateDesc": "Anonimowe sumy wszystkich ćwiczących w tym okresie",
|
||||
"aggTonnage": "Tonaż",
|
||||
"aggSessions": "Sesje",
|
||||
"aggExercisers": "Ćwiczący",
|
||||
@@ -353,10 +351,8 @@
|
||||
"equivBus": "autobus (12,5 t)",
|
||||
"equivCar": "samochód osobowy (1,5 t)",
|
||||
"musclesTitle": "Partie ciała siłowni",
|
||||
"musclesDesc": "Serie i tonaż w wybranym okresie (wszyscy anonimowo)",
|
||||
"emptyMuscles": "Brak serii w tym okresie.",
|
||||
"recordsTitle": "Rekordy 1RM",
|
||||
"recordsDesc": "Maksymalne szacowane 1RM (Epley) z całej historii — autor tylko za zgodą",
|
||||
"anon": "anonim",
|
||||
"emptyRecords": "Brak mierzalnych rekordów."
|
||||
},
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
"minutes": "{{n}} min",
|
||||
"tonnageInRange": "Tonaż w zakresie",
|
||||
"tonnageKgName": "Tonaż",
|
||||
"weeklyTonnage": "Tonaż 12 tygodni",
|
||||
"weeklyTonnage": "Tonaż",
|
||||
"musclesTitle": "Co trenujesz najczęściej",
|
||||
"musclesDesc": "Serie i tonaż wg partii — seria liczy się do mięśnia głównego ćwiczenia.",
|
||||
"weekdayTitle": "Dni treningowe",
|
||||
|
||||
@@ -65,6 +65,9 @@ export default function Announcements() {
|
||||
}
|
||||
};
|
||||
|
||||
/* przycisk filtra = tylko bieżący stan; kategoria („Typ") zostaje w aria-label */
|
||||
const typeValue = t(TYPE_FILTERS.find((f) => f.id === typeFilter)?.labelKey ?? 'filters.ALL');
|
||||
|
||||
useTopbar({
|
||||
title: t('nav:announcements'),
|
||||
search: 'announcements',
|
||||
@@ -75,9 +78,8 @@ export default function Announcements() {
|
||||
<FilterDropdown
|
||||
key="type"
|
||||
icon={<Filter className="w-4 h-4" />}
|
||||
label={t('filters.typeLabel', {
|
||||
label: t(TYPE_FILTERS.find((f) => f.id === typeFilter)?.labelKey ?? 'filters.ALL'),
|
||||
})}
|
||||
label={typeValue}
|
||||
srLabel={t('filters.typeLabel', { label: typeValue })}
|
||||
active={typeFilter !== 'ALL'}
|
||||
options={TYPE_FILTERS.map((f) => ({ id: f.id, label: t(f.labelKey) }))}
|
||||
selected={typeFilter}
|
||||
|
||||
@@ -217,25 +217,21 @@ export default function GymBoard({ tv = false }: { tv?: boolean }) {
|
||||
<span className="text-[1.05rem] text-dim">{t('board.tvRefresh')}</span>
|
||||
</header>
|
||||
) : (
|
||||
<>
|
||||
<PageHeader title={t('board.title')} actions={<BackButton to={`/gyms/${id}`} />} />
|
||||
{/* HERO-LITE: nazwa siłowni (tytuł h1 należy do topbaru) */}
|
||||
<div className="mb-5 flex flex-wrap items-end justify-between gap-3">
|
||||
<span className="font-display text-[1.35rem] font-bold tracking-[-0.02em]">
|
||||
/* jeden wiersz: „Tablica" + nazwa siłowni (badge) + wstecz */
|
||||
<PageHeader
|
||||
title={t('board.title')}
|
||||
badge={
|
||||
<span className="min-w-0 truncate font-display text-[1.05rem] font-semibold tracking-[-0.02em] text-dim">
|
||||
{gymName}
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
actions={<BackButton to={`/gyms/${id}`} />}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* RANKING: skuteczne sesje w zakresie; nick tylko członków z opt-in */}
|
||||
<Card>
|
||||
<SectionHeader
|
||||
title={t('board.rankingTitle')}
|
||||
description={t('board.rankingDesc', {
|
||||
days: t('stats.rangeDays', { count: data.rangeDays }),
|
||||
})}
|
||||
/>
|
||||
<SectionHeader title={t('board.rankingTitle')} />
|
||||
{ranking.length === 0 ? (
|
||||
<p className="text-[0.875rem] text-dim">{t('board.emptyRanking')}</p>
|
||||
) : (
|
||||
@@ -280,7 +276,7 @@ export default function GymBoard({ tv = false }: { tv?: boolean }) {
|
||||
|
||||
{/* ZBIOROWOŚĆ: anonimowe agregaty wszystkich ćwiczących + ekwiwalenty tonażu */}
|
||||
<Card>
|
||||
<SectionHeader title={t('board.aggregateTitle')} description={t('board.aggregateDesc')} />
|
||||
<SectionHeader title={t('board.aggregateTitle')} />
|
||||
<div className={`grid gap-3 ${tv ? 'grid-cols-3' : 'grid-cols-2 sm:grid-cols-3'}`}>
|
||||
<Kpi label={t('board.aggTonnage')} value={fmtVolume(aggregate.tonnageKg)} tv={tv} />
|
||||
<Kpi label={t('board.aggSessions')} value={aggregate.sessions} tv={tv} />
|
||||
@@ -306,7 +302,7 @@ export default function GymBoard({ tv = false }: { tv?: boolean }) {
|
||||
|
||||
{/* PARTIE CIAŁA: serie i tonaż wg partii pierwotnej (współdzielony pasek + legenda) */}
|
||||
<Card>
|
||||
<SectionHeader title={t('board.musclesTitle')} description={t('board.musclesDesc')} />
|
||||
<SectionHeader title={t('board.musclesTitle')} />
|
||||
{aggregate.muscles.length === 0 ? (
|
||||
<p className="text-[0.875rem] text-dim">{t('board.emptyMuscles')}</p>
|
||||
) : (
|
||||
@@ -316,7 +312,7 @@ export default function GymBoard({ tv = false }: { tv?: boolean }) {
|
||||
|
||||
{/* REKORDY 1RM: Epley z całej historii; autor tylko gdy wyraził zgodę */}
|
||||
<Card>
|
||||
<SectionHeader title={t('board.recordsTitle')} description={t('board.recordsDesc')} />
|
||||
<SectionHeader title={t('board.recordsTitle')} />
|
||||
{records.length === 0 ? (
|
||||
<p className="text-[0.875rem] text-dim">{t('board.emptyRecords')}</p>
|
||||
) : (
|
||||
|
||||
@@ -951,12 +951,13 @@ export default function GymDetail() {
|
||||
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||
{gym.kind === 'REAL' && <GalleryTile gym={gym} />}
|
||||
<EquipmentTile gym={gym} />
|
||||
{gym.kind === 'REAL' && isMember && <BoardTile gymId={gym.id} />}
|
||||
<AnnouncementsTile gymId={gym.id} className="sm:col-span-2" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex min-w-0 flex-col gap-4">
|
||||
{/* Tablica nad Bytnością: kafelek prowadzi na podstronę tablicy */}
|
||||
{gym.kind === 'REAL' && isMember && <BoardTile gymId={gym.id} />}
|
||||
{gym.kind === 'REAL' && <PresenceSection gymId={gym.id} />}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -50,16 +50,20 @@ export default function Messages() {
|
||||
const [groupByRole, setGroupByRole] = useState(false);
|
||||
const [activeRoleTab, setActiveRoleTab] = useState<string | null>(null);
|
||||
|
||||
/* przycisk sortowania = tylko bieżący stan; kategoria („Sortuj") zostaje w aria-label */
|
||||
const sortValue = t(SORT_OPTIONS.find((s) => s.id === sortKey)?.labelKey ?? 'sort.none');
|
||||
|
||||
useTopbar({
|
||||
title: t('nav:messages'),
|
||||
search: 'messages',
|
||||
filters: [
|
||||
/* sortowanie: przycisk „Sortuj: <wartość>” + rozwijany select (kompaktowo w grupie filtrów) */
|
||||
/* sortowanie: przycisk „<stan>” + rozwijany select (prefix tylko w aria-label, oszczędność miejsca) */
|
||||
<div key="sort" className="relative">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => setSortOpen((o) => !o)}
|
||||
aria-label={`${t('sortPrefix')}${sortValue}`}
|
||||
aria-haspopup="true"
|
||||
aria-expanded={sortOpen}
|
||||
/* pomarańcz (accent) tylko gdy wybrano nie-domyślne sortowanie; telefon: pełna szerokość */
|
||||
@@ -69,8 +73,7 @@ export default function Messages() {
|
||||
)}
|
||||
>
|
||||
<ArrowUpDown className="w-4 h-4" />
|
||||
{t('sortPrefix')}
|
||||
{t(SORT_OPTIONS.find((s) => s.id === sortKey)?.labelKey ?? 'sort.none')}
|
||||
{sortValue}
|
||||
<ChevronDown className={`w-4 h-4 transition-transform ${sortOpen ? 'rotate-180' : ''}`} />
|
||||
</Button>
|
||||
{sortOpen && (
|
||||
@@ -97,11 +100,13 @@ export default function Messages() {
|
||||
</>
|
||||
)}
|
||||
</div>,
|
||||
/* grupowanie wg roli rozmówcy — opcja (domyślnie lista płaska) */
|
||||
/* grupowanie wg roli rozmówcy — opcja (domyślnie lista płaska);
|
||||
md+: tylko ikona (stan = accent + aria-pressed), telefon: z etykietą */
|
||||
<Button
|
||||
key="group"
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
aria-label={t('groupByRole')}
|
||||
aria-pressed={groupByRole}
|
||||
onClick={() => setGroupByRole((v) => !v)}
|
||||
className={cn(
|
||||
@@ -110,7 +115,7 @@ export default function Messages() {
|
||||
)}
|
||||
>
|
||||
<Users className="w-4 h-4" />
|
||||
{t('groupByRole')}
|
||||
<span className="hidden max-md:inline">{t('groupByRole')}</span>
|
||||
</Button>,
|
||||
],
|
||||
filterActive: sortKey !== 'none' || groupByRole,
|
||||
|
||||
@@ -61,6 +61,13 @@ export default function Plans() {
|
||||
const [statusFilter, setStatusFilter] = useState<'ALL' | Plan['status']>('ALL');
|
||||
const [sortKey, setSortKey] = useState<SortKey>('default');
|
||||
|
||||
/* przyciski filtrów pokazują tylko bieżący stan (oszczędność miejsca);
|
||||
kategoria zostaje wyłącznie w aria-label (czytnik + stabilne selektory testów) */
|
||||
const statusValue = t(
|
||||
STATUS_FILTERS.find((s) => s.id === statusFilter)?.labelKey ?? 'filters.ALL',
|
||||
);
|
||||
const sortValue = t(SORT_OPTIONS.find((s) => s.id === sortKey)?.labelKey ?? 'sorts.default');
|
||||
|
||||
useTopbar({
|
||||
title: t('nav:plans'),
|
||||
search: 'plans',
|
||||
@@ -68,9 +75,8 @@ export default function Plans() {
|
||||
<FilterDropdown
|
||||
key="status"
|
||||
icon={<Filter className="w-4 h-4" />}
|
||||
label={t('list.statusLabel', {
|
||||
label: t(STATUS_FILTERS.find((s) => s.id === statusFilter)?.labelKey ?? 'filters.ALL'),
|
||||
})}
|
||||
label={statusValue}
|
||||
srLabel={t('list.statusLabel', { label: statusValue })}
|
||||
active={statusFilter !== 'ALL'}
|
||||
options={STATUS_FILTERS.map((s) => ({ id: s.id, label: t(s.labelKey) }))}
|
||||
selected={statusFilter}
|
||||
@@ -79,9 +85,8 @@ export default function Plans() {
|
||||
<FilterDropdown
|
||||
key="sort"
|
||||
icon={<ArrowUpDown className="w-4 h-4" />}
|
||||
label={t('list.sortLabel', {
|
||||
label: t(SORT_OPTIONS.find((s) => s.id === sortKey)?.labelKey ?? 'sorts.default'),
|
||||
})}
|
||||
label={sortValue}
|
||||
srLabel={t('list.sortLabel', { label: sortValue })}
|
||||
active={sortKey !== 'default'}
|
||||
options={SORT_OPTIONS.map((s) => ({ id: s.id, label: t(s.labelKey) }))}
|
||||
selected={sortKey}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
BarChart3,
|
||||
Building2,
|
||||
ChevronRight,
|
||||
Dumbbell,
|
||||
@@ -24,13 +23,12 @@ import {
|
||||
useMyGymClaims,
|
||||
} from '../../api/queries';
|
||||
import { ageFromBirthDate, displayName, fmtDate, fmtVolume } from '../../lib/format';
|
||||
import { localizedName } from '../../lib/localizedName';
|
||||
import { Badge, Card, Skeleton } from '../../components/ui';
|
||||
import { WeeklyTonnageChart } from '../../components/stats/WeeklyTonnageChart';
|
||||
import { Avatar } from '../../components/Avatar';
|
||||
import { useTopbar } from '../../topbar';
|
||||
|
||||
/** Mini-statystyka: ikona + etykieta + wartość. */
|
||||
/** Mini-statystyka: ikona + etykieta + wartość; kafelki współdzielą jedną kartę (podziały line). */
|
||||
function MiniStat({
|
||||
icon: Icon,
|
||||
label,
|
||||
@@ -41,8 +39,8 @@ function MiniStat({
|
||||
value: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex items-center gap-3 rounded-xl border border-line bg-(image:--card-grad) px-3.5 py-3 shadow-card">
|
||||
<span className="grid h-9 w-9 shrink-0 place-items-center rounded-[10px] bg-accent/10 text-accent-text">
|
||||
<div className="flex items-center gap-3 px-4 py-3.5">
|
||||
<span className="grid h-9 w-9 shrink-0 place-items-center rounded-[10px] bg-accent/10 text-accent-text transition-colors group-hover:bg-accent/20">
|
||||
<Icon className="h-4.5 w-4.5" />
|
||||
</span>
|
||||
<div className="min-w-0">
|
||||
@@ -85,11 +83,12 @@ function SectionLink({
|
||||
}
|
||||
|
||||
/**
|
||||
* Przegląd profilu: hero (avatar + nazwa + nick), pasek mini-statystyk
|
||||
* i sekcje jako kompaktowe wiersze-listy (mobile: kolumna, sm+: siatka 2 kol.).
|
||||
* Przegląd profilu: hero (avatar + nazwa + nick), jedna karta statystyk
|
||||
* (mini-statystyki + wykres tonażu + przejście na podstronę) i sekcje jako
|
||||
* kompaktowe wiersze-listy (mobile: kolumna, sm+: siatka 2 kol.).
|
||||
*/
|
||||
export default function Profile() {
|
||||
const { t, i18n } = useTranslation('profile');
|
||||
const { t } = useTranslation('profile');
|
||||
useTopbar({ title: t('nav:profile') });
|
||||
const { data: meData, isLoading: meLoading } = useMe();
|
||||
const { data: bp } = useBodyParameters();
|
||||
@@ -104,11 +103,7 @@ export default function Profile() {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<Skeleton className="h-24" />
|
||||
<div className="grid grid-cols-2 gap-3 sm:grid-cols-3">
|
||||
<Skeleton className="h-[72px]" />
|
||||
<Skeleton className="h-[72px]" />
|
||||
<Skeleton className="h-[72px]" />
|
||||
</div>
|
||||
<Skeleton className="h-[190px]" />
|
||||
<Skeleton className="h-72" />
|
||||
</div>
|
||||
);
|
||||
@@ -173,13 +168,6 @@ export default function Profile() {
|
||||
const progressSummary =
|
||||
progressCount > 0 ? t('common:counters.exercises', { count: progressCount }) : t('noData');
|
||||
|
||||
// statystyki: podsumowanie wiersza „Statystyki” (ulubiona siłownia lub ćwiczenie)
|
||||
const statsSummary = statsData?.topGym
|
||||
? statsData.topGym.name
|
||||
: statsData?.topExercise
|
||||
? localizedName(statsData.topExercise, i18n.language)
|
||||
: t('noData');
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Hero: avatar + nazwa + e-mail + nick */}
|
||||
@@ -194,34 +182,38 @@ export default function Profile() {
|
||||
{user?.nickname && <Badge color="blue">@{user.nickname}</Badge>}
|
||||
</div>
|
||||
|
||||
{/* Pasek mini-statystyk: 2+1 na mobile, 3 w rzędzie na desktop */}
|
||||
<div className="mb-4 grid grid-cols-2 gap-3 sm:grid-cols-3">
|
||||
<MiniStat
|
||||
icon={Flame}
|
||||
label={t('killstreak')}
|
||||
value={dash?.killstreak != null ? String(dash.killstreak) : '—'}
|
||||
/>
|
||||
<MiniStat
|
||||
icon={Dumbbell}
|
||||
label={t('volume7d')}
|
||||
value={volume7d > 0 ? fmtVolume(volume7d) : '—'}
|
||||
/>
|
||||
<MiniStat
|
||||
icon={History}
|
||||
label={t('sessionsLabel')}
|
||||
value={sessions.length > 0 ? String(sessions.length) : '—'}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Wykres tonażu 12 tygodni — wizualne rozwinięcie paska statystyk */}
|
||||
{statsData?.weeklyTonnage && (
|
||||
<Card className="mb-4 p-4">
|
||||
<div className="mb-2 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
|
||||
{t('stats.weeklyTonnage')}
|
||||
{/* Statystyki: jedna karta = jeden link na podstronę (mini-statystyki + wykres tonażu) */}
|
||||
<Link
|
||||
to="/profile/stats"
|
||||
aria-label={t('secStats')}
|
||||
className="group mb-4 block overflow-hidden rounded-xl border border-line bg-(image:--card-grad) shadow-card transition-colors hover:border-accent/40 hover:bg-line/10"
|
||||
>
|
||||
<div className="grid grid-cols-1 divide-y divide-line sm:grid-cols-3 sm:divide-x sm:divide-y-0">
|
||||
<MiniStat
|
||||
icon={Flame}
|
||||
label={t('killstreak')}
|
||||
value={dash?.killstreak != null ? String(dash.killstreak) : '—'}
|
||||
/>
|
||||
<MiniStat
|
||||
icon={Dumbbell}
|
||||
label={t('volume7d')}
|
||||
value={volume7d > 0 ? fmtVolume(volume7d) : '—'}
|
||||
/>
|
||||
<MiniStat
|
||||
icon={History}
|
||||
label={t('sessionsLabel')}
|
||||
value={sessions.length > 0 ? String(sessions.length) : '—'}
|
||||
/>
|
||||
</div>
|
||||
{statsData?.weeklyTonnage && (
|
||||
<div className="border-t border-line px-4 pb-4 pt-3">
|
||||
<div className="mb-2 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
|
||||
{t('stats.weeklyTonnage')}
|
||||
</div>
|
||||
<WeeklyTonnageChart data={statsData.weeklyTonnage} height={104} />
|
||||
</div>
|
||||
<WeeklyTonnageChart data={statsData.weeklyTonnage} height={104} />
|
||||
</Card>
|
||||
)}
|
||||
)}
|
||||
</Link>
|
||||
|
||||
{/* Sekcje: wiersze-listy; mobile kolumna (divide-y), sm+ siatka 2 kol. */}
|
||||
<Card>
|
||||
@@ -253,12 +245,6 @@ export default function Profile() {
|
||||
icon={TrendingUp}
|
||||
summary={progressSummary}
|
||||
/>
|
||||
<SectionLink
|
||||
to="/profile/stats"
|
||||
title={t('secStats')}
|
||||
icon={BarChart3}
|
||||
summary={statsSummary}
|
||||
/>
|
||||
<SectionLink to="/gyms" title={t('nav:gyms')} icon={Building2} summary={gymsSummary} />
|
||||
<SectionLink
|
||||
to="/profile/claims"
|
||||
|
||||
@@ -8,13 +8,12 @@ import {
|
||||
Cake,
|
||||
Check,
|
||||
Clock,
|
||||
KeyRound,
|
||||
Link2,
|
||||
Pencil,
|
||||
Phone,
|
||||
Plus,
|
||||
Ruler,
|
||||
Search,
|
||||
Settings,
|
||||
Sparkles,
|
||||
Trash2,
|
||||
User,
|
||||
@@ -585,18 +584,27 @@ export default function ProfileInfo() {
|
||||
// topbar = rodzic („Profil”), nazwa podstrony w PageHeader poniżej (h2)
|
||||
title: t('nav:profile'),
|
||||
back: '/profile',
|
||||
actions: [
|
||||
{ label: t('editData'), icon: Pencil, onClick: () => setBasicOpen(true) },
|
||||
{ label: t('editMuscles'), icon: Pencil, onClick: openMusclesModal },
|
||||
{ label: t('editSocial'), icon: Pencil, onClick: () => setSocialOpen(true) },
|
||||
// operacje profilu w JEDNEJ grupie „Zarządzaj” (jak /gyms/*): akcje nigdy luzem
|
||||
// na pasku — desktop = „Zarządzaj” + dropdown, tablet = zębatka, telefon = dolny pasek
|
||||
groups: [
|
||||
{
|
||||
label: t('changePassword'),
|
||||
icon: KeyRound,
|
||||
onClick: () => {
|
||||
setPasswordError('');
|
||||
setPasswordForm({ current: '', next: '', confirm: '' });
|
||||
setPasswordOpen(true);
|
||||
},
|
||||
id: 'manage',
|
||||
label: t('groupManage'),
|
||||
icon: Settings,
|
||||
collapsed: true,
|
||||
actions: [
|
||||
{ label: t('editData'), onClick: () => setBasicOpen(true) },
|
||||
{ label: t('editMuscles'), onClick: openMusclesModal },
|
||||
{ label: t('editSocial'), onClick: () => setSocialOpen(true) },
|
||||
{
|
||||
label: t('changePassword'),
|
||||
onClick: () => {
|
||||
setPasswordError('');
|
||||
setPasswordForm({ current: '', next: '', confirm: '' });
|
||||
setPasswordOpen(true);
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -128,16 +128,20 @@ export default function Trainees() {
|
||||
const [searching, setSearching] = useState(false);
|
||||
const [addOpen, setAddOpen] = useState(false);
|
||||
|
||||
/* przycisk sortowania = tylko bieżący stan; kategoria („Sortuj") zostaje w aria-label */
|
||||
const sortValue = t(SORT_OPTIONS.find((s) => s.id === sortKey)?.labelKey ?? 'sortNone');
|
||||
|
||||
useTopbar({
|
||||
title: t('nav:trainees'),
|
||||
search: 'trainees',
|
||||
filters: [
|
||||
/* sortowanie: przycisk „Sortuj: <wartość>” + rozwijany select (kompaktowo w grupie filtrów) */
|
||||
/* sortowanie: przycisk „<stan>” + rozwijany select (prefix tylko w aria-label, oszczędność miejsca) */
|
||||
<div key="sort" className="relative">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => setSortOpen((o) => !o)}
|
||||
aria-label={t('sortBy', { sort: sortValue })}
|
||||
aria-haspopup="true"
|
||||
aria-expanded={sortOpen}
|
||||
/* pomarańcz (accent) tylko gdy wybrano nie-domyślne sortowanie; telefon: pełna szerokość */
|
||||
@@ -147,9 +151,7 @@ export default function Trainees() {
|
||||
)}
|
||||
>
|
||||
<ArrowUpDown className="w-4 h-4" />
|
||||
{t('sortBy', {
|
||||
sort: t(SORT_OPTIONS.find((s) => s.id === sortKey)?.labelKey ?? 'sortNone'),
|
||||
})}
|
||||
{sortValue}
|
||||
<ChevronDown className={`w-4 h-4 transition-transform ${sortOpen ? 'rotate-180' : ''}`} />
|
||||
</Button>
|
||||
{sortOpen && (
|
||||
@@ -177,11 +179,13 @@ export default function Trainees() {
|
||||
</>
|
||||
)}
|
||||
</div>,
|
||||
/* grupowanie wg siłowni — opcja (domyślnie lista płaska) */
|
||||
/* grupowanie wg siłowni — opcja (domyślnie lista płaska);
|
||||
md+: tylko ikona (stan = accent + aria-pressed), telefon: z etykietą */
|
||||
<Button
|
||||
key="group"
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
aria-label={t('groupByGym')}
|
||||
aria-pressed={groupByGym}
|
||||
onClick={() => setGroupByGym((v) => !v)}
|
||||
className={cn(
|
||||
@@ -190,7 +194,7 @@ export default function Trainees() {
|
||||
)}
|
||||
>
|
||||
<Building2 className="w-4 h-4" />
|
||||
{t('groupByGym')}
|
||||
<span className="hidden max-md:inline">{t('groupByGym')}</span>
|
||||
</Button>,
|
||||
],
|
||||
filterActive: sortKey !== 'none' || groupByGym,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Calendar, ChevronLeft, ChevronRight } from 'lucide-react';
|
||||
import { Button } from '../components/ui';
|
||||
import { formatMonth, monthShort } from '../lib/format';
|
||||
|
||||
function currentMonthStr(): string {
|
||||
@@ -63,19 +62,19 @@ export function MonthPickerCore({
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
<div className="flex items-center gap-1">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
{/* Jedna pigułka (jak inne kontrolki topbaru): strzałki NA WEWNĄTRZ, w środku wartość miesiąca */}
|
||||
<div className="flex h-8 items-center overflow-hidden rounded-[10px] border border-line bg-card/60 shadow-card max-md:w-full">
|
||||
<button
|
||||
type="button"
|
||||
disabled={!prevMonth}
|
||||
onClick={() => prevMonth && setMonth(prevMonth)}
|
||||
aria-label={allowAll ? t('topbar.prevMonth') : t('topbar.prevMonthWithData')}
|
||||
className="flex h-full w-8 flex-none cursor-pointer items-center justify-center text-dim transition-colors hover:bg-line/30 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/60 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
>
|
||||
<ChevronLeft className="w-4 h-4" />
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
<ChevronLeft className="w-4 h-4" aria-hidden="true" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
if (open) setOpen(false);
|
||||
else {
|
||||
@@ -85,21 +84,24 @@ export function MonthPickerCore({
|
||||
}}
|
||||
aria-haspopup="true"
|
||||
aria-expanded={open}
|
||||
/* telefon: rozciąga się między strzałkami na pełną szerokość panelu */
|
||||
className="max-md:flex-1"
|
||||
className={`flex h-full min-w-0 flex-1 cursor-pointer items-center justify-center gap-2 px-2 text-[0.8125rem] font-bold transition-colors hover:bg-line/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/60 ${
|
||||
open ? 'text-accent-text' : 'text-ink'
|
||||
}`}
|
||||
>
|
||||
<Calendar className="w-4 h-4" />
|
||||
{month === '' && allowAll ? t('all') : formatMonth(month)}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
<Calendar className="w-4 h-4" aria-hidden="true" />
|
||||
<span className="truncate">
|
||||
{month === '' && allowAll ? t('all') : formatMonth(month)}
|
||||
</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={!nextMonth}
|
||||
onClick={() => nextMonth && setMonth(nextMonth)}
|
||||
aria-label={allowAll ? t('topbar.nextMonth') : t('topbar.nextMonthWithData')}
|
||||
className="flex h-full w-8 flex-none cursor-pointer items-center justify-center text-dim transition-colors hover:bg-line/30 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/60 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
>
|
||||
<ChevronRight className="w-4 h-4" />
|
||||
</Button>
|
||||
<ChevronRight className="w-4 h-4" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
{open && (
|
||||
<>
|
||||
|
||||
@@ -283,7 +283,7 @@ describe('Gym board — podstrona Tablica', () => {
|
||||
const select = screen.getByRole('combobox', { name: 'Zakres tablicy' });
|
||||
expect(select).toHaveValue('30');
|
||||
await user.selectOptions(select, '7');
|
||||
expect(await screen.findByText(/ostatnie 7 dni/)).toBeInTheDocument();
|
||||
expect(select).toHaveValue('7');
|
||||
});
|
||||
|
||||
it('TV mode renders fullscreen board without topbar controls', async () => {
|
||||
|
||||
@@ -247,6 +247,10 @@ describe('Profile overview — hero, statystyki i wiersze sekcji', () => {
|
||||
const sesjeStat = screen.getByText('Sesje').closest('div.min-w-0') as HTMLElement;
|
||||
expect(within(sesjeStat).queryByText(/ostatnia/)).not.toBeInTheDocument();
|
||||
|
||||
// statystyki w jednej karcie: przejście na podstronę jest w karcie, nie w liście sekcji
|
||||
const statsLink = screen.getByRole('link', { name: 'Statystyki' });
|
||||
expect(statsLink).toHaveAttribute('href', '/profile/stats');
|
||||
|
||||
// dane osobowe: imię i nazwisko + wiek/wzrost
|
||||
const infoRow = await screen.findByRole('link', { name: /Dane osobowe/ });
|
||||
expect(infoRow).toHaveTextContent('Jan Kowalski');
|
||||
|
||||
@@ -17,7 +17,7 @@ test('tablica: kafelek prowadzi do podstrony z rankingiem, zbiorowością i reko
|
||||
}) => {
|
||||
await loginToGymDetail(page);
|
||||
|
||||
// REAL + członek: kafelek „Tablica" w siatce sekcji (nie w grupie Zarządzaj)
|
||||
// REAL + członek: kafelek „Tablica" nad kartą Bytności (nie w grupie Zarządzaj)
|
||||
await page.getByRole('link', { name: 'Tablica' }).click();
|
||||
await expect(page).toHaveURL(/\/gyms\/gym-1\/board$/);
|
||||
|
||||
@@ -66,11 +66,12 @@ test('tablica: filtr okresu 7/30/90 odświeża zapytanie bez błędów konsoli',
|
||||
await loginToGymDetail(page);
|
||||
await page.getByRole('link', { name: 'Tablica' }).click();
|
||||
|
||||
await expect(page.getByText(/ostatnie 30 dni/)).toBeVisible();
|
||||
await page.getByRole('combobox', { name: 'Zakres tablicy' }).selectOption('7');
|
||||
await expect(page.getByText(/ostatnie 7 dni/)).toBeVisible();
|
||||
await page.getByRole('combobox', { name: 'Zakres tablicy' }).selectOption('90');
|
||||
await expect(page.getByText(/ostatnie 90 dni/)).toBeVisible();
|
||||
const rangeSelect = page.getByRole('combobox', { name: 'Zakres tablicy' });
|
||||
await expect(rangeSelect).toHaveValue('30');
|
||||
await rangeSelect.selectOption('7');
|
||||
await expect(rangeSelect).toHaveValue('7');
|
||||
await rangeSelect.selectOption('90');
|
||||
await expect(rangeSelect).toHaveValue('90');
|
||||
});
|
||||
|
||||
test('tablica: tryb TV otwiera pełnoekranowy widok bez topbaru i filtrów', async ({ page }) => {
|
||||
|
||||
@@ -57,10 +57,12 @@ test('profil: ustawienie nicku i social media w edycji (per sekcja)', async ({ p
|
||||
});
|
||||
await expect(basicCard.getByRole('button', { name: 'Edytuj' })).toHaveCount(0);
|
||||
await expect(socialCard.getByRole('button', { name: 'Edytuj' })).toHaveCount(0);
|
||||
// akcje zbierone w grupie „Zarządzaj” (jak /gyms/*): kontrolka rozwija dropdown
|
||||
await page.getByRole('button', { name: 'Zarządzaj' }).click();
|
||||
await expect(page.getByRole('button', { name: 'Edytuj dane' })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'Edytuj social' })).toBeVisible();
|
||||
|
||||
// nick — sekcja „Podstawowe dane” (akcja topbaru)
|
||||
// nick — sekcja „Podstawowe dane” (akcja w grupie „Zarządzaj”)
|
||||
await page.getByRole('button', { name: 'Edytuj dane' }).click();
|
||||
const basicDialog = page.getByRole('dialog');
|
||||
await basicDialog.getByPlaceholder('np. fitfan').fill('fitfan');
|
||||
@@ -69,7 +71,8 @@ test('profil: ustawienie nicku i social media w edycji (per sekcja)', async ({ p
|
||||
// po zapisie podgląd pokazuje nick (mock /me jest stateful)
|
||||
await expect(page.getByText('fitfan')).toBeVisible();
|
||||
|
||||
// social media — osobna akcja topbaru z własnym zapisem
|
||||
// social media — osobna akcja w „Zarządzaj” z własnym zapisem
|
||||
await page.getByRole('button', { name: 'Zarządzaj' }).click();
|
||||
await page.getByRole('button', { name: 'Edytuj social' }).click();
|
||||
const socialDialog = page.getByRole('dialog');
|
||||
// wpis social media: domyślna platforma Instagram + URL
|
||||
|
||||
@@ -233,9 +233,9 @@ test('obciążenie po przecinku: kropka normalizowana, znaki obce odrzucane, zap
|
||||
await load.fill('62.5');
|
||||
await expect(load).toHaveValue('62,5');
|
||||
await load.fill('a62x,555!');
|
||||
await expect(load).toHaveValue('62,55');
|
||||
await expect(load).toHaveValue('62,555');
|
||||
|
||||
// zapis akceptowany (do API leci 62.55 jako number)
|
||||
// zapis akceptowany (do API leci 62.555 jako number; sanitizer ucina do 3 miejsc)
|
||||
await page.getByRole('button', { name: 'Dalej' }).click();
|
||||
await page.getByRole('button', { name: 'Zapisz' }).click();
|
||||
await expect(page.getByRole('heading', { name: 'Plan', exact: true })).toBeVisible();
|
||||
|
||||
@@ -52,8 +52,8 @@ test('mobile: dane osobowe — bottom sheet mięśni z zakładkami i wyszukiwark
|
||||
await page.getByRole('link', { name: /Dane osobowe/ }).click();
|
||||
await expect(page.getByRole('heading', { name: 'Dane osobowe', level: 2 })).toBeVisible();
|
||||
|
||||
// menu kontekstowe (telefon = pasek na dole): „Akcje” → „Edytuj mięśnie” → bottom sheet (Radix dialog)
|
||||
await page.getByRole('button', { name: 'Akcje' }).click();
|
||||
// menu kontekstowe (telefon = pasek na dole): zębatka „Zarządzaj” → „Edytuj mięśnie” → bottom sheet (Radix dialog)
|
||||
await page.getByRole('button', { name: 'Zarządzaj' }).click();
|
||||
await page.getByRole('button', { name: 'Edytuj mięśnie' }).click();
|
||||
const dialog = page.getByRole('dialog');
|
||||
await expect(dialog).toBeVisible();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { test, expect, type Page } from './fixtures';
|
||||
import { mockApi } from './mock-api';
|
||||
|
||||
/* Statystyki osobiste: wiersz na przeglądzie profilu + podstrona /profile/stats. */
|
||||
/* Statystyki osobiste: karta statystyk na przeglądzie profilu + podstrona /profile/stats. */
|
||||
|
||||
async function login(page: Page) {
|
||||
await page.goto('/login');
|
||||
@@ -18,20 +18,23 @@ async function openStats(page: Page) {
|
||||
await expect(page.getByRole('heading', { name: 'Statystyki', level: 2 })).toBeVisible();
|
||||
}
|
||||
|
||||
test('przegląd profilu: wiersz Statystyki z podsumowaniem i mini-wykres tonażu', async ({
|
||||
test('przegląd profilu: statystyki w jednej karcie z wykresem i przejściem na podstronę', async ({
|
||||
page,
|
||||
}) => {
|
||||
mockApi(page);
|
||||
await login(page);
|
||||
await page.getByRole('link', { name: 'Mój profil' }).click();
|
||||
|
||||
// wiersz sekcji z podsumowaniem = ulubiona siłownia z mocka
|
||||
const statsRow = page.getByRole('link', { name: /Statystyki/ });
|
||||
await expect(statsRow).toContainText('Żelazna Świątynia');
|
||||
|
||||
// karta z mini-wykres tonażu 12 tygodni
|
||||
await expect(page.getByText('Tonaż 12 tygodni')).toBeVisible();
|
||||
// jedna karta statystyk: mini-statystyki + mini-wykres tonażu
|
||||
await expect(page.getByText('Objętość 7 dni')).toBeVisible();
|
||||
await expect(page.getByText('Tonaż')).toBeVisible();
|
||||
await expect(page.locator('.recharts-bar').first()).toBeVisible();
|
||||
|
||||
// przejście na podstronę jest w karcie statystyk (brak wiersza „Statystyki” w liście sekcji)
|
||||
const statsLink = page.getByRole('link', { name: 'Statystyki' });
|
||||
await expect(statsLink).toHaveCount(1);
|
||||
await statsLink.click();
|
||||
await expect(page.getByRole('heading', { name: 'Statystyki', level: 2 })).toBeVisible();
|
||||
});
|
||||
|
||||
test('podstrona Statystyki: ulubione, KPI, partie, rekordy i ekwiwalenty', async ({ page }) => {
|
||||
|
||||
Reference in New Issue
Block a user