- {sessions.map((s) => {
- const st = SESSION_STATUS[s.status];
- const open = openSession === s.id;
- const plannedTotal = s.exercises.reduce(
- (n, ex) => n + ex.sets.filter((set) => set.planned).length,
- 0,
- );
- const plannedDone = s.exercises.reduce(
- (n, ex) => n + ex.sets.filter((set) => set.planned && set.reps != null).length,
- 0,
- );
- // Serie wykonane ponad plan (bez planowanego odpowiednika) z zapisanymi powtórzeniami.
- const extraSets = s.exercises.reduce(
- (n, ex) => n + ex.sets.filter((set) => set.planned == null && set.reps != null).length,
- 0,
- );
- // Deficyt = niewyrobione serie normowe (bonus nie wchodzi w normę).
- const deficit = plannedTotal - plannedDone;
- // Objętość = Σ obciążenie × powtórzenia; seria bez planowanego obciążenia = masa ciała z profilu.
- const volume = s.exercises
- .flatMap((ex) => ex.sets)
- .reduce(
- (sum, set) =>
- set.reps != null ? sum + (set.planned?.loadKg ?? s.bodyKg ?? 0) * set.reps : sum,
- 0,
- );
- const duration = s.endedAt ? fmtDuration(s.startedAt, s.endedAt) : null;
- return (
-
-
- {open && (
-
- {s.exercises.length === 0 && (
-
{t('history.noExercises')}
- )}
- {s.exercises.length > 0 && (
-
- {s.exercises.map((ex) => (
-
-
-
-
- {localizedName(ex, i18n.language)}
-
- {ex.isExtra && {t('history.added')}}
-
-
- {muscleName(ex.muscle) || ex.muscle}
-
-
-
- {ex.sets.map((set) => (
-
-
-
- S{set.index + 1}
-
- {set.planned && set.reps == null ? (
-
- {t('history.notDone')}
-
- ) : (
-
- {set.reps ?? '—'}
-
- {t('history.repsUnit')}
-
-
- )}
-
- {(set.planned || set.rir != null || set.difficulty != null) && (
-
- {set.planned && (
-
- {t('history.planPrefix')}
- {set.planned.reps ?? '—'}
- {set.planned.loadKg != null
- ? `/${set.planned.loadKg} kg`
- : `/${t('history.bodyweight')}`}
- {set.planned.restSec != null
- ? `/${set.planned.restSec} s`
- : ''}
-
- )}
- {set.rir != null && RIR {set.rir}}
- {set.difficulty != null && (
-
- {t('history.difficultyWord', { n: set.difficulty })}
-
- )}
-
- )}
- {set.note && (
-
-
- {set.note}
-
- )}
-
- ))}
-
- {ex.comments.length > 0 && (
-
- {ex.comments.map((c) => (
-
-
-
{c.authorName}
-
· {fmtDate(c.createdAt)}
-
{c.body}
-
-
- ))}
-
- )}
-
- ))}
-
- )}
-
- )}
-
- );
- })}
-
- );
-}
diff --git a/admin/src/components/MembershipActionsModal.tsx b/admin/src/components/MembershipActionsModal.tsx
new file mode 100644
index 0000000..b651345
--- /dev/null
+++ b/admin/src/components/MembershipActionsModal.tsx
@@ -0,0 +1,137 @@
+import { useState } from 'react';
+import { Link } from 'react-router-dom';
+import { useTranslation } from 'react-i18next';
+import { api } from '../api/client';
+import type { GymRole } from '../api/types';
+import { GymRolePicker } from './GymRolePicker';
+import { Button, ErrorText, Field, Modal, Muted, Textarea } from './ui';
+import { GYM_ROLE_ORDER } from '../lib/roles';
+
+/**
+ * Wspólne menu członkostwa (konsola siłowni + profil usera): pełna lista ról (PATCH)
+ * oraz wyrzucenie z siłowni z wymagalnym powodem (DELETE + audyt membership.deleted).
+ */
+export function MembershipActionsModal({
+ userId,
+ titleName,
+ gymId,
+ roles: initialRoles,
+ showProfileLink = true,
+ onClose,
+ onChanged,
+}: {
+ userId: string;
+ titleName: string;
+ gymId: string;
+ roles: string[];
+ showProfileLink?: boolean;
+ onClose: () => void;
+ onChanged: () => void;
+}) {
+ const { t } = useTranslation('gyms');
+ const [roles, setRoles] = useState