Files
FitOS/admin/src/pages/users/UserProgress.tsx

61 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useParams } from 'react-router-dom';
import { TrendingUp } from 'lucide-react';
import { useTopbar } from '../../topbar';
import {
BackButton,
Card,
EmptyState,
ErrorText,
Muted,
PageHeader,
Skeleton,
} from '../../components/ui';
import ExerciseProgressCards from '../../components/ExerciseProgressCards';
import { useUserExerciseProgress } from './user-queries';
/**
* Postępy per ćwiczenie (1RM Epley + objętość) użytkownika — widok admina,
* wzorowany na `/profile/progress` z aplikacji.
*/
export default function UserProgress() {
const { id } = useParams();
useTopbar({ title: 'Postępy', back: id ? `/users/${id}` : '/users' });
const { data, isLoading, error } = useUserExerciseProgress(id);
if (isLoading) {
return (
<div className="space-y-4">
<Skeleton className="h-9 w-48" />
<Skeleton className="h-64" />
</div>
);
}
const exercises = data?.exercises ?? [];
return (
<>
<PageHeader
title="Postępy per ćwiczenie"
actions={<BackButton to={id ? `/users/${id}` : '/users'} />}
/>
<Card>
<Muted className="text-[0.875rem]">
1RM Epley: zaplanowane obciążenie × (1 + powtórzenia/30), maks. per sesja; objętość = Σ
obciążenie × powtórzenia.
</Muted>
{error && <ErrorText>Błąd: {(error as Error).message}</ErrorText>}
{!error && exercises.length === 0 && (
<EmptyState
icon={TrendingUp}
title="Brak postępów"
description="Postępy pojawią się po pierwszym ukończonym treningu użytkownika."
/>
)}
{!error && exercises.length > 0 && <ExerciseProgressCards exercises={exercises} />}
</Card>
</>
);
}