|
| 1 | +import { IonContent, IonPage } from '@ionic/react'; |
| 2 | +import { useEffect } from 'react'; |
| 3 | +import { useIonRouter } from '@ionic/react'; |
| 4 | +import { useTranslation } from 'react-i18next'; |
| 5 | + |
| 6 | +import './SplashPage.scss'; |
| 7 | +import splashBg from '../../../../src/assets/Splash.png'; |
| 8 | +import { PropsWithTestId } from 'common/components/types'; |
| 9 | + |
| 10 | +/** |
| 11 | + * Properties for the `SplashPage` component. |
| 12 | + */ |
| 13 | +interface SplashPageProps extends PropsWithTestId {} |
| 14 | + |
| 15 | +/** |
| 16 | + * The `SplashPage` renders the initial splash screen with the app logo. |
| 17 | + * It automatically redirects to the login page after a short delay. |
| 18 | + * |
| 19 | + * @param {SplashPageProps} props - Component properties. |
| 20 | + * @returns {JSX.Element} JSX |
| 21 | + */ |
| 22 | +const SplashPage = ({ testid = 'page-splash' }: SplashPageProps): JSX.Element => { |
| 23 | + const router = useIonRouter(); |
| 24 | + const { t } = useTranslation(); |
| 25 | + |
| 26 | + useEffect(() => { |
| 27 | + // Redirect to login page after a delay |
| 28 | + const timer = setTimeout(() => { |
| 29 | + router.push('/auth/signin', 'forward', 'replace'); |
| 30 | + }, 2000); |
| 31 | + |
| 32 | + return () => clearTimeout(timer); |
| 33 | + }, [router]); |
| 34 | + |
| 35 | + return ( |
| 36 | + <IonPage className="ls-splash-page" data-testid={testid}> |
| 37 | + <IonContent fullscreen className="ion-no-padding"> |
| 38 | + <div className="ls-splash-page__container"> |
| 39 | + <img |
| 40 | + src={splashBg} |
| 41 | + alt={t('splash.background-alt', { ns: 'common' })} |
| 42 | + className="ls-splash-page__background" |
| 43 | + /> |
| 44 | + <div className="ls-splash-page__logo-container"></div> |
| 45 | + </div> |
| 46 | + </IonContent> |
| 47 | + </IonPage> |
| 48 | + ); |
| 49 | +}; |
| 50 | + |
| 51 | +export default SplashPage; |
0 commit comments