46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { useParams } from 'react-router-dom';
|
|
import { TrendingUp } from 'lucide-react';
|
|
import { useTopbar } from '../../topbar';
|
|
import { BackButton, Card, EmptyState, ErrorText, PageHeader, Skeleton } from '../../components/ui';
|
|
import ExerciseProgressCards from '../../components/ExerciseProgressCards';
|
|
import { useUserExerciseProgress } from './user-queries';
|
|
|
|
/**
|
|
* Postępy per ćwiczenie użytkownika — widok admina 1:1 z `/profile/progress`
|
|
* z aplikacji (czyt. opis wzoru 1RM usunięty z obu stron).
|
|
*/
|
|
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" actions={<BackButton to={id ? `/users/${id}` : '/users'} />} />
|
|
|
|
<Card>
|
|
{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>
|
|
</>
|
|
);
|
|
}
|