Router.js 953 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 ChannelList from "./Channel/ChannelContainer";
import Home from "../Components/Home";
import OTOChat from "./OTOChat/OTOChatContainer";

const LoggedInRoutes = () => (
  <>
    <Route exact path="/" component={ChannelList} />
    <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;