import { isAdministrator, Solution as SolutionModel, SolutionStat } from '../../shared/model' import { sortByStringKey } from '../../shared/utils' import { prependBaseUrl } from '../api' import { Header } from '../components/Header' import { Solution } from '../components/Solution' import { useResource } from '../hooks' import { useCurrentUser } from '../hooks/useCurrentUser' type RouteProps = { uid: string } export const UserPage = ({ uid }: RouteProps) => { const [user] = useCurrentUser() const [stats] = useResource>(`/api/stats`, null) if(stats) { const userStats = stats[uid] const [solutions, refreshSolutions] = useResource(`/api/solutions?user=${uid}`, []) const sortedSolutions = sortByStringKey(solutions, s => s.createdAt, false) return ( <>
Profilo di @{uid}

Statistiche
Soluzioni inviate
Soluzioni corrette
{userStats.sentSolutionsCount}
{userStats.correctSolutionsCount}
Soluzioni notevoli
{sortedSolutions.map(solution => ( ))}
) } else { return <> } }