1
- import React , { useState , useEffect } from 'react'
2
- import { BrowserRouter as Router , Route , Redirect } from " react-router-dom" ;
1
+ import React , { useState , useEffect } from 'react' ;
2
+ import { BrowserRouter as Router , Route , Redirect } from ' react-router-dom' ;
3
3
import { createBrowserHistory } from 'history' ;
4
4
5
5
import Room from './Components/Room/Room' ;
@@ -9,60 +9,87 @@ import JoinRoom from './Components/Room/JoinRoom';
9
9
import CreateRoom from './Components/Room/CreateRoom' ;
10
10
import FrontPage from './Components/FrontPage/FrontPage' ;
11
11
import LoginPage from './Components/Auth/Login/LoginPage' ;
12
+ import ForgotPassword from './Components/Auth/ForgotPassword/ForgotPassword' ;
13
+ import ResetPassword from './Components/Auth/ResetPassword/ResetPassword' ;
12
14
import Register from './Components/Auth/Register/Register' ;
13
15
import Cookies from 'universal-cookie' ;
14
- import ProtectedRoute from './Protected'
16
+ import ProtectedRoute from './Protected' ;
15
17
import Trial from './Components/trial/trial' ;
16
18
import ReactGA from 'react-ga' ;
17
- import TeamPage from './Components/Team Page/TeamPage'
19
+ import TeamPage from './Components/Team Page/TeamPage' ;
18
20
import NotFound from './Components/NotFound/NotFound' ;
19
- import { Helmet } from " react-helmet" ;
20
- import { useMediaQuery } from 'react-responsive'
21
+ import { Helmet } from ' react-helmet' ;
22
+ import { useMediaQuery } from 'react-responsive' ;
21
23
import Mobile from './Components/Mobile/Mobile' ;
22
24
const cookies = new Cookies ( ) ;
23
25
const history = createBrowserHistory ( ) ;
24
26
25
- const isAuthenticated = JSON . parse ( localStorage . getItem ( 'authUser' ) ) ?. token
27
+ const isAuthenticated = JSON . parse ( localStorage . getItem ( 'authUser' ) ) ?. token ;
26
28
function App ( ) {
27
29
// useEffect(() => {
28
30
// console.log({ authroot: isAuthenticated });
29
31
// }, [isAuthenticated])
30
32
useEffect ( ( ) => {
31
33
ReactGA . initialize ( 'UA-213485416-1' ) ;
32
34
ReactGA . pageview ( window . location . pathname + window . location . search ) ;
33
- } , [ ] )
35
+ } , [ ] ) ;
34
36
35
- const [ loginUser , setLoginUser ] = useState ( null )
37
+ const [ loginUser , setLoginUser ] = useState ( null ) ;
36
38
const isDesktopOrLaptop = useMediaQuery ( {
37
- query : '(min-width: 1224px)'
38
- } )
39
- const isBigScreen = useMediaQuery ( { query : '(min-width: 1200px)' } )
40
-
41
-
42
-
43
- console . log ( { isBigScreen} )
39
+ query : '(min-width: 1224px)' ,
40
+ } ) ;
41
+ const isBigScreen = useMediaQuery ( { query : '(min-width: 1200px)' } ) ;
44
42
43
+ console . log ( { isBigScreen } ) ;
45
44
46
45
return (
47
46
< >
48
- < Helmet >
47
+ < Helmet >
49
48
< title > CodeSync</ title >
50
- < meta name = "description" content = "Cloud collaborative tool for student , Teachers and Professional with real time code editor or IDE, Realtime drawing board , Real time chat app " />
49
+ < meta
50
+ name = 'description'
51
+ content = 'Cloud collaborative tool for student , Teachers and Professional with real time code editor or IDE, Realtime drawing board , Real time chat app '
52
+ />
51
53
</ Helmet >
52
- { isBigScreen == true ? < Router history = { history } >
53
- < Route path = "/" component = { FrontPage } exact />
54
- < Route path = "/login" render = { ( props ) => < LoginPage { ...props } /> } exact />
55
- < Route path = "/register" component = { Register } exact />
56
- < ProtectedRoute path = '/room' component = { HomePage } exact />
57
- < Route path = '/room/:id' render = { ( props ) => ( isAuthenticated ? < Room { ...props } /> : < Redirect to = "/login" /> ) } exact />
58
- < ProtectedRoute path = '/joinRoom' render = { JoinRoom } exact />
59
- < Route path = '/newRoom' render = { ( props ) => isAuthenticated ? < CreateRoom { ...props } /> : < Redirect to = "/login" /> } exact />
60
- < Route path = '/editor' render = { Editor } exact />
61
- < Route path = '/trial' render = { ( props ) => < Trial { ...props } /> } exact />
62
- < Route path = "/team" component = { TeamPage } exact />
54
+ { isBigScreen == true ? (
55
+ < Router history = { history } >
56
+ < Route path = '/' component = { FrontPage } exact />
57
+ < Route path = '/forgot_password' exact component = { ForgotPassword } />
58
+ < Route path = '/_reset_password/:id' exact component = { ResetPassword } />
63
59
64
- </ Router > : < Mobile /> }
65
-
60
+ < Route
61
+ path = '/login'
62
+ render = { ( props ) => < LoginPage { ...props } /> }
63
+ exact
64
+ />
65
+ < Route path = '/register' component = { Register } exact />
66
+ < ProtectedRoute path = '/room' component = { HomePage } exact />
67
+ < Route
68
+ path = '/room/:id'
69
+ render = { ( props ) =>
70
+ isAuthenticated ? < Room { ...props } /> : < Redirect to = '/login' />
71
+ }
72
+ exact
73
+ />
74
+ < ProtectedRoute path = '/joinRoom' render = { JoinRoom } exact />
75
+ < Route
76
+ path = '/newRoom'
77
+ render = { ( props ) =>
78
+ isAuthenticated ? (
79
+ < CreateRoom { ...props } />
80
+ ) : (
81
+ < Redirect to = '/login' />
82
+ )
83
+ }
84
+ exact
85
+ />
86
+ < Route path = '/editor' render = { Editor } exact />
87
+ < Route path = '/trial' render = { ( props ) => < Trial { ...props } /> } exact />
88
+ < Route path = '/team' component = { TeamPage } exact />
89
+ </ Router >
90
+ ) : (
91
+ < Mobile />
92
+ ) }
66
93
</ >
67
94
) ;
68
95
}
0 commit comments