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