sdy

update routes

1 import React from "react"; 1 import React from "react";
2 import PropTypes from "prop-types"; 2 import PropTypes from "prop-types";
3 -import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; 3 +import { Route, Switch, Redirect } from "react-router-dom";
4 import Auth from "./Auth/AuthContainer"; 4 import Auth from "./Auth/AuthContainer";
5 import RoomList from "./Room/RoomContainer"; 5 import RoomList from "./Room/RoomContainer";
6 import Home from "../Components/Home"; 6 import Home from "../Components/Home";
7 -import OTOChat from "./OTOChat/OTOChatContainer";
8 7
9 const LoggedInRoutes = () => ( 8 const LoggedInRoutes = () => (
10 - <> 9 + <Switch>
11 <Route exact path="/" component={RoomList} /> 10 <Route exact path="/" component={RoomList} />
12 <Route path="/:roomname" component={Home} /> 11 <Route path="/:roomname" component={Home} />
13 - <Route path="/OTOChat" component={OTOChat} /> 12 + <Redirect from="*" to="/" />
14 - <Route path="/RandomChat" component={Home} /> 13 + </Switch>
15 - <Route path="/CategoryChat" component={Home} />
16 - <Route path="/Profile" component={Home} />
17 - </>
18 ); 14 );
19 15
20 const LoggedOutRoutes = () => ( 16 const LoggedOutRoutes = () => (
21 - <> 17 + <Switch>
22 <Route exact path="/" component={Auth} /> 18 <Route exact path="/" component={Auth} />
23 - </> 19 + <Redirect from="*" to="/" />
20 + </Switch>
24 ); 21 );
25 22
26 -const AppRouter = ({ isLoggedIn }) => ( 23 +const AppRouter = ({ isLoggedIn }) =>
27 - <Router> 24 + isLoggedIn ? <LoggedInRoutes /> : <LoggedOutRoutes />;
28 - <Switch>{isLoggedIn ? <LoggedInRoutes /> : <LoggedOutRoutes />}</Switch>
29 - </Router>
30 -);
31 25
32 AppRouter.propTypes = { 26 AppRouter.propTypes = {
33 isLoggedIn: PropTypes.bool.isRequired, 27 isLoggedIn: PropTypes.bool.isRequired,
......