Files
FBSAdminTool/src/containers/TheContent.js

67 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-07-12 09:41:26 +05:30
import React, { Suspense } from 'react'
2021-07-29 12:44:10 +05:30
import Cookies from 'js-cookie';
2021-07-12 09:41:26 +05:30
import {
Redirect,
Route,
Switch
} from 'react-router-dom'
import { CContainer, CFade } from '@coreui/react'
// routes config
import routes from '../routes'
2021-07-28 17:28:25 +05:30
2021-07-12 09:41:26 +05:30
const loading = (
<div className="pt-3 text-center">
<div className="sk-spinner sk-spinner-pulse"></div>
</div>
)
const TheContent = () => {
2021-07-28 17:28:25 +05:30
function get_token_from_storage_or_cookie() {
2021-07-29 13:33:16 +05:30
const shib = Cookies.get()
2021-07-28 17:28:25 +05:30
console.log(shib);
2021-07-29 12:33:04 +05:30
return shib;
2021-07-28 17:28:25 +05:30
}
2021-07-12 09:41:26 +05:30
return (
<main className="c-main">
<CContainer fluid>
<Suspense fallback={loading}>
<Switch>
{routes.map((route, idx) => {
return route.component && (
<Route
key={idx}
path={route.path}
exact={route.exact}
name={route.name}
2021-07-28 17:28:25 +05:30
render={props =>
get_token_from_storage_or_cookie("tokenName") !== null
? (
2021-07-12 09:41:26 +05:30
<route.component {...props} />
2021-07-28 17:28:25 +05:30
) : (
<Redirect to={{ pathname: "/sso" }} />
)
}
// render={props => (
// <CFade>
// <route.component {...props} />
// </CFade>
// )}
/>
2021-07-12 09:41:26 +05:30
)
})}
<Redirect from="/" to="/dashboard" />
</Switch>
</Suspense>
</CContainer>
</main>
)
}
export default React.memo(TheContent)