diff --git a/client/pages/UserPage.tsx b/client/pages/UserPage.tsx index ea9cb36..d5a4241 100644 --- a/client/pages/UserPage.tsx +++ b/client/pages/UserPage.tsx @@ -1,4 +1,4 @@ -import { isAdministrator, Solution as SolutionModel } from '../../shared/model' +import { isAdministrator, Solution as SolutionModel, SolutionStat } from '../../shared/model' import { sortByStringKey } from '../../shared/utils' import { prependBaseUrl } from '../api' import { Header } from '../components/Header' @@ -14,20 +14,34 @@ export const UserPage = ({ uid }: RouteProps) => { const [user] = useCurrentUser() - const [solutions, refreshSolutions] = useResource(`/api/solutions?user=${uid}`, []) - const sortedSolutions = sortByStringKey(solutions, s => s.createdAt, false) + const [stats] = useResource>(`/api/stats`, null) + if(stats) { + const userStats = stats[uid] - return ( - <> -
-
-
Soluzioni di @{uid}
-
- {sortedSolutions.map(solution => ( - - ))} -
-
- - ) -} \ No newline at end of file + const [solutions, refreshSolutions] = useResource(`/api/solutions?user=${uid}`, []) + const sortedSolutions = sortByStringKey(solutions, s => s.createdAt, false) + + return ( + <> +
+
+
Statistiche di @{uid}
+
    +
  • +
    Soluzioni inviate: {userStats.sentSolutionsCount}
    +
  • +
  • +
    Soluzioni corrette: {userStats.correctSolutionsCount}
    +
  • +
+
Soluzioni notevoli
+
+ {sortedSolutions.map(solution => ( + + ))} +
+
+ + ) + } +} diff --git a/client/styles/main.scss b/client/styles/main.scss index 50254c9..f3dd742 100644 --- a/client/styles/main.scss +++ b/client/styles/main.scss @@ -308,6 +308,10 @@ main { font-size: 28px; } + .info { + font-size: 20px; + } + .fill-main { display: flex; gap: 0.5rem;