2023-08-09 15:41:41 -04:00
|
|
|
import Loading from './components/Loading'
|
2023-08-29 10:48:55 -04:00
|
|
|
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
2023-07-13 07:22:08 -04:00
|
|
|
|
2023-07-27 18:59:40 -04:00
|
|
|
// Wrapper around protected routes, used in src/Router.tsx
|
|
|
|
export const Auth = ({ children }: React.PropsWithChildren) => {
|
2023-08-29 10:48:55 -04:00
|
|
|
const {
|
|
|
|
auth: { state },
|
|
|
|
} = useGlobalStateContext()
|
2023-09-19 14:08:26 -04:00
|
|
|
const isLoggingIn = state.matches('checkIfLoggedIn')
|
2023-07-11 20:34:09 +10:00
|
|
|
|
2023-09-19 14:08:26 -04:00
|
|
|
return isLoggingIn ? (
|
2023-08-10 16:22:45 -04:00
|
|
|
<Loading>Loading KittyCAD Modeling App...</Loading>
|
|
|
|
) : (
|
|
|
|
<>{children}</>
|
|
|
|
)
|
2023-03-06 18:18:01 +11:00
|
|
|
}
|