import { route } from 'preact-router' import { useState } from 'preact/hooks' import { server } from '../api.jsx' import { Header } from '../components/Header.jsx' import { Solution } from '../components/Solution.jsx' import { useCurrentUser, useReadResource } from '../hooks.jsx' export const ProfilePage = ({}) => { const [solutions, setSolutions] = useState([]) const [user, logout] = useCurrentUser(async user => { if (!user) { route('/login', true) } setSolutions(await server.get(`/api/solutions?user=${user.id}`)) }) const handleLogout = () => { logout() route('/') } return ( user && (
Le tue soluzioni
{solutions.map(({ forProblem, content }) => ( ))}
Altro
) ) }