diff --git a/app/src/components/ExerciseReportTable.tsx b/app/src/components/ExerciseReportTable.tsx index 745d54e..a737179 100644 --- a/app/src/components/ExerciseReportTable.tsx +++ b/app/src/components/ExerciseReportTable.tsx @@ -4,6 +4,7 @@ import { MessageSquare } from 'lucide-react'; import type { ExerciseReport, ExerciseReportSet } from '../api/types'; import { fmtLoadKg } from '../lib/format'; import DifficultyDots from './DifficultyDots'; +import { NoteCallout } from './ui'; /** Powyżej tylu serii mobilne karty zwijają się za „Pokaż więcej”. */ const COLLAPSED_LIMIT = 3; @@ -33,6 +34,24 @@ export default function ExerciseReportTable({ exercise, isMobile }: ExerciseRepo const notes = exercise.sets.filter((s) => s.note); + /* Sekcja calloutów komentarzy: etykieta sekcji + callout na serie. */ + const notesSection = (list: ExerciseReportSet[]) => ( +
+
+ {t('history.setNotes')} +
+
+ {list.map((set) => ( + + ))} +
+
+ ); + const table = (
@@ -52,7 +71,15 @@ export default function ExerciseReportTable({ exercise, isMobile }: ExerciseRepo {exercise.sets.map((set) => (
- {set.index} + + {set.index} + {set.note && ( + {set.planned?.reps ?? '—'} @@ -75,20 +102,14 @@ export default function ExerciseReportTable({ exercise, isMobile }: ExerciseRepo ))}
- {notes.length > 0 && ( -
- {notes.map((set) => ( -
- S{set.index}: {set.note} -
- ))} -
- )} + {notes.length > 0 && notesSection(notes)}
); const collapsed = exercise.sets.length > COLLAPSED_LIMIT && !expanded; const visibleSets = collapsed ? exercise.sets.slice(0, COLLAPSED_LIMIT) : exercise.sets; + // komentarze serii spoza zwiniętego progu — nie mogą znikać z widoku trenera + const hiddenNotes = collapsed ? exercise.sets.slice(COLLAPSED_LIMIT).filter((s) => s.note) : []; const cards = (
@@ -121,14 +142,16 @@ export default function ExerciseReportTable({ exercise, isMobile }: ExerciseRepo {planCell(set, t('common:bodyweight'))}
{set.note && ( -
- - {set.note} -
+ )} ))} + {hiddenNotes.length > 0 && notesSection(hiddenNotes)} {exercise.sets.length > COLLAPSED_LIMIT && (
{collapsed ? ( diff --git a/app/src/components/HistoryTable.tsx b/app/src/components/HistoryTable.tsx index 870994e..36855b3 100644 --- a/app/src/components/HistoryTable.tsx +++ b/app/src/components/HistoryTable.tsx @@ -1,6 +1,6 @@ import { useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { ChevronDown, ChevronRight, ChevronUp } from 'lucide-react'; +import { ChevronDown, ChevronRight, ChevronUp, MessageSquare } from 'lucide-react'; import type { HistoryExercise, HistorySession } from '../api/types'; import { fmtDate, fmtDuration, fmtVolume } from '../lib/format'; import { localizedName } from '../lib/localizedName'; @@ -165,6 +165,8 @@ export default function HistoryTable({ : sum, 0, ); + // komentarze serii: wskaznik, by trener nie musial otwierac dialogu + const exNotes = ex.sets.filter((set) => set.note).length; return (
diff --git a/app/src/components/ui.tsx b/app/src/components/ui.tsx index 2c7b171..509dd96 100644 --- a/app/src/components/ui.tsx +++ b/app/src/components/ui.tsx @@ -55,13 +55,17 @@ export function Badge({ color, className, children, + title, + 'aria-label': ariaLabel, }: { color?: BadgeColor; className?: string; children: ReactNode; + title?: string; + 'aria-label'?: string; }) { return ( - + {children} ); diff --git a/app/src/components/ui/content.tsx b/app/src/components/ui/content.tsx index d26c6ff..43664d2 100644 --- a/app/src/components/ui/content.tsx +++ b/app/src/components/ui/content.tsx @@ -2,7 +2,7 @@ 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 { ArrowLeft, ChevronLeft, ChevronRight, MessageSquare, X } from 'lucide-react'; import { buttonVariants } from './button'; import { H2, H3, Muted } from './typography'; import { cn } from '../../lib/utils'; @@ -143,6 +143,33 @@ export function ListRow({ ); } +/* Callout komentarza serii (SessionSet.note): akcentowa ramka + normalna czcionka — + trener od razu widzi, że seria ma komentarz (ten sam styl w historii i u trenera). */ +export function NoteCallout({ + label, + text, + className = '', +}: { + label: string; + text: string; + className?: string; +}) { + return ( +
+
+ ); +} + /* Meta item: small icon + muted text */ export function MetaItem({ icon: Icon, diff --git a/app/src/i18n/locales/en/common.json b/app/src/i18n/locales/en/common.json index 585b571..5889844 100644 --- a/app/src/i18n/locales/en/common.json +++ b/app/src/i18n/locales/en/common.json @@ -181,6 +181,9 @@ "showMore": "Show more (+{{n}})", "collapseSets": "Collapse", "actualWord": "Performed", - "sessionContext": "Session from {{date}} · {{plan}}" + "sessionContext": "Session from {{date}} · {{plan}}", + "setNotes": "Set notes", + "setNotesBadge_one": "{{count}} set note", + "setNotesBadge_other": "{{count}} set notes" } } diff --git a/app/src/i18n/locales/pl/common.json b/app/src/i18n/locales/pl/common.json index ed0d29d..301d8e9 100644 --- a/app/src/i18n/locales/pl/common.json +++ b/app/src/i18n/locales/pl/common.json @@ -205,6 +205,10 @@ "showMore": "Pokaż więcej (+{{n}})", "collapseSets": "Zwiń", "actualWord": "Wykonanie", - "sessionContext": "Sesja z {{date}} · {{plan}}" + "sessionContext": "Sesja z {{date}} · {{plan}}", + "setNotes": "Komentarze przy seriach", + "setNotesBadge_one": "{{count}} komentarz przy serii", + "setNotesBadge_few": "{{count}} komentarze przy seriach", + "setNotesBadge_other": "{{count}} komentarzy przy seriach" } } diff --git a/app/src/pages/DayExecution.tsx b/app/src/pages/DayExecution.tsx index 1f02f3a..3cd2c7d 100644 --- a/app/src/pages/DayExecution.tsx +++ b/app/src/pages/DayExecution.tsx @@ -2,7 +2,7 @@ import { useEffect, useRef, useState, type ReactNode } from 'react'; import { useParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { useQueryClient } from '@tanstack/react-query'; -import { Check, ChevronDown, MessageSquare, Plus, Trash2 } from 'lucide-react'; +import { Check, ChevronDown, Plus, Trash2 } from 'lucide-react'; import { abandonSession, addSessionExercise, @@ -40,6 +40,7 @@ import { H3, Input, Modal, + NoteCallout, PageHeader, ProgressBar, SetEditDialog, @@ -257,12 +258,13 @@ function SetRow({ ))}

)} - {/* komentarz trenujący zapisany przy serii (ten sam co w historii i u trenera) */} + {/* komentarz trenujacego zapisany przy serii (ten sam co w historii i u trenera) */} {set.note && ( -

-

+ )}
diff --git a/app/test/e2e/profile-mobile.spec.ts b/app/test/e2e/profile-mobile.spec.ts index 466d076..ac237bd 100644 --- a/app/test/e2e/profile-mobile.spec.ts +++ b/app/test/e2e/profile-mobile.spec.ts @@ -133,17 +133,25 @@ test('mobile: historia — kompaktowe serie, objętość/czas i filtr miesiąca' await expect(page.getByText('1 h 30 min')).toBeVisible(); await expect(page.getByText('320 kg')).toBeVisible(); - // tap na sesji rozwija ćwiczenia: kompaktowe wiersze serii + // tap na sesji rozwija ćwiczenia; licznik komentarzy serii przy wierszu ćwiczenia await page.getByRole('button', { name: /600 kg/ }).click(); await expect(page.getByText('Przysiady')).toBeVisible(); - await expect(page.getByText('S1')).toBeVisible(); + await expect(page.getByTitle('1 komentarz przy serii')).toBeVisible(); + // tap na ćwiczeniu otwiera dialog z kompaktowymi kartami serii (wariant mobilny) + await page.getByRole('button', { name: /Przysiady/ }).click(); + const dialog = page.getByRole('dialog'); + await expect(dialog.getByText('S1')).toBeVisible(); // obie serie mają ten sam plan → first() - await expect(page.getByText('plan 10/60 kg/90 s').first()).toBeVisible(); - await expect(page.getByText('RIR 2')).toBeVisible(); - // komentarz przy serii (wpisany w oknie uzupełniania) - await expect(page.getByText('ostatnia seria była ciężka')).toBeVisible(); + await expect(dialog.getByText('plan 10 / 60 kg / 90 s').first()).toBeVisible(); + await expect(dialog.getByText('RIR 2')).toBeVisible(); + // komentarz przy serii (wpisany w oknie uzupełniania) — callout w karcie mobilnej + // (drugi identyczny callout istnieje w ukrytej tabeli desktop → filtr widoczności) + await expect( + dialog.getByText('ostatnia seria była ciężka').filter({ visible: true }), + ).toBeVisible(); // niewykonana seria = czerwony chip - await expect(page.getByText('niewykonane')).toBeVisible(); + await expect(dialog.getByText('niewykonane').filter({ visible: true })).toBeVisible(); + await page.getByRole('button', { name: 'Zamknij' }).click(); // filtr miesiąca w topmenu: „Filtry” → selektor → bieżący miesiąc await page.getByRole('button', { name: 'Filtry' }).click(); diff --git a/app/test/e2e/trainees.spec.ts b/app/test/e2e/trainees.spec.ts index 5addd0f..f5e0670 100644 --- a/app/test/e2e/trainees.spec.ts +++ b/app/test/e2e/trainees.spec.ts @@ -95,13 +95,18 @@ test('szczegóły podopiecznego: przegląd i historia z planem vs. fakty', async await page.getByRole('button', { name: /24\.08\.2026/ }).click(); await expect(page.getByText('Przysiady')).toBeVisible(); await expect(page.getByText('dodane')).toBeVisible(); - // kompaktowy wiersz serii: S1 + powt. + plan (nowy format HistoryTable) - await expect(page.getByText('S1').first()).toBeVisible(); - await expect(page.getByText('plan 10/60 kg/90 s')).toBeVisible(); - // komentarz trenującego przy serii — widoczny dla trenera - await expect(page.getByText('ostatnia seria była ciężka')).toBeVisible(); - // nagłówek sesji: objętość + czas trwania (obie sesje po 1,5 h → first()) - await expect(page.getByText('600 kg')).toBeVisible(); + // licznik komentarzy serii przy wierszu ćwiczenia — trener nie musi otwierać dialogu + await expect(page.getByTitle('1 komentarz przy serii')).toBeVisible(); + // dialog ćwiczenia: callout komentarza serii + ikona wskazująca przy numerze serii + await page.getByRole('button', { name: /Przysiady/ }).click(); + const dialog = page.getByRole('dialog'); + await expect(dialog.getByText('Komentarze przy seriach')).toBeVisible(); + await expect(dialog.getByText('ostatnia seria była ciężka').first()).toBeVisible(); + await expect(dialog.getByTitle('ostatnia seria była ciężka')).toBeVisible(); + await page.getByRole('button', { name: 'Zamknij' }).click(); + // nagłówek sesji: objętość + czas trwania (600 kg też w wierszu ćwiczenia → first(); + // obie sesje po 1,5 h → first()) + await expect(page.getByText('600 kg').first()).toBeVisible(); await expect(page.getByText('1 h 30 min').first()).toBeVisible(); }); @@ -117,6 +122,9 @@ test('komentarz pod ćwiczeniem w panelu podopiecznego (trener)', async ({ page await page.getByRole('button', { name: /24\.08\.2026/ }).click(); await expect(page.getByText('Przysiady')).toBeVisible(); + // formularz komentarza jest w dialogu ćwiczenia (master/detail) + await page.getByRole('button', { name: /Przysiady/ }).click(); + await expect(page.getByRole('dialog')).toBeVisible(); // formularz komentarza dla Przysiadów (własny form, bo dwa ćwiczenia mają po przycisku) const form = page.locator('form', { has: page.getByRole('textbox', { name: 'Komentarz dla ćwiczenia Przysiady' }), diff --git a/app/test/history-report.test.tsx b/app/test/history-report.test.tsx index fd9dfca..d3a5ec4 100644 --- a/app/test/history-report.test.tsx +++ b/app/test/history-report.test.tsx @@ -84,6 +84,8 @@ describe('HistoryTable — master/detail (dialog ćwiczenia)', () => { // rozwinięta sesja: podsumowania ćwiczeń w kartach expect(screen.getByRole('button', { name: /Przysiad/ })).toBeInTheDocument(); expect(screen.getByText('dodane')).toBeInTheDocument(); + // licznik komentarzy serii przy wierszu ćwiczenia (trener nie musi otwierać dialogu) + expect(screen.getByTitle('1 komentarz przy serii')).toBeInTheDocument(); await user.click(screen.getByRole('button', { name: /Przysiad/ })); const dialog = screen.getByRole('dialog'); @@ -94,8 +96,13 @@ describe('HistoryTable — master/detail (dialog ćwiczenia)', () => { expect(within(dialog).getByText('Trudność')).toBeInTheDocument(); // seria planowa niewykonana — etykieta w tabeli i w karcie mobilnej expect(within(dialog).getAllByText('niewykonane').length).toBeGreaterThanOrEqual(2); - // notatka przy serii + komentarz w stopce dialogu - expect(within(dialog).getByText('luz')).toBeInTheDocument(); + // notatka przy serii: callout w wariancie desktop i karcie mobilnej + etykieta serii; + // wskaznik ikony w kolumnie „#” (title) + sekcja calloutow + expect(within(dialog).getAllByText('luz').length).toBeGreaterThanOrEqual(2); + expect(within(dialog).getAllByText(/Seria 1/).length).toBeGreaterThanOrEqual(1); + expect(within(dialog).getByTitle('luz')).toBeInTheDocument(); + expect(within(dialog).getByText('Komentarze przy seriach')).toBeInTheDocument(); + // komentarz w stopce dialogu expect(within(dialog).getByText('Dobre tempo')).toBeInTheDocument(); await user.click(within(dialog).getByRole('button', { name: 'Zamknij' })); @@ -115,6 +122,8 @@ describe('ExerciseReportTable — karty mobilne i zwijanie', () => { index: i, planned: { reps: 10, loadKg: 40, restSec: 60, rir: null }, actual: { reps: 10, rir: null, difficulty: 2 }, + // komentarz przy serii spoza progu zwijania — nie może znikać + note: i === 5 ? 'ciezka' : null, })), }; @@ -124,9 +133,15 @@ describe('ExerciseReportTable — karty mobilne i zwijanie', () => { expect(screen.getByText('S1')).toBeInTheDocument(); expect(screen.getByText('S3')).toBeInTheDocument(); expect(screen.queryByText('S4')).not.toBeInTheDocument(); + // komentarz serii spoza zwiniętej listy pozostaje widoczny (callout poza prog) + expect(screen.getByText('ciezka')).toBeInTheDocument(); + expect(screen.getByText('Komentarze przy seriach')).toBeInTheDocument(); await user.click(screen.getByRole('button', { name: 'Pokaż więcej (+2)' })); expect(screen.getByText('S4')).toBeInTheDocument(); expect(screen.getByText('S5')).toBeInTheDocument(); + // po rozwinięciu komentarz przenosi się do karty serii — bez duplikatu + expect(screen.getByText('ciezka')).toBeInTheDocument(); + expect(screen.queryByText('Komentarze przy seriach')).not.toBeInTheDocument(); await user.click(screen.getByRole('button', { name: 'Zwiń' })); expect(screen.queryByText('S4')).not.toBeInTheDocument(); }); diff --git a/app/test/trainees.test.tsx b/app/test/trainees.test.tsx index d420aad..da1ec10 100644 --- a/app/test/trainees.test.tsx +++ b/app/test/trainees.test.tsx @@ -244,6 +244,23 @@ function mockApi() { { date: '2026-08-21T00:00:00.000Z', status: 'COMPLETED', moved: true }, { date: '2026-08-25T00:00:00.000Z', status: 'PLANNED', moved: false }, ], + // detale per cwiczenie: seria z komentarzem (callout w tabeli serii) + exercises: [ + { + id: 'rep-ex-1', + name: 'Martwy ciąg', + muscle: 'legs', + isExtra: false, + sets: [ + { + index: 1, + planned: { reps: 8, loadKg: 100, restSec: 120, rir: null }, + actual: { reps: 8, rir: 1, difficulty: 4 }, + note: 'bolely plecy', + }, + ], + }, + ], }); if (url.includes('/trainer/trainees/trainee-1/history')) return jsonResponse(200, { @@ -693,6 +710,10 @@ describe('Trainees — lista i szczegóły', () => { // pasek objętości: fakty/plany + zalecany zakres expect(screen.getByText('10/12 · 10–18')).toBeInTheDocument(); expect(screen.getByText('4/10 · 10–20')).toBeInTheDocument(); + // detale cwiczen: komentarz serii widoczny jako callout z etykieta sekcji + expect(screen.getByText('Martwy ciąg')).toBeInTheDocument(); + expect(screen.getByText('Komentarze przy seriach')).toBeInTheDocument(); + expect(screen.getAllByText('bolely plecy').length).toBeGreaterThanOrEqual(1); }); it('zakładka Dyscyplina: heatmapa dni i log przesunięć', async () => {