From 3160d9fa2eb2a106621d5ed9d20273dd49deaecd Mon Sep 17 00:00:00 2001 From: tisachi Date: Sat, 17 Oct 2026 04:56:10 +0200 Subject: [PATCH] =?UTF-8?q?Dashboard:=20Historia=20w=20jednej=20linii=20-?= =?UTF-8?q?=20Serie+Killstreak=204/5,=20Uko=C5=84czone=20plany=201/5=20(us?= =?UTF-8?q?uniete=20Treningi=20i=20Trenujesz=20od)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/pages/Dashboard.tsx | 64 ++++++++++++++++--------------- app/test/dashboard-stats.test.tsx | 10 ++--- app/test/e2e/auth.spec.ts | 2 +- 3 files changed, 40 insertions(+), 36 deletions(-) diff --git a/app/src/pages/Dashboard.tsx b/app/src/pages/Dashboard.tsx index edef07c..c74835c 100644 --- a/app/src/pages/Dashboard.tsx +++ b/app/src/pages/Dashboard.tsx @@ -5,7 +5,7 @@ import type { LucideIcon } from 'lucide-react'; import { useActiveSession, useDashboard, useFeed } from '../api/queries'; import { FeedItemRow } from '../components/FeedItemRow'; import { useAuth } from '../store/auth'; -import { fmtDate, timeAgo, todayStr, daysPlural, daysSince } from '../lib/format'; +import { fmtDate, todayStr, daysPlural } from '../lib/format'; import { DAY_NAMES, MUSCLE_NAMES } from '../lib/labels'; import { useTopbar } from '../topbar'; import { Button, Card, EmptyState, ErrorText, SectionHeader, Skeleton } from '../components/ui'; @@ -111,9 +111,19 @@ function ProgressRing({ percent }: { percent: number }) { } /* Karta statystyki: lbl + duża liczba (Space Grotesk) + opcjonalny dopisek kontekstowy. */ -function StatCard({ label, value, sub }: { label: string; value: ReactNode; sub?: ReactNode }) { +function StatCard({ + label, + value, + sub, + className = '', +}: { + label: string; + value: ReactNode; + sub?: ReactNode; + className?: string; +}) { return ( - +
{label}
{value} @@ -318,8 +328,6 @@ export default function Dashboard() { // Fallbacki dla starszych/okrojonych odpowiedzi (np. mocki testów jednostkowych). const week = data.week ?? null; const killstreakBest = data.killstreakBest ?? data.killstreak; - const lastSessionAt = data.lastSessionAt ?? null; - const firstSessionAt = data.firstSessionAt ?? null; const historyVisible = data.killstreak > 0 || history.completedPlans > 0 || history.sessions > 0 || history.sets > 0; @@ -404,39 +412,35 @@ export default function Dashboard() { {historyVisible && ( <> Historia -
+ {/* Jedna linia: Serie + Killstreak (razem 4/5) i Ukończone plany (1/5). */} +
+ {/* Kafelek: łączna liczba serii + prawdziwy trend tygodniowy. */} + +
+
+ Serie +
+
+ {history.sets} +
+
+ łącznie · kreski: serie w 8 ostatnich tygodniach +
+
+ w.sets)} /> +
0 ? data.killstreak : '—'} sub={`rekord: ${daysPlural(killstreakBest)}`} /> - - {firstSessionAt != null && ( - - )}
- {/* Szeroki kafelek: łączna liczba serii + prawdziwy trend tygodniowy. */} - -
-
Serie
-
- {history.sets} -
-
- łącznie · kreski: serie w 8 ostatnich tygodniach -
-
- w.sets)} /> -
)} diff --git a/app/test/dashboard-stats.test.tsx b/app/test/dashboard-stats.test.tsx index 77ddfdc..e4f11dc 100644 --- a/app/test/dashboard-stats.test.tsx +++ b/app/test/dashboard-stats.test.tsx @@ -137,17 +137,17 @@ describe('Dashboard — statystyki motywacyjne', () => { expect(await screen.findByText('brak treningów w tym tygodniu')).toBeInTheDocument(); }); - it('sekcja „Historia": rekord passy, ostatni trening i „Trenujesz od”', async () => { + it('sekcja „Historia": rekord passy, bez kart „Treningi" i „Trenujesz od"', async () => { mockApi(dashBody()); const user = userEvent.setup(); renderApp(); await login(user); expect(await screen.findByText('rekord: 5 dni')).toBeInTheDocument(); - expect(screen.getByText('ostatni: wczoraj')).toBeInTheDocument(); - expect(screen.getByText('Trenujesz od', { exact: true })).toBeInTheDocument(); - // Pierwsza sesja 29 dni temu => 30. dzień przygody (włącznie). - expect(screen.getByText('30', { exact: true })).toBeInTheDocument(); + expect(screen.getByText('Ukończone plany', { exact: true })).toBeInTheDocument(); + expect(screen.queryByText('ostatni: wczoraj')).not.toBeInTheDocument(); + expect(screen.queryByText('Treningi', { exact: true })).not.toBeInTheDocument(); + expect(screen.queryByText('Trenujesz od', { exact: true })).not.toBeInTheDocument(); }); it('kafelek „Serie” renderuje prawdziwy wykres ośmiu tygodni', async () => { diff --git a/app/test/e2e/auth.spec.ts b/app/test/e2e/auth.spec.ts index e949d02..5cfc7ca 100644 --- a/app/test/e2e/auth.spec.ts +++ b/app/test/e2e/auth.spec.ts @@ -22,7 +22,7 @@ test('udane logowanie przekierowuje na dashboard', async ({ page }) => { await expect(page.getByText('1/3', { exact: true })).toBeVisible(); await expect(page.getByText('Historia', { exact: true })).toBeVisible(); await expect(page.getByText('rekord: 5 dni')).toBeVisible(); - await expect(page.getByText('Trenujesz od', { exact: true })).toBeVisible(); + await expect(page.getByText('Ukończone plany', { exact: true })).toBeVisible(); }); test('zapamiętaj mnie zapisuje e-mail i podpowiada go po wylogowaniu', async ({ page }) => {