Files
modeling-app/src/Auth.tsx
Frank Noirot b0426e3f94 Refactor: separate authMachine from React (#5110)
* Create a global appMachine

* Strip authMachine of side-effects

* Replace react-bound authMachine use with XState actor use

* Fix import goof

* Register auth commands directly!

* @lf94 feedback: conver `AuthNavigationHandler` to `useAuthNavigation`

* Uh, fix signing out thank you @lf94

* Fix tsc

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)"

This reverts commit 8dc50b6a26.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-01-31 14:47:08 -05:00

17 lines
472 B
TypeScript

import { useAuthState } from 'machines/appMachine'
import Loading from './components/Loading'
// Wrapper around protected routes, used in src/Router.tsx
export const Auth = ({ children }: React.PropsWithChildren) => {
const authState = useAuthState()
const isLoggingIn = authState.matches('checkIfLoggedIn')
return isLoggingIn ? (
<Loading>
<span data-testid="initial-load">Loading Modeling App...</span>
</Loading>
) : (
<>{children}</>
)
}