Router.js 1009 Bytes
import React from "react";
import PropTypes from "prop-types";
import { Route, Switch } from "react-router-dom";
import Auth from "./Auth/AuthContainer";
import About from "./About";
import RoomList from "./Room/RoomContainer";
import Main from "./MainPresenter";
import Forum from "./Forum/ForumPresenter";
import Features from "./Features";
import News from "./News";

const LoggedInRoutes = () => (
  <Switch>
    <Route path="/roomlist" component={RoomList} />
  </Switch>
);

const LoggedOutRoutes = () => (
  <Switch>
    <Route exact path="/" component={Main} />
    <Route path="/about" component={About} />
    <Route path="/auth" component={Auth} />
    <Route path="/forum" component={Forum} />
    <Route path="/features" component={Features} />
    <Route path="/news" component={News} />
  </Switch>
);

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

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

export default AppRouter;