2023-08-09 15:41:41 -04:00
|
|
|
import Loading from './components/Loading'
|
2023-08-22 05:34:20 +10:00
|
|
|
import { useAuthMachine } from './hooks/useAuthMachine'
|
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-22 05:34:20 +10:00
|
|
|
const [isLoggedIn] = useAuthMachine((s) => s.matches('checkIfLoggedIn'))
|
2023-07-11 20:34:09 +10:00
|
|
|
|
2023-08-22 05:34:20 +10:00
|
|
|
return isLoggedIn ? (
|
2023-08-10 16:22:45 -04:00
|
|
|
<Loading>Loading KittyCAD Modeling App...</Loading>
|
|
|
|
) : (
|
|
|
|
<>{children}</>
|
|
|
|
)
|
2023-03-06 18:18:01 +11:00
|
|
|
}
|