import { useEffect } from "react"
import { getToken } from "../utils/auth"
import { useNavigate } from "react-router-dom"

function WithToken({ children }) {
    const navigate = useNavigate()

    useEffect(() => {
        if (!getToken()) {
            return navigate("/login")
        }
    }, [navigate])
    
    return (
        <>{children}</>
    )
}

export default WithToken