import React from "react";
import { useApp, useAuth } from "../hooks";
import PrivateRouter from "./PrivateRouter";
import PublicRouter from "./PublicRouter";
import { TIPO_PROJECTO_FIREBASE } from "../constants"
const { REACT_APP_PROJECT: tipoProyecto } = process.env;
const AppRouting = () => {
  const { session, sessionLoading } = useAuth();
  const { token } = useApp();
  
  const user = tipoProyecto === TIPO_PROJECTO_FIREBASE ? session : token;

  if (sessionLoading) return null;

  return (
    <>
      {user ? <PrivateRouter /> : <PublicRouter />}
    </>
  );
};

export default AppRouting;