File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change
1
+ import React from "react" ;
2
+ import { useSelector , useDispatch } from "react-redux" ;
3
+ import { Route , Redirect } from "react-router-dom" ;
4
+ import CreateOrganization from "../../pages/createOrganization/createOrganization" ;
5
+ import { getOrg } from "../../reducers/orgSlice" ;
6
+ function OrganizationSetupRoute ( ) {
7
+ const dispatch = useDispatch ( ) ;
8
+ const orgExists = useSelector ( state => state . org . get . org ) ;
9
+ if ( Object . keys ( orgExists ) . length == 0 ) {
10
+ dispatch ( getOrg ( ) ) ;
11
+ return null ;
12
+ }
13
+ return (
14
+ < Route
15
+ render = { ( ) =>
16
+ orgExists . exists ? < Redirect to = "/" /> : < CreateOrganization />
17
+ }
18
+ />
19
+ ) ;
20
+ }
21
+
22
+ export default OrganizationSetupRoute ;
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ export const getOrg = createAsyncThunk(
61
61
isArchived
62
62
isUnderMaintenance
63
63
totalUsers
64
+ exists
64
65
}}` ,
65
66
} ,
66
67
{
Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
import { BrowserRouter , Route , Switch } from "react-router-dom" ;
3
- import Dashboard from "./pages/dashboard/dashboard"
4
- import CreateOrganization from "./pages/createOrganization/createOrganization " ;
3
+ import Dashboard from "./pages/dashboard/dashboard" ;
4
+ import OrganizationSetupRoute from "./components/common/organizationSetupRoute " ;
5
5
6
6
const Router = ( ) => (
7
7
< BrowserRouter >
8
8
< Switch >
9
9
< Route exact path = "/" component = { Dashboard } />
10
- < Route path = "/setup" component = { CreateOrganization } />
10
+ < OrganizationSetupRoute path = "/setup" />
11
11
</ Switch >
12
12
</ BrowserRouter >
13
13
) ;
You can’t perform that action at this time.
0 commit comments