import { useUser } from '../../user/userStore.ts'
import { useNavigate, Outlet } from 'react-router-dom'
import { useEffect } from 'react'

export default function Protected() {
  const { user } = useUser()

  const navigate = useNavigate()

  useEffect(() => {
    if (!user) {
      navigate('/login')
    }
  }, [user, navigate])

  return <Outlet />
}
