import { PropsWithChildren, useEffect } from "react"
import { useNavigate } from "react-router-dom"

export const Guard = ({ children }: PropsWithChildren) => {
    const navigate = useNavigate()
    const token = window.localStorage.getItem("token")

    useEffect(() => {
        if (!token || token?.length <= 0 || token === undefined || token === null) {
            navigate("/auth/login")
        }
    }, [token , navigate])

    return (
        <>
            {children}
        </>
    )
}