diff --git a/002_source/ionic_mobile/src/pages/auth/Home/index.tsx b/002_source/ionic_mobile/src/pages/auth/Home/index.tsx index 7cca67d..70c0173 100644 --- a/002_source/ionic_mobile/src/pages/auth/Home/index.tsx +++ b/002_source/ionic_mobile/src/pages/auth/Home/index.tsx @@ -11,15 +11,39 @@ import { IonRouterLink, IonRow, IonToolbar, + useIonRouter, } from '@ionic/react'; // import { Action } from '../components/Action'; import styles from './style.module.scss'; import { Action } from '../../../components/Action'; import { Paths } from '../../../Paths'; import { useTranslation } from 'react-i18next'; +import { useEffect, useState } from 'react'; +import { useUser } from '../../../hooks/use-user'; const AuthHome = () => { const { t } = useTranslation(); + const { user } = useUser(); + const router = useIonRouter(); + + const [showLoading, setShowLoading] = useState(true); + const [showError, setShowErrr] = useState<{ show: boolean; message: string }>({ + show: false, + message: '', + }); + + useEffect(() => { + if (!user) { + } else { + if (user?.id) { + router.push(Paths.AuthorizedTest); + } + } + setShowLoading(false); + }, []); + + if (showLoading) return <>loading; + if (showError) return <>{showError.message}; return (