2026-09-04 19:06:19 +02:00
|
|
|
import { useEffect, useMemo, useState } from 'react';
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2026-09-04 19:06:19 +02:00
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
|
|
import { ScrollText } from 'lucide-react';
|
|
|
|
|
import { useTopbar } from '../topbar';
|
2026-10-17 04:27:39 +02:00
|
|
|
import { MonthPickerCore } from '../topbar/MonthPicker';
|
2026-09-04 19:06:19 +02:00
|
|
|
import { api } from '../api/client';
|
|
|
|
|
import type { ActivityLog, ActivityLogPage } from '../api/types';
|
|
|
|
|
import { Badge, EmptyState, ErrorText, Loading, Select, type BadgeColor } from '../components/ui';
|
|
|
|
|
import { useListSearch } from '../store/list-search';
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
import i18n from '../i18n';
|
|
|
|
|
import { fmtDateTime } from '../lib/format';
|
2026-09-04 19:06:19 +02:00
|
|
|
|
2026-10-17 16:18:37 +02:00
|
|
|
const t = (key: string, options?: Record<string, unknown>): string =>
|
|
|
|
|
String(i18n.t(`logs:${key}`, options as never));
|
2026-09-04 19:06:19 +02:00
|
|
|
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
export const ACTION_KEYS = [
|
|
|
|
|
'user.registered',
|
2026-10-19 22:39:12 +02:00
|
|
|
'user.logged_in',
|
|
|
|
|
'user.logged_out',
|
|
|
|
|
'user.created',
|
|
|
|
|
'user.updated',
|
|
|
|
|
'user.status.changed',
|
|
|
|
|
'user.admin.changed',
|
|
|
|
|
'user.deleted',
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
'profile.updated',
|
|
|
|
|
'weight.added',
|
|
|
|
|
'weight.removed',
|
|
|
|
|
'circumference.added',
|
|
|
|
|
'circumference.removed',
|
|
|
|
|
'plan.created',
|
|
|
|
|
'plan.updated',
|
|
|
|
|
'plan.deleted',
|
|
|
|
|
'plan.activated',
|
|
|
|
|
'plan.abandoned',
|
|
|
|
|
'plan.completed',
|
|
|
|
|
'plan.reopened',
|
2026-10-19 22:39:12 +02:00
|
|
|
'plan.shared',
|
|
|
|
|
'plan.unshared',
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
'session.started',
|
|
|
|
|
'session.completed',
|
|
|
|
|
'session.abandoned',
|
|
|
|
|
'session.reopened',
|
|
|
|
|
'gym.created',
|
|
|
|
|
'gym.updated',
|
|
|
|
|
'gym.deleted',
|
|
|
|
|
'gym.joined',
|
2026-10-19 22:39:12 +02:00
|
|
|
'gym.invited',
|
|
|
|
|
'gym.invitation.accepted',
|
|
|
|
|
'gym.invitation.declined',
|
|
|
|
|
'gym.invitation.withdrawn',
|
|
|
|
|
'gym.owner.granted',
|
|
|
|
|
'gym.owner.revoked',
|
|
|
|
|
'gym.exception.added',
|
|
|
|
|
'gym.exception.removed',
|
|
|
|
|
'gym.equipment.added',
|
|
|
|
|
'gym.equipment.updated',
|
|
|
|
|
'gym.equipment.removed',
|
|
|
|
|
'gym.claim.created',
|
|
|
|
|
'gym.claim.approved',
|
|
|
|
|
'gym.claim.rejected',
|
|
|
|
|
'gym.claim.withdrawn',
|
|
|
|
|
'gym.photos.added',
|
|
|
|
|
'gym.photo.deleted',
|
|
|
|
|
'gym.photo.cover',
|
|
|
|
|
'gym.equipment.photos.added',
|
|
|
|
|
'gym.equipment.photo.deleted',
|
|
|
|
|
'membership.created',
|
|
|
|
|
'membership.updated',
|
|
|
|
|
'membership.deleted',
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
'coaching.invited',
|
|
|
|
|
'coaching.accepted',
|
|
|
|
|
'coaching.declined',
|
|
|
|
|
'coaching.withdrawn',
|
|
|
|
|
'coaching.archived',
|
2026-10-19 22:39:12 +02:00
|
|
|
'comment.added',
|
|
|
|
|
'comment.deleted',
|
|
|
|
|
'announcement.published',
|
|
|
|
|
'announcement.updated',
|
|
|
|
|
'announcement.deleted',
|
|
|
|
|
'exercise.created',
|
|
|
|
|
'exercise.updated',
|
|
|
|
|
'exercise.deleted',
|
|
|
|
|
'equipment.created',
|
|
|
|
|
'equipment.updated',
|
|
|
|
|
'equipment.deleted',
|
|
|
|
|
'focus_area.created',
|
|
|
|
|
'focus_area.updated',
|
|
|
|
|
'focus_area.deleted',
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
];
|
2026-09-04 19:06:19 +02:00
|
|
|
|
|
|
|
|
export function actionLabel(action: string) {
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
return t(`actions.${action}`, { defaultValue: action });
|
2026-09-04 19:06:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function actionColor(action: string): BadgeColor {
|
|
|
|
|
if (action.startsWith('plan.')) return 'blue';
|
|
|
|
|
if (action.startsWith('session.')) return 'green';
|
|
|
|
|
if (action.startsWith('gym.')) return 'gray';
|
|
|
|
|
if (action.startsWith('coaching.')) return 'red';
|
2026-10-19 22:39:12 +02:00
|
|
|
// akcje security konta — tak samo wyraźne jak relacje trenerskie
|
|
|
|
|
if (action.startsWith('user.')) return 'red';
|
|
|
|
|
if (action.startsWith('membership.')) return 'blue';
|
2026-09-04 19:06:19 +02:00
|
|
|
return 'yellow';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function formatLogDate(iso: string) {
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
return fmtDateTime(iso);
|
2026-09-04 19:06:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function actorName(log: ActivityLog) {
|
|
|
|
|
const { firstName, lastName, email } = log.actor;
|
|
|
|
|
return [firstName, lastName].filter(Boolean).join(' ') || email;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Nazwa obiektu z szczegółów wpisu (tytuł planu, nazwa siłowni, nazwa obwodu). */
|
|
|
|
|
function entityName(log: ActivityLog) {
|
|
|
|
|
const d = log.details;
|
|
|
|
|
if (!d) return null;
|
|
|
|
|
return (d.title ?? d.name ?? d.gymName ?? null) as string | null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Klucze pokazywane w innych kolumnach (aktor w „Użytkownik", nazwa w „Obiekt"). */
|
|
|
|
|
const HIDDEN_DETAIL_KEYS = new Set(['actorId', 'title', 'name', 'gymName']);
|
|
|
|
|
|
|
|
|
|
function formatDetailValue(log: ActivityLog, key: string, value: unknown): string {
|
|
|
|
|
if (Array.isArray(value)) return value.map((v) => String(v)).join(', ');
|
|
|
|
|
if (value && typeof value === 'object') {
|
|
|
|
|
return Object.entries(value)
|
|
|
|
|
.map(([k, v]) => `${k}: ${formatDetailValue(log, k, v)}`)
|
|
|
|
|
.join(', ');
|
|
|
|
|
}
|
|
|
|
|
let text = String(value);
|
|
|
|
|
if (key === 'value' && typeof value === 'number') {
|
|
|
|
|
const unit =
|
|
|
|
|
log.action === 'weight.added' || log.action === 'weight.removed'
|
|
|
|
|
? ' kg'
|
|
|
|
|
: log.action === 'circumference.added' || log.action === 'circumference.removed'
|
|
|
|
|
? ' cm'
|
|
|
|
|
: '';
|
|
|
|
|
text += unit;
|
|
|
|
|
}
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Szczegóły wpisu jako naturalny tekst: `start: 2026-08-24 · wartość: 82.5 kg`. */
|
|
|
|
|
function detailsText(log: ActivityLog) {
|
|
|
|
|
const d = log.details;
|
|
|
|
|
if (!d) return null;
|
|
|
|
|
const parts = Object.entries(d)
|
|
|
|
|
.filter(([k]) => !HIDDEN_DETAIL_KEYS.has(k))
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
.map(([k, v]) => `${t(`details.${k}`, { defaultValue: k })}: ${formatDetailValue(log, k, v)}`);
|
2026-09-04 19:06:19 +02:00
|
|
|
return parts.length > 0 ? parts.join(' · ') : null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const PAGE_SIZE = 100;
|
|
|
|
|
|
|
|
|
|
export default function Logs() {
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
const { t: tr } = useTranslation('logs');
|
2026-09-04 19:06:19 +02:00
|
|
|
const [action, setAction] = useState('');
|
|
|
|
|
const [month, setMonth] = useState('');
|
|
|
|
|
const [limit, setLimit] = useState(PAGE_SIZE);
|
|
|
|
|
const query = useListSearch((s) => s.queries.logs);
|
|
|
|
|
const setQuery = useListSearch((s) => s.setQuery);
|
|
|
|
|
|
|
|
|
|
const hasFilters = action !== '' || month !== '';
|
|
|
|
|
|
|
|
|
|
const { data, isLoading, error } = useQuery({
|
|
|
|
|
queryKey: ['admin-logs', action, month, limit],
|
|
|
|
|
queryFn: () => {
|
|
|
|
|
const params = new URLSearchParams();
|
|
|
|
|
if (action) params.set('action', action);
|
|
|
|
|
if (month) {
|
|
|
|
|
const [y, m] = month.split('-').map(Number);
|
|
|
|
|
params.set('from', `${month}-01`);
|
|
|
|
|
params.set('to', `${month}-${String(new Date(y, m, 0).getDate()).padStart(2, '0')}`);
|
|
|
|
|
}
|
|
|
|
|
params.set('limit', String(limit));
|
|
|
|
|
return api<ActivityLogPage>(`/admin/logs?${params.toString()}`);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2026-10-17 04:27:39 +02:00
|
|
|
// miesiące do panelu selektora: z załadowanych logów + bieżący (chip lata)
|
|
|
|
|
const availableMonths = useMemo(() => {
|
|
|
|
|
const d = new Date();
|
|
|
|
|
const current = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}`;
|
|
|
|
|
const set = new Set([...(data?.logs ?? []).map((l) => l.createdAt.slice(0, 7)), current]);
|
2026-09-04 19:06:19 +02:00
|
|
|
return [...set].sort().reverse();
|
|
|
|
|
}, [data?.logs]);
|
|
|
|
|
|
|
|
|
|
useTopbar({
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
title: tr('common:nav.logs'),
|
2026-09-04 19:06:19 +02:00
|
|
|
search: 'logs',
|
|
|
|
|
dateFilter: (
|
2026-10-17 04:27:39 +02:00
|
|
|
<MonthPickerCore
|
|
|
|
|
month={month}
|
|
|
|
|
setMonth={(m) => {
|
2026-09-04 19:06:19 +02:00
|
|
|
setMonth(m);
|
|
|
|
|
setLimit(PAGE_SIZE);
|
|
|
|
|
}}
|
2026-10-17 04:27:39 +02:00
|
|
|
availableMonths={availableMonths}
|
|
|
|
|
allowAll
|
2026-09-04 19:06:19 +02:00
|
|
|
/>
|
|
|
|
|
),
|
|
|
|
|
filters: [
|
|
|
|
|
<div key="action" className="w-48">
|
|
|
|
|
<Select
|
|
|
|
|
size="sm"
|
|
|
|
|
className="h-9"
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
aria-label={tr('filterAria')}
|
2026-09-04 19:06:19 +02:00
|
|
|
value={action}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
setAction(e.target.value);
|
|
|
|
|
setLimit(PAGE_SIZE);
|
|
|
|
|
}}
|
|
|
|
|
>
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
<option value="">{tr('allActions')}</option>
|
|
|
|
|
{ACTION_KEYS.map((value) => (
|
2026-09-04 19:06:19 +02:00
|
|
|
<option key={value} value={value}>
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
{tr(`actions.${value}`)}
|
2026-09-04 19:06:19 +02:00
|
|
|
</option>
|
|
|
|
|
))}
|
|
|
|
|
</Select>
|
|
|
|
|
</div>,
|
|
|
|
|
],
|
|
|
|
|
filterActive: hasFilters,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// wyszukiwarka jest w menu kontekstowym (Layout) — czyścimy ją przy opuszczeniu strony
|
|
|
|
|
useEffect(() => () => setQuery('logs', ''), [setQuery]);
|
|
|
|
|
|
|
|
|
|
const logs = data?.logs ?? [];
|
|
|
|
|
const total = data?.total ?? 0;
|
|
|
|
|
|
|
|
|
|
const filtered = query
|
|
|
|
|
? logs.filter((l) => {
|
|
|
|
|
const q = query.toLowerCase();
|
|
|
|
|
const name = `${l.actor.firstName ?? ''} ${l.actor.lastName ?? ''}`.toLowerCase();
|
|
|
|
|
return l.actor.email.toLowerCase().includes(q) || (name.trim() && name.includes(q));
|
|
|
|
|
})
|
|
|
|
|
: logs;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{isLoading && <Loading />}
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
{error && (
|
|
|
|
|
<ErrorText>
|
|
|
|
|
{tr('common:errorPrefix')}
|
|
|
|
|
{(error as Error).message}
|
|
|
|
|
</ErrorText>
|
|
|
|
|
)}
|
2026-09-04 19:06:19 +02:00
|
|
|
|
|
|
|
|
{!isLoading && !error && filtered.length === 0 && (
|
|
|
|
|
<EmptyState
|
|
|
|
|
icon={ScrollText}
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
title={tr('noEventsTitle')}
|
2026-09-04 19:06:19 +02:00
|
|
|
description={
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
query ? tr('noResultsDesc') : hasFilters ? tr('noEventsFiltered') : tr('noEventsDesc')
|
2026-09-04 19:06:19 +02:00
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{!isLoading && !error && filtered.length > 0 && (
|
2026-09-05 02:27:57 +02:00
|
|
|
<div className="overflow-x-auto rounded-[10px] border border-line bg-(image:--card-grad) shadow-card">
|
2026-09-04 19:06:19 +02:00
|
|
|
<table className="w-full text-[0.95rem]">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr className="border-b border-line text-left text-dim">
|
2026-10-14 22:37:52 +02:00
|
|
|
<th className="px-4 py-3 text-[10.5px] font-bold uppercase tracking-[0.11em]">
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
{tr('colDate')}
|
2026-10-14 22:37:52 +02:00
|
|
|
</th>
|
|
|
|
|
<th className="px-4 py-3 text-[10.5px] font-bold uppercase tracking-[0.11em]">
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
{tr('colUser')}
|
2026-10-14 22:37:52 +02:00
|
|
|
</th>
|
|
|
|
|
<th className="px-4 py-3 text-[10.5px] font-bold uppercase tracking-[0.11em]">
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
{tr('colAction')}
|
2026-10-14 22:37:52 +02:00
|
|
|
</th>
|
|
|
|
|
<th className="px-4 py-3 text-[10.5px] font-bold uppercase tracking-[0.11em]">
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
{tr('colEntity')}
|
2026-10-14 22:37:52 +02:00
|
|
|
</th>
|
|
|
|
|
<th className="px-4 py-3 text-[10.5px] font-bold uppercase tracking-[0.11em]">
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
{tr('colDetails')}
|
2026-10-14 22:37:52 +02:00
|
|
|
</th>
|
2026-09-04 19:06:19 +02:00
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
{filtered.map((log) => (
|
2026-10-14 22:37:52 +02:00
|
|
|
<tr
|
|
|
|
|
key={log.id}
|
|
|
|
|
className="border-b border-line/60 transition-colors last:border-b-0 hover:bg-line/20"
|
|
|
|
|
>
|
|
|
|
|
<td className="whitespace-nowrap px-4 py-3 font-display text-dim tabular-nums">
|
|
|
|
|
{formatLogDate(log.createdAt)}
|
|
|
|
|
</td>
|
2026-09-04 19:06:19 +02:00
|
|
|
<td className="px-4 py-3">
|
|
|
|
|
<div className="font-semibold">{actorName(log)}</div>
|
|
|
|
|
<div className="text-[0.875rem] text-dim">{log.actor.email}</div>
|
|
|
|
|
<div className="font-mono text-[0.75rem] text-dim/70" title={log.actor.id}>
|
|
|
|
|
{log.actor.id}
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
<td className="px-4 py-3">
|
|
|
|
|
<Badge color={actionColor(log.action)}>{actionLabel(log.action)}</Badge>
|
|
|
|
|
</td>
|
|
|
|
|
<td className="px-4 py-3">
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
<div>{tr(`entities.${log.entityType}`, { defaultValue: log.entityType })}</div>
|
2026-10-14 22:37:52 +02:00
|
|
|
{entityName(log) && (
|
|
|
|
|
<div className="text-[0.875rem] text-dim">{entityName(log)}</div>
|
|
|
|
|
)}
|
2026-09-04 19:06:19 +02:00
|
|
|
</td>
|
|
|
|
|
<td className="px-4 py-3 text-dim">{detailsText(log) ?? '—'}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
))}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{!isLoading && !error && logs.length < total && (
|
|
|
|
|
<div className="mt-4 text-center">
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => setLimit((l) => l + PAGE_SIZE)}
|
|
|
|
|
className="text-[0.9rem] font-semibold text-accent-text hover:underline cursor-pointer"
|
|
|
|
|
>
|
I18n: panel admina (partia 6) - tlumaczenie calego UI: common rozbudowany (nav/topbar/fmt/counters/roles/equipmentKind/picker/muscles/statuses), nowe namespace'y gyms/users/catalog/logs/verifications/announcements; lib format/labels/availability/equipment/roles na i18n.t (Intl wg jezyka); layout, topbar, MonthPicker, modale i pickery; strony Login, Logs, Verifications, Announcements, katalog (Equipment/Exercises/FocusAreas), siłownie (GymForm/GymsList/GymDetail z sekcjami) i users (lista, wizard, profil z podstronami, parametry ciala, historia, postepy, członkostwa, wnioski, kary); auth store i formaty dat/licit przez jezyk; testy jednostkowe 84/84 zielone
2026-10-17 16:00:36 +02:00
|
|
|
{tr('showMoreRemaining', { n: total - logs.length })}
|
2026-09-04 19:06:19 +02:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|