Router.js 890 Bytes
import React from "react";
import PropTypes from "prop-types";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import Auth from "./Auth/AuthContainer";
import Home from "../Components/Home";
import OTOChat from "./OTOChat/OTOChatContainer";

const LoggedInRoutes = () => (
  <>
    <Route path="/Home" component={Home} />
    <Route path="/OTOChat" component={OTOChat} />
    <Route path="/RandomChat" component={Home} />
    <Route path="/CategoryChat" component={Home} />
    <Route path="/Profile" component={Home} />
  </>
);

const LoggedOutRoutes = () => (
  <>
    <Route exact path="/" component={Auth} />
  </>
);

const AppRouter = ({ isLoggedIn }) => (
  <Router>
    <Switch>{isLoggedIn ? <LoggedInRoutes /> : <LoggedOutRoutes />}</Switch>
  </Router>
);

AppRouter.propTypes = {
  isLoggedIn: PropTypes.bool.isRequired,
};

export default AppRouter;