|
|
|
|
@@ -63,7 +63,9 @@ function SessionStatusCard({
|
|
|
|
|
<div className="flex flex-wrap items-center gap-x-4 gap-y-2">
|
|
|
|
|
{/* kolorowe badge'y zgrupowane po lewej; data nie rozdziela ich */}
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<Badge color={SESSION_STATUS[session.status].color}>{SESSION_STATUS[session.status].label}</Badge>
|
|
|
|
|
<Badge color={SESSION_STATUS[session.status].color}>
|
|
|
|
|
{SESSION_STATUS[session.status].label}
|
|
|
|
|
</Badge>
|
|
|
|
|
{extraDone > 0 && <Badge color="green">+{extraDone} bonus</Badge>}
|
|
|
|
|
</div>
|
|
|
|
|
<span className="text-dim text-[0.875rem]">start: {fmtDate(session.startedAt)}</span>
|
|
|
|
|
@@ -90,7 +92,10 @@ function SessionStatusCard({
|
|
|
|
|
</b>
|
|
|
|
|
/ {Math.floor(rest.totalSec / 60)}:{String(rest.totalSec % 60).padStart(2, '0')}
|
|
|
|
|
</span>
|
|
|
|
|
<ProgressBar percent={Math.round((restRemaining / rest.totalSec) * 100)} className="min-w-24 flex-1" />
|
|
|
|
|
<ProgressBar
|
|
|
|
|
percent={Math.round((restRemaining / rest.totalSec) * 100)}
|
|
|
|
|
className="min-w-24 flex-1"
|
|
|
|
|
/>
|
|
|
|
|
<Button variant="ghost" size="sm" onClick={onEndRest}>
|
|
|
|
|
Zakończ
|
|
|
|
|
</Button>
|
|
|
|
|
@@ -102,7 +107,9 @@ function SessionStatusCard({
|
|
|
|
|
|
|
|
|
|
/* Mała jednostka przy dużej liczbie (np. 70 + „kg” w 0.55em, dim). */
|
|
|
|
|
function Unit({ children }: { children: ReactNode }) {
|
|
|
|
|
return <span className="ml-0.5 text-[0.55em] font-semibold tracking-normal text-dim">{children}</span>;
|
|
|
|
|
return (
|
|
|
|
|
<span className="ml-0.5 text-[0.55em] font-semibold tracking-normal text-dim">{children}</span>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Wiersz serii: lewo (Seria N, Następna/bonus, cel z planu) | prawo (wynik, Edytuj/Uzupełnij, Usuń serię). */
|
|
|
|
|
@@ -177,7 +184,9 @@ function SetRow({
|
|
|
|
|
{planned.reps != null ? `${planned.reps} powt.` : ''}
|
|
|
|
|
</span>
|
|
|
|
|
) : null,
|
|
|
|
|
planned?.restSec != null ? <span key="rest">przerwa {planned.restSec} s</span> : null,
|
|
|
|
|
planned?.restSec != null ? (
|
|
|
|
|
<span key="rest">przerwa {planned.restSec} s</span>
|
|
|
|
|
) : null,
|
|
|
|
|
planned?.rir != null ? <span key="rir">RIR {planned.rir}</span> : null,
|
|
|
|
|
]
|
|
|
|
|
.filter(Boolean)
|
|
|
|
|
@@ -247,7 +256,8 @@ function ExerciseAccordion({
|
|
|
|
|
}) {
|
|
|
|
|
const isNextEx = exercise.sets.some((s) => s.id === nextSetId);
|
|
|
|
|
const doneCount = exercise.sets.filter((s) => s.reps != null).length;
|
|
|
|
|
const setPercent = exercise.sets.length > 0 ? Math.round((doneCount / exercise.sets.length) * 100) : 0;
|
|
|
|
|
const setPercent =
|
|
|
|
|
exercise.sets.length > 0 ? Math.round((doneCount / exercise.sets.length) * 100) : 0;
|
|
|
|
|
return (
|
|
|
|
|
<Card>
|
|
|
|
|
{/* nagłówek = akordeon: klik rozwija/zwija; aktywne ćwiczenie (z następną serią) rozwija się samo */}
|
|
|
|
|
@@ -260,7 +270,9 @@ function ExerciseAccordion({
|
|
|
|
|
>
|
|
|
|
|
<div className="flex flex-wrap items-center gap-2">
|
|
|
|
|
<H3 className="mb-0">{exercise.exercise.name}</H3>
|
|
|
|
|
<Badge color="green">Ćwiczenie {order} / {total}</Badge>
|
|
|
|
|
<Badge color="green">
|
|
|
|
|
Ćwiczenie {order} / {total}
|
|
|
|
|
</Badge>
|
|
|
|
|
{exercise.planExercise === null && <Badge color="blue">dodane do sesji</Badge>}
|
|
|
|
|
{isNextEx && !expanded && <Badge color="green">Następna</Badge>}
|
|
|
|
|
</div>
|
|
|
|
|
@@ -269,7 +281,11 @@ function ExerciseAccordion({
|
|
|
|
|
{MUSCLE_NAMES[exercise.exercise.primaryMuscle] || exercise.exercise.primaryMuscle}
|
|
|
|
|
</span>
|
|
|
|
|
{!expanded && (
|
|
|
|
|
<Badge color={doneCount === exercise.sets.length && exercise.sets.length > 0 ? 'green' : 'gray'}>
|
|
|
|
|
<Badge
|
|
|
|
|
color={
|
|
|
|
|
doneCount === exercise.sets.length && exercise.sets.length > 0 ? 'green' : 'gray'
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
{doneCount}/{exercise.sets.length}
|
|
|
|
|
</Badge>
|
|
|
|
|
)}
|
|
|
|
|
@@ -282,7 +298,9 @@ function ExerciseAccordion({
|
|
|
|
|
Usuń
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
<ChevronDown className={`w-5 h-5 text-dim transition-transform ${expanded ? 'rotate-180' : ''}`} />
|
|
|
|
|
<ChevronDown
|
|
|
|
|
className={`w-5 h-5 text-dim transition-transform ${expanded ? 'rotate-180' : ''}`}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@@ -312,7 +330,13 @@ function ExerciseAccordion({
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
{inProgress && (
|
|
|
|
|
<Button variant="secondary" size="sm" className="mt-2" onClick={onAddSet} disabled={!canAddExtra}>
|
|
|
|
|
<Button
|
|
|
|
|
variant="secondary"
|
|
|
|
|
size="sm"
|
|
|
|
|
className="mt-2"
|
|
|
|
|
onClick={onAddSet}
|
|
|
|
|
disabled={!canAddExtra}
|
|
|
|
|
>
|
|
|
|
|
<Plus className="w-4 h-4" />
|
|
|
|
|
Dodaj serię
|
|
|
|
|
</Button>
|
|
|
|
|
@@ -349,7 +373,9 @@ function AddExerciseModal({
|
|
|
|
|
className="flex items-center justify-between gap-3 w-full px-3 py-2.5 rounded-[10px] text-left hover:bg-line/22 cursor-pointer transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<span className="font-semibold">{p.name}</span>
|
|
|
|
|
<span className="text-dim text-[0.8rem]">{MUSCLE_NAMES[p.primaryMuscle] || p.primaryMuscle}</span>
|
|
|
|
|
<span className="text-dim text-[0.8rem]">
|
|
|
|
|
{MUSCLE_NAMES[p.primaryMuscle] || p.primaryMuscle}
|
|
|
|
|
</span>
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
@@ -376,7 +402,7 @@ export default function DayExecution() {
|
|
|
|
|
const [editSet, setEditSet] = useState<{
|
|
|
|
|
setId: string;
|
|
|
|
|
index: number;
|
|
|
|
|
planned: { reps: number | null; rir: number | null; difficulty: number | null };
|
|
|
|
|
planned: { reps: number | null; rir: number | null };
|
|
|
|
|
restSec: number | null;
|
|
|
|
|
} | null>(null);
|
|
|
|
|
|
|
|
|
|
@@ -421,7 +447,8 @@ export default function DayExecution() {
|
|
|
|
|
// Akordeon: rozwinięte jest ćwiczenie zawierające następną serię (aktywne);
|
|
|
|
|
// kliknięcie nagłówka przełącza rozwinięcie (jedno ćwiczenie naraz).
|
|
|
|
|
const nextExerciseId = session
|
|
|
|
|
? session.exercises.find((ex) => !ex.removed && ex.sets.some((s) => s.id === nextSetId))?.id ?? null
|
|
|
|
|
? (session.exercises.find((ex) => !ex.removed && ex.sets.some((s) => s.id === nextSetId))?.id ??
|
|
|
|
|
null)
|
|
|
|
|
: null;
|
|
|
|
|
const [expandedExId, setExpandedExId] = useState<string | null>(null);
|
|
|
|
|
|
|
|
|
|
@@ -445,7 +472,11 @@ export default function DayExecution() {
|
|
|
|
|
setRest(null);
|
|
|
|
|
}, [sessionId]);
|
|
|
|
|
|
|
|
|
|
const [dayInfo, setDayInfo] = useState<{ date: string | null; status: string; dayOfWeek: number } | null>(null);
|
|
|
|
|
const [dayInfo, setDayInfo] = useState<{
|
|
|
|
|
date: string | null;
|
|
|
|
|
status: string;
|
|
|
|
|
dayOfWeek: number;
|
|
|
|
|
} | null>(null);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// Fetch day info through a direct API call.
|
|
|
|
|
@@ -455,9 +486,14 @@ export default function DayExecution() {
|
|
|
|
|
|
|
|
|
|
const fetchDayInfo = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const data = await api<{ day: { date: string | null; status: string; dayOfWeek: number; sessions: { id: string; status: string }[] } }>(
|
|
|
|
|
`/days/${dayId}`,
|
|
|
|
|
);
|
|
|
|
|
const data = await api<{
|
|
|
|
|
day: {
|
|
|
|
|
date: string | null;
|
|
|
|
|
status: string;
|
|
|
|
|
dayOfWeek: number;
|
|
|
|
|
sessions: { id: string; status: string }[];
|
|
|
|
|
};
|
|
|
|
|
}>(`/days/${dayId}`);
|
|
|
|
|
setDayInfo({ date: data.day.date, status: data.day.status, dayOfWeek: data.day.dayOfWeek });
|
|
|
|
|
const active = data.day.sessions.find((s) => s.status === 'IN_PROGRESS');
|
|
|
|
|
if (active) setSessionId(active.id);
|
|
|
|
|
@@ -528,13 +564,19 @@ export default function DayExecution() {
|
|
|
|
|
back: '/calendar',
|
|
|
|
|
// akcje sesji (Ukończ/Porzuć) widoczne na starcie — grupa otwarta domyślnie
|
|
|
|
|
defaultOpenGroup: 'actions',
|
|
|
|
|
actions: session?.status === 'IN_PROGRESS'
|
|
|
|
|
? [
|
|
|
|
|
{ label: 'Dodaj ćwiczenie', onClick: () => setAddExerciseOpen(true), icon: Plus },
|
|
|
|
|
{ label: 'Ukończ sesję', onClick: complete, disabled: busy || normPending > 0 },
|
|
|
|
|
{ label: 'Porzuć sesję', onClick: () => setConfirmAbandon(true), variant: 'danger' as const, disabled: busy },
|
|
|
|
|
]
|
|
|
|
|
: undefined,
|
|
|
|
|
actions:
|
|
|
|
|
session?.status === 'IN_PROGRESS'
|
|
|
|
|
? [
|
|
|
|
|
{ label: 'Dodaj ćwiczenie', onClick: () => setAddExerciseOpen(true), icon: Plus },
|
|
|
|
|
{ label: 'Ukończ sesję', onClick: complete, disabled: busy || normPending > 0 },
|
|
|
|
|
{
|
|
|
|
|
label: 'Porzuć sesję',
|
|
|
|
|
onClick: () => setConfirmAbandon(true),
|
|
|
|
|
variant: 'danger' as const,
|
|
|
|
|
disabled: busy,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
: undefined,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const addExercise = async (exerciseId: string) => {
|
|
|
|
|
@@ -645,7 +687,8 @@ export default function DayExecution() {
|
|
|
|
|
{!session && dayInfo && dayInfo.status !== 'PLANNED' && (
|
|
|
|
|
<Card>
|
|
|
|
|
<p className="text-dim">
|
|
|
|
|
Dzień jest {dayInfo.status === 'COMPLETED' ? 'ukończony' : 'pominięty'}. Brak aktywnej sesji.
|
|
|
|
|
Dzień jest {dayInfo.status === 'COMPLETED' ? 'ukończony' : 'pominięty'}. Brak aktywnej
|
|
|
|
|
sesji.
|
|
|
|
|
</p>
|
|
|
|
|
</Card>
|
|
|
|
|
)}
|
|
|
|
|
@@ -683,8 +726,8 @@ export default function DayExecution() {
|
|
|
|
|
setId: s.id,
|
|
|
|
|
index: i,
|
|
|
|
|
planned: planned
|
|
|
|
|
? { reps: planned.reps, rir: planned.rir, difficulty: planned.difficulty }
|
|
|
|
|
: { reps: null, rir: null, difficulty: null },
|
|
|
|
|
? { reps: planned.reps, rir: planned.rir }
|
|
|
|
|
: { reps: null, rir: null },
|
|
|
|
|
restSec: planned?.restSec ?? null,
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
@@ -721,9 +764,10 @@ export default function DayExecution() {
|
|
|
|
|
open={editSet != null}
|
|
|
|
|
setIndex={editSet?.index ?? 0}
|
|
|
|
|
values={editValues}
|
|
|
|
|
planned={editSet?.planned ?? { reps: null, rir: null, difficulty: null }}
|
|
|
|
|
planned={editSet?.planned ?? { reps: null, rir: null }}
|
|
|
|
|
title={
|
|
|
|
|
editSet && (editValues.reps !== '' || editValues.rir !== '' || editValues.difficulty !== '')
|
|
|
|
|
editSet &&
|
|
|
|
|
(editValues.reps !== '' || editValues.rir !== '' || editValues.difficulty !== '')
|
|
|
|
|
? `Edytuj serię ${editSet.index + 1}`
|
|
|
|
|
: undefined
|
|
|
|
|
}
|
|
|
|
|
|