import { Navigate, Outlet } from 'react-router-dom'

import { useAuthStore } from '@/stores/auth-store'

export const GuestOnly = () => {
  const hasSession = useAuthStore((state) => Boolean(state.tokens))

  if (hasSession) {
    return <Navigate to="/dashboard" replace />
  }

  return <Outlet />
}
