App: krok 1 kreatora planu wg makiety - pola Tytul/Dlugosc/Silownia w jednym rzedzie z ikonami, kalendarz tygodni startu w osobnej karcie (wiersz = tydzien Pn-Nd, nawigacja < Dzis >), autofocus na tytule przy nowym planie (weekPicker.today w i18n; testy unit + e2e)
This commit is contained in:
@@ -122,15 +122,17 @@ export function Label({ children, className }: { children: ReactNode; className?
|
||||
|
||||
export function Field({
|
||||
label,
|
||||
labelIcon,
|
||||
children,
|
||||
className,
|
||||
}: {
|
||||
label: string;
|
||||
labelIcon?: ReactNode;
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<UIField label={label} className={className}>
|
||||
<UIField label={label} labelIcon={labelIcon} className={className}>
|
||||
{children}
|
||||
</UIField>
|
||||
);
|
||||
|
||||
@@ -4,12 +4,23 @@ import { cn } from '../../lib/utils';
|
||||
|
||||
interface FieldProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
label: string;
|
||||
/** Ikona przed etykietą (np. Tag/Calendar w formularzu planu); dekoracyjna. */
|
||||
labelIcon?: React.ReactNode;
|
||||
}
|
||||
|
||||
function Field({ className, label, children, ...props }: FieldProps) {
|
||||
function Field({ className, label, labelIcon, children, ...props }: FieldProps) {
|
||||
return (
|
||||
<div data-slot="field" className={cn('mb-3.5', className)} {...props}>
|
||||
<Label>{label}</Label>
|
||||
<Label>
|
||||
{labelIcon ? (
|
||||
<span className="inline-flex items-center gap-1.5">
|
||||
<span aria-hidden="true">{labelIcon}</span>
|
||||
{label}
|
||||
</span>
|
||||
) : (
|
||||
label
|
||||
)}
|
||||
</Label>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
||||
import { Button } from './button';
|
||||
import { CalendarDays, ChevronLeft, ChevronRight } from 'lucide-react';
|
||||
import { formatMonth } from '../../lib/format';
|
||||
import { fmtDate } from '../../lib/format';
|
||||
import { cn } from '../../lib/utils';
|
||||
@@ -42,9 +41,15 @@ export function isPastWeek(monday: string): boolean {
|
||||
return new Date(y, m - 1, d) < currentMonday();
|
||||
}
|
||||
|
||||
/* Wybór tygodnia startu: siatka miesiąca, w której kliknięcie dowolnego dnia zaznacza
|
||||
CAŁY tydzień (Pn–Nd) — data startu to poniedziałek zaznaczonego tygodnia.
|
||||
Minione tygodnie są zablokowane (start nie może być w przeszłości). */
|
||||
/* Kwadratowy target nawigacji — ta sama estetyka co pola formularza (bg-input +
|
||||
hover w akcencie). */
|
||||
const NAV_BTN =
|
||||
'grid h-10 min-w-10 cursor-pointer place-items-center rounded-[10px] border border-line bg-input text-dim transition-all duration-150 hover:border-accent hover:text-accent-text active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60';
|
||||
|
||||
/* Wybór tygodnia startu: kalendarz miesiąca, w którym każdy tydzień (Pn–Nd) jest
|
||||
osobnym wierszem — kliknięcie dowolnego dnia zaznacza CAŁY tydzień (tło w akcencie),
|
||||
a data startu to poniedziałek zaznaczonego tygodnia. Minione tygodnie są zablokowane
|
||||
(start nie może być w przeszłości). Nawigacja miesiącami + skrót „Dziś”. */
|
||||
export function WeekPicker({
|
||||
value,
|
||||
onChange,
|
||||
@@ -71,80 +76,115 @@ export function WeekPicker({
|
||||
const d = new Date(y, m - 1 + delta, 1);
|
||||
setView([d.getFullYear(), d.getMonth() + 1]);
|
||||
};
|
||||
const goToday = () => setView([now.getFullYear(), now.getMonth() + 1]);
|
||||
|
||||
// Monday-first grid
|
||||
// Monday-first grid: 6 pełnych wierszy tygodni (42 dni) — każdy wiersz to
|
||||
// jednostka wyboru (cały tydzień).
|
||||
const firstDay = new Date(y, m - 1, 1);
|
||||
const startOffset = (firstDay.getDay() + 6) % 7;
|
||||
const gridStart = new Date(y, m - 1, 1 - startOffset);
|
||||
const cells: Date[] = [];
|
||||
for (let i = 0; i < 42; i++) {
|
||||
const d = new Date(gridStart);
|
||||
d.setDate(gridStart.getDate() + i);
|
||||
cells.push(d);
|
||||
const rows: Date[][] = [];
|
||||
for (let wi = 0; wi < 6; wi++) {
|
||||
const row: Date[] = [];
|
||||
for (let i = 0; i < 7; i++) {
|
||||
const d = new Date(gridStart);
|
||||
d.setDate(gridStart.getDate() + wi * 7 + i);
|
||||
row.push(d);
|
||||
}
|
||||
rows.push(row);
|
||||
}
|
||||
|
||||
const selMondayKey = value ? localDayKey(mondayOf(parseIsoLocal(value))) : null;
|
||||
const todayKey = localDayKey(now);
|
||||
|
||||
return (
|
||||
<div className={cn('w-full', className)}>
|
||||
<div className="flex items-center justify-between gap-2 mb-2">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={() => shift(-1)}
|
||||
aria-label={t('topbar.prevMonth')}
|
||||
className="max-md:h-11 max-md:w-11 max-md:justify-center"
|
||||
>
|
||||
<ChevronLeft className="w-4 h-4" />
|
||||
</Button>
|
||||
<span className="text-[0.9rem] font-semibold">
|
||||
{formatMonth(`${y}-${String(m).padStart(2, '0')}`)}
|
||||
</span>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={() => shift(1)}
|
||||
aria-label={t('topbar.nextMonth')}
|
||||
className="max-md:h-11 max-md:w-11 max-md:justify-center"
|
||||
>
|
||||
<ChevronRight className="w-4 h-4" />
|
||||
</Button>
|
||||
<div className="mb-3 flex items-center justify-between gap-2">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<CalendarDays className="h-5 w-5 shrink-0 text-accent" aria-hidden="true" />
|
||||
<span className="truncate text-[1.125rem] font-bold sm:text-[1.25rem]">
|
||||
{formatMonth(`${y}-${String(m).padStart(2, '0')}`)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center gap-1.5">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => shift(-1)}
|
||||
aria-label={t('topbar.prevMonth')}
|
||||
className={NAV_BTN}
|
||||
>
|
||||
<ChevronLeft className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={goToday}
|
||||
className={cn(NAV_BTN, 'px-3 text-[0.875rem] font-semibold')}
|
||||
>
|
||||
{t('weekPicker.today')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => shift(1)}
|
||||
aria-label={t('topbar.nextMonth')}
|
||||
className={NAV_BTN}
|
||||
>
|
||||
<ChevronRight className="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-7 gap-1" role="group" aria-label={t('weekPicker.groupAria')}>
|
||||
{dows.map((d) => (
|
||||
<div key={d} className="text-center text-dim text-[0.75rem] py-1">
|
||||
{d}
|
||||
</div>
|
||||
))}
|
||||
{cells.map((d, i) => {
|
||||
const inMonth = d.getMonth() === m - 1;
|
||||
const weekMonday = mondayOf(d);
|
||||
const isPast = isPastWeek(localDayKey(weekMonday));
|
||||
const isSel = selMondayKey != null && localDayKey(weekMonday) === selMondayKey;
|
||||
<div role="group" aria-label={t('weekPicker.groupAria')} className="flex flex-col gap-1.5">
|
||||
<div className="grid grid-cols-7">
|
||||
{dows.map((d) => (
|
||||
<div key={d} className="py-1 text-center text-[0.75rem] font-semibold text-dim">
|
||||
{d}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{rows.map((row) => {
|
||||
const weekMonday = row[0];
|
||||
const weekKey = localDayKey(weekMonday);
|
||||
const past = isPastWeek(weekKey);
|
||||
const sel = selMondayKey === weekKey;
|
||||
return (
|
||||
<button
|
||||
key={i}
|
||||
type="button"
|
||||
disabled={isPast}
|
||||
onClick={() => onChange(localDayKey(weekMonday))}
|
||||
aria-pressed={isSel}
|
||||
className={`h-8 max-md:h-10 rounded-md text-[0.8rem] transition-colors ${
|
||||
isPast
|
||||
? 'text-dim/40 cursor-not-allowed'
|
||||
: isSel
|
||||
? 'bg-accent/15 text-accent-text font-bold cursor-pointer'
|
||||
: inMonth
|
||||
? 'text-ink hover:bg-line/30 cursor-pointer'
|
||||
: 'text-dim/60 hover:bg-line/30 cursor-pointer'
|
||||
}`}
|
||||
<div
|
||||
key={weekKey}
|
||||
className={cn(
|
||||
'grid grid-cols-7 overflow-hidden rounded-[10px] border transition-colors',
|
||||
sel ? 'border-accent/50 bg-accent/10' : 'border-line',
|
||||
)}
|
||||
>
|
||||
{d.getDate()}
|
||||
</button>
|
||||
{row.map((d, i) => {
|
||||
const inMonth = d.getMonth() === m - 1;
|
||||
const isToday = localDayKey(d) === todayKey;
|
||||
return (
|
||||
<button
|
||||
key={i}
|
||||
type="button"
|
||||
disabled={past}
|
||||
onClick={() => onChange(weekKey)}
|
||||
aria-pressed={sel}
|
||||
className={cn(
|
||||
'h-12 text-center text-[0.9rem] tabular-nums transition-colors max-md:h-11',
|
||||
i > 0 && 'border-l border-line',
|
||||
past ? 'cursor-not-allowed text-dim/40' : 'cursor-pointer hover:bg-line/25',
|
||||
sel
|
||||
? 'bg-accent/15 font-bold text-accent-text'
|
||||
: inMonth
|
||||
? 'text-ink'
|
||||
: 'text-dim/50',
|
||||
!past && !sel && isToday && 'font-bold text-accent-text',
|
||||
)}
|
||||
>
|
||||
{d.getDate()}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{value && (
|
||||
<p className="text-dim text-[0.8rem] mt-2">
|
||||
<p className="mt-2 text-dim text-[0.8rem]">
|
||||
{t('weekPicker.startWeek', {
|
||||
from: fmtDate(value),
|
||||
to: fmtDate(localDayKey(addDaysLocal(parseIsoLocal(value), 6))),
|
||||
|
||||
@@ -57,7 +57,8 @@
|
||||
"weekPicker": {
|
||||
"dows": ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
||||
"groupAria": "Start week selection",
|
||||
"startWeek": "Start: week {{from}} – {{to}}"
|
||||
"startWeek": "Start: week {{from}} – {{to}}",
|
||||
"today": "Today"
|
||||
},
|
||||
"weekShort": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
||||
"fmt": {
|
||||
|
||||
@@ -85,8 +85,7 @@
|
||||
"length": "Length (weeks)",
|
||||
"gym": "Gym",
|
||||
"noGym": "No gym",
|
||||
"gymHint": "Limits the exercise list to available equipment.",
|
||||
"activateHint": "Optionally pick a start week — the plan is activated right away (start = Monday of the picked week) and training day dates are calculated automatically. Without a week the plan stays a draft.",
|
||||
"activateHint": "Optionally mark the start week — the plan is activated right away (start = Monday of the marked week).",
|
||||
"startDateLockedHint": "This plan is in progress — its start date cannot change.",
|
||||
"changeNoteLabel": "Change note",
|
||||
"changeNotePlaceholder": "What you change in the in-progress plan and why",
|
||||
|
||||
@@ -57,7 +57,8 @@
|
||||
"weekPicker": {
|
||||
"dows": ["Pn", "Wt", "Śr", "Cz", "Pt", "So", "Nd"],
|
||||
"groupAria": "Wybór tygodnia startu",
|
||||
"startWeek": "Start: tydzień {{from}} – {{to}}"
|
||||
"startWeek": "Start: tydzień {{from}} – {{to}}",
|
||||
"today": "Dziś"
|
||||
},
|
||||
"weekShort": ["Pon", "Wt", "Śr", "Czw", "Pt", "Sob", "Niedz"],
|
||||
"fmt": {
|
||||
|
||||
@@ -85,8 +85,7 @@
|
||||
"length": "Długość (tygodnie)",
|
||||
"gym": "Siłownia",
|
||||
"noGym": "Bez siłowni",
|
||||
"gymHint": "Ogranicza listę ćwiczeń do dostępnego sprzętu.",
|
||||
"activateHint": "Opcjonalnie zaznacz tydzień startu — plan zostanie od razu aktywowany (start = poniedziałek zaznaczonego tygodnia), a daty dni treningowych wyliczone automatycznie. Bez tygodnia plan pozostanie szkicem.",
|
||||
"activateHint": "Opcjonalnie zaznacz tydzień startu — plan zostanie od razu aktywowany (start = poniedziałek zaznaczonego tygodnia).",
|
||||
"startDateLockedHint": "Plan jest realizowany — data startu jest niezmienna.",
|
||||
"changeNoteLabel": "Notatka o zmianach",
|
||||
"changeNotePlaceholder": "Co i dlaczego zmieniasz w realizowanym planie",
|
||||
|
||||
@@ -572,6 +572,7 @@ export default function PlanEditor() {
|
||||
onTitleChange={editor.setTitle}
|
||||
onTitleBlur={() => setTitleTouched(true)}
|
||||
titleError={titleError}
|
||||
autoFocusTitle={!isEdit}
|
||||
weeksCount={editor.weeksCount}
|
||||
onWeeksCountChange={(n) => {
|
||||
// Skrócenie planu, który usunęłoby tygodnie z dniami z historią —
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { CalendarDays, CircleSlash, Info, Tag } from 'lucide-react';
|
||||
import { Card, ErrorText, Field, Input, Select, WeekPicker } from '../../../components/ui';
|
||||
import { fmtDate } from '../../../lib/format';
|
||||
|
||||
/* Meta planu: tytuł, długość, siłownia, tydzień startu (+ hint) — inputy w rzędzie,
|
||||
kalendarz na pełną szerokość karty, błędy inline. Siłownia jest tu, bo realnie
|
||||
decyduje o dostępnym sprzęcie w pickerze ćwiczeń (krok 2).
|
||||
Plan w trakcie realizacji: start jest niezmienny (pole tylko do odczytu) i pojawia
|
||||
się opcjonalna notatka o zmianach (historia edycji planu). */
|
||||
/* Meta planu (krok 1): karta pól — tytuł, długość, siłownia w jednym rzędzie
|
||||
(ikony w etykietach) — oraz osobna karta kalendarza tygodnia startu. Siłownia
|
||||
jest w kroku 1, bo realnie decyduje o dostępnym sprzęcie w pickerze ćwiczeń (krok 2).
|
||||
Plan w trakcie realizacji: start jest niezmienny (pole tylko do odczytu zamiast
|
||||
kalendarza) i pojawia się opcjonalna notatka o zmianach (historia edycji planu). */
|
||||
export function PlanMetaForm({
|
||||
title,
|
||||
onTitleChange,
|
||||
onTitleBlur,
|
||||
titleError,
|
||||
autoFocusTitle = false,
|
||||
weeksCount,
|
||||
onWeeksCountChange,
|
||||
gymOptions,
|
||||
@@ -30,6 +32,8 @@ export function PlanMetaForm({
|
||||
onTitleChange: (v: string) => void;
|
||||
onTitleBlur?: () => void;
|
||||
titleError?: string;
|
||||
/** Nowy plan: fokus na tytule od razu po wejściu do kreatora. */
|
||||
autoFocusTitle?: boolean;
|
||||
weeksCount: number;
|
||||
onWeeksCountChange: (n: number) => void;
|
||||
/** Siłownie właściciela planu (członkostwa); pusta = komunikat `noGymNotice`. */
|
||||
@@ -48,40 +52,47 @@ export function PlanMetaForm({
|
||||
onSetChangeNote?: (v: string) => void;
|
||||
}) {
|
||||
const { t } = useTranslation('plans');
|
||||
const titleField = (
|
||||
<Field label={t('meta.title')}>
|
||||
<Input
|
||||
value={title}
|
||||
onChange={(e) => onTitleChange(e.target.value)}
|
||||
onBlur={onTitleBlur}
|
||||
placeholder={t('meta.titlePlaceholder')}
|
||||
aria-invalid={titleError ? true : undefined}
|
||||
/>
|
||||
{titleError && <ErrorText>{titleError}</ErrorText>}
|
||||
</Field>
|
||||
);
|
||||
const weeksField = (
|
||||
<Field label={t('meta.length')}>
|
||||
<Select value={weeksCount} onChange={(e) => onWeeksCountChange(parseInt(e.target.value))}>
|
||||
{[1, 2, 3, 4, 5, 6, 7, 8].map((n) => (
|
||||
<option key={n} value={n}>
|
||||
{n}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</Field>
|
||||
);
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
{titleField}
|
||||
{weeksField}
|
||||
</div>
|
||||
<div className="mt-4">
|
||||
<Field label={t('meta.gym')}>
|
||||
{gymOptions.length > 0 ? (
|
||||
<>
|
||||
<>
|
||||
<Card>
|
||||
<div className="grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-3">
|
||||
<Field
|
||||
label={t('meta.title')}
|
||||
labelIcon={<Tag className="h-3.5 w-3.5" />}
|
||||
className="mb-0"
|
||||
>
|
||||
<Input
|
||||
value={title}
|
||||
onChange={(e) => onTitleChange(e.target.value)}
|
||||
onBlur={onTitleBlur}
|
||||
autoFocus={autoFocusTitle}
|
||||
placeholder={t('meta.titlePlaceholder')}
|
||||
aria-invalid={titleError ? true : undefined}
|
||||
/>
|
||||
{titleError && <ErrorText>{titleError}</ErrorText>}
|
||||
</Field>
|
||||
<Field
|
||||
label={t('meta.length')}
|
||||
labelIcon={<CalendarDays className="h-3.5 w-3.5" />}
|
||||
className="mb-0"
|
||||
>
|
||||
<Select
|
||||
value={weeksCount}
|
||||
onChange={(e) => onWeeksCountChange(parseInt(e.target.value))}
|
||||
>
|
||||
{[1, 2, 3, 4, 5, 6, 7, 8].map((n) => (
|
||||
<option key={n} value={n}>
|
||||
{n}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</Field>
|
||||
<Field
|
||||
label={t('meta.gym')}
|
||||
labelIcon={<CircleSlash className="h-3.5 w-3.5" />}
|
||||
className="mb-0"
|
||||
>
|
||||
{gymOptions.length > 0 ? (
|
||||
<Select value={gymId ?? ''} onChange={(e) => onGymIdChange(e.target.value || null)}>
|
||||
<option value="">{t('meta.noGym')}</option>
|
||||
{gymOptions.map((g) => (
|
||||
@@ -90,48 +101,57 @@ export function PlanMetaForm({
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
<p className="mt-1.5 text-dim text-[0.8125rem]">{t('meta.gymHint')}</p>
|
||||
</>
|
||||
) : (
|
||||
<p className="py-1 text-dim text-[0.875rem]">{noGymNotice}</p>
|
||||
)}
|
||||
</Field>
|
||||
</div>
|
||||
<div className="mt-4">
|
||||
<Field label={t('detail.startWeekLabel')}>
|
||||
{startDateLocked ? (
|
||||
<>
|
||||
) : (
|
||||
<p className="py-1 text-dim text-[0.875rem]">{noGymNotice}</p>
|
||||
)}
|
||||
</Field>
|
||||
</div>
|
||||
{onSetChangeNote && (
|
||||
<div className="mt-4">
|
||||
<Field label={t('meta.changeNoteLabel')}>
|
||||
<textarea
|
||||
value={changeNote ?? ''}
|
||||
onChange={(e) => onSetChangeNote(e.target.value)}
|
||||
maxLength={300}
|
||||
rows={3}
|
||||
placeholder={t('meta.changeNotePlaceholder')}
|
||||
className="w-full rounded-[10px] border border-line bg-input px-3 py-2 text-[0.9rem] text-ink placeholder:text-dim/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60"
|
||||
/>
|
||||
<p className="mt-1.5 text-dim text-[0.8125rem]">{t('meta.changeNoteHint')}</p>
|
||||
</Field>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
{startDateLocked ? (
|
||||
<>
|
||||
<Field label={t('detail.startWeekLabel')}>
|
||||
<p className="rounded-[10px] border border-line bg-input px-3 py-2 text-[0.9rem]">
|
||||
{startDate ? fmtDate(startDate) : '—'}
|
||||
</p>
|
||||
<p className="mt-1.5 text-dim text-[0.8125rem]">{t('meta.startDateLockedHint')}</p>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<WeekPicker value={startDate} onChange={onStartDateChange} />
|
||||
{startWeekError && <ErrorText>{startWeekError}</ErrorText>}
|
||||
</>
|
||||
)}
|
||||
</Field>
|
||||
</div>
|
||||
{onSetChangeNote && (
|
||||
<div className="mt-4">
|
||||
<Field label={t('meta.changeNoteLabel')}>
|
||||
<textarea
|
||||
value={changeNote ?? ''}
|
||||
onChange={(e) => onSetChangeNote(e.target.value)}
|
||||
maxLength={300}
|
||||
rows={3}
|
||||
placeholder={t('meta.changeNotePlaceholder')}
|
||||
className="w-full rounded-[10px] border border-line bg-input px-3 py-2 text-[0.9rem] text-ink placeholder:text-dim/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60"
|
||||
/>
|
||||
<p className="mt-1.5 text-dim text-[0.8125rem]">{t('meta.changeNoteHint')}</p>
|
||||
</Field>
|
||||
</div>
|
||||
)}
|
||||
<p className="mt-3 text-dim text-[0.875rem]">
|
||||
{startDateLocked ? t('meta.editActiveHint') : t('meta.activateHint')}
|
||||
</p>
|
||||
</Card>
|
||||
</Field>
|
||||
<p className="mt-1 flex items-start gap-2 text-dim text-[0.875rem]">
|
||||
<Info className="mt-0.5 h-4 w-4 shrink-0" aria-hidden="true" />
|
||||
{t('meta.editActiveHint')}
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<WeekPicker value={startDate} onChange={onStartDateChange} />
|
||||
{startWeekError && (
|
||||
<div className="mt-3">
|
||||
<ErrorText>{startWeekError}</ErrorText>
|
||||
</div>
|
||||
)}
|
||||
<p className="mt-4 flex items-start gap-2 text-dim text-[0.875rem]">
|
||||
<Info className="mt-0.5 h-4 w-4 shrink-0" aria-hidden="true" />
|
||||
{t('meta.activateHint')}
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -211,6 +211,20 @@ describe('PlanEditor — data startu i menu kontekstowe', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('autofocus na tytule przy tworzeniu nowego planu; kalendarz tygodnia z przyciskiem „Dziś”', async () => {
|
||||
mockApi({});
|
||||
const user = userEvent.setup();
|
||||
renderApp();
|
||||
await loginAndOpenNewPlan(user);
|
||||
|
||||
// wejście do kreatora nowego planu = fokus na polu tytułu
|
||||
expect(document.activeElement).toBe(
|
||||
screen.getByPlaceholderText('np. Plan masowy 8-tygodniowy'),
|
||||
);
|
||||
// kalendarz tygodnia startu: nawigacja miesiącami + skrót do bieżącego miesiąca
|
||||
expect(screen.getByRole('button', { name: 'Dziś' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('blokuje minione tygodnie startu', async () => {
|
||||
mockApi({});
|
||||
const user = userEvent.setup();
|
||||
|
||||
Reference in New Issue
Block a user