import type { ReactNode } from "react";
import { Navigate } from "react-router-dom";

type Props = {
    children: ReactNode;
};

function ProtectedRoute({ children }: Props) {
    const token = localStorage.getItem("token-robot-tracker");

    if (!token || token === "undefined" || token === "null") {
        return <Navigate to="/login" replace />;
    }

    return children;
}

export default ProtectedRoute;
