diff --git a/app/src/components/plans/PlanWeeks.tsx b/app/src/components/plans/PlanWeeks.tsx index 13ef376..ca9eed9 100644 --- a/app/src/components/plans/PlanWeeks.tsx +++ b/app/src/components/plans/PlanWeeks.tsx @@ -3,7 +3,9 @@ import { Link } from 'react-router-dom'; import { Play } from 'lucide-react'; import { fmtDate } from '../../lib/format'; import { DAY_NAMES, DAY_STATUS } from '../../lib/labels'; -import { Badge, Button, Card, H2 } from '../ui'; +import { Badge, Card, H2 } from '../ui'; +import { buttonVariants } from '../ui/button'; +import { cn } from '../../lib/utils'; import type { PlanDay, PlanWeek } from '../../api/types'; /* Tło wiersza dnia zależne od statusu. */ @@ -20,20 +22,25 @@ const DAY_DOT: Record = { SKIPPED: 'bg-danger', }; -/** Wiersz dnia planu (read-only): kropka statusu + nazwa (+ data), akcje, lista ćwiczeń. */ +/** + * Wiersz dnia planu (read-only): kropka statusu + nazwa (+ data), akcje, lista ćwiczeń. + * Gdy podano `to` — cały wiersz jest jednym klikalnym linkiem z pojedynczym + * hoverem na całym elemencie (wcześniej nakładały się dwa hovere: dzień + ćwiczenie). + */ export function PlanDayRow({ day, showDate = false, actions, + to, }: { day: PlanDay; showDate?: boolean; actions?: ReactNode; + to?: string; }) { - return ( -
+ const base = `rounded-[10px] px-3 py-3 ${DAY_TINT[day.status]}`.trim(); + const inner = ( + <>
(
  • {ex.exercise.name} @@ -63,11 +70,20 @@ export function PlanDayRow({
  • ))} -
    + ); + if (to) { + return ( + + {inner} + + ); + } + return
    {inner}
    ; } -/** Karta tygodnia planu (read-only): H2 + postęp tygodnia + wiersze dni (badge statusu, „Wykonaj”). */ +/** Karta tygodnia planu: H2 + postęp tygodnia + wiersze dni (badge statusu); + * dla aktywnego planu cały wiersz dnia jest linkiem do treningu (chip „Wykonaj”). */ export function PlanWeekCard({ week, showDate = false, @@ -113,16 +129,19 @@ export function PlanWeekCard({ key={d.id} day={d} showDate={showDate} + to={canExecute ? `/day/${d.id}` : undefined} actions={ <> {DAY_STATUS[d.status].label} {canExecute && d.status === 'PLANNED' && ( - - - + // wskazówka wizualna — klikalność i nawigacja są na całym wierszu + )} } diff --git a/app/test/PlanDetail.test.tsx b/app/test/PlanDetail.test.tsx index df679a1..99289c0 100644 --- a/app/test/PlanDetail.test.tsx +++ b/app/test/PlanDetail.test.tsx @@ -325,6 +325,42 @@ describe('PlanDetail — udostępnianie planów (WP4)', () => { }); describe('PlanDetail — statusy i klikalność dni', () => { + it('szkic: wiersz dnia bez linku (dzień klikalny tylko w aktywnym planie)', async () => { + mockApi({}, { user: OWNER, plans: [planDetail()] }); + const user = userEvent.setup(); + renderApp(); + await loginAndOpenPlans(user, OWNER.email); + + await user.click(screen.getByRole('link', { name: /Otwórz/ })); + expect(await screen.findByRole('heading', { name: 'Plan masowy' })).toBeInTheDocument(); + expect(screen.getByText('Poniedziałek')).toBeInTheDocument(); + expect(screen.queryByRole('link', { name: /Poniedziałek/ })).not.toBeInTheDocument(); + }); + + it('plan aktywny: cały dzień to link do /day/:id; tylko „Porzuć” (bez „Wznów”)', async () => { + const active = planDetail({ status: 'ACTIVE', weeksCount: 1, startDate: '2026-10-12' }); + mockApi({}, { user: OWNER, plans: [active], plan: active }); + const user = userEvent.setup(); + renderApp(); + await loginAndOpenPlans(user, OWNER.email); + + await user.click(screen.getByRole('link', { name: /Otwórz/ })); + expect(await screen.findByRole('heading', { name: 'Plan masowy' })).toBeInTheDocument(); + + // cały wiersz dnia = jeden link do dnia treningu (pojedynczy hover) + const dayLink = await screen.findByRole('link', { name: /Poniedziałek/ }); + expect(dayLink).toHaveAttribute('href', '/day/td-1'); + expect(screen.queryByRole('button', { name: 'Wykonaj' })).not.toBeInTheDocument(); + + const header = document.querySelector('header')!; + expect(within(header).getByRole('button', { name: 'Porzuć' })).toBeInTheDocument(); + // dzień PLANNED = plan w trakcie realizacji + expect( + within(header).queryByRole('button', { name: 'Oznacz jako ukończony' }), + ).not.toBeInTheDocument(); + expect(within(header).queryByRole('button', { name: 'Wznów' })).not.toBeInTheDocument(); + }); + it('plan ukończony: akcja „Wznów”; potwierdzenie = POST /plans/:id/reopen', async () => { const capture: Capture = {}; const closed = planDetail({ status: 'COMPLETED' });