You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
905 B
39 lines
905 B
import React, { Component } from 'react'; |
|
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; |
|
import store from "./Redux/store"; |
|
import { Provider } from "react-redux"; |
|
|
|
import Home from "./views/Home/Home"; |
|
import ChatRoom from "./views/ChatRoom/ChatRoom"; |
|
import Auth from "./views/Auth/Auth"; |
|
|
|
|
|
export default class AppRouter extends Component { |
|
render() { |
|
let home; |
|
if(!localStorage.getItem("access_token")){ |
|
home = <Route exact path={'/'}> |
|
<Home /> |
|
</Route> |
|
}else{ |
|
home = <Route exact path={'/'}> |
|
<Auth /> |
|
</Route> |
|
} |
|
return ( |
|
<Provider store={store} > |
|
<Router> |
|
<Switch> |
|
{home} |
|
</Switch> |
|
<Route exact path={`/chatroom/:id`}> |
|
<ChatRoom /> |
|
</Route> |
|
<Route exact path={'/auth'}> |
|
<Auth /> |
|
</Route> |
|
</Router> |
|
</Provider> |
|
) |
|
} |
|
} |