import { Navigate } from 'react-router-dom'
import Cookies from "js-cookie";
import { ACCESS_TOKEN, REFRESH_TOKEN } from '@/lib/data';


type Props = {
  children: React.ReactNode
}

const ProtectedRoute: React.FC<Props> = ({ children }) => {

  const access_token = Cookies.get(ACCESS_TOKEN);
  const refresh_token = Cookies.get(REFRESH_TOKEN)

  if (!access_token || ! refresh_token) return <Navigate to="/" replace />
  return <>{children}</>
}

export default ProtectedRoute
