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