|
| 1 | +import { useContext } from 'react'; |
| 2 | +import { useNavigate } from 'react-router-dom'; |
| 3 | + |
| 4 | +import StaticPageLayout from '@/Layout/StaticPageLayout'; |
| 5 | +import PageContext from '@/Providers/PageContextProvider/PageContext'; |
| 6 | +import Button from '@/components/Button'; |
| 7 | +import DynamicT from '@/components/DynamicT'; |
| 8 | +import NavBar from '@/components/NavBar'; |
| 9 | +import PageMeta from '@/components/PageMeta'; |
| 10 | +import { getBrandingLogoUrl } from '@/utils/logo'; |
| 11 | + |
| 12 | +import SupportInfo from '../ErrorPage/SupportInfo'; |
| 13 | + |
| 14 | +import styles from './index.module.scss'; |
| 15 | + |
| 16 | +type Props = { |
| 17 | + readonly account?: string; |
| 18 | +}; |
| 19 | + |
| 20 | +const SwitchAccount = ({ account }: Props) => { |
| 21 | + const navigate = useNavigate(); |
| 22 | + const { experienceSettings, theme } = useContext(PageContext); |
| 23 | + const searchParams = new URLSearchParams(window.location.search); |
| 24 | + const currentAccountName = searchParams.get('account') ?? account; |
| 25 | + |
| 26 | + if (!experienceSettings) { |
| 27 | + return null; |
| 28 | + } |
| 29 | + |
| 30 | + const { |
| 31 | + color: { isDarkModeEnabled }, |
| 32 | + branding, |
| 33 | + } = experienceSettings; |
| 34 | + const logoUrl = getBrandingLogoUrl({ theme, branding, isDarkModeEnabled }); |
| 35 | + |
| 36 | + return ( |
| 37 | + <StaticPageLayout> |
| 38 | + <PageMeta titleKey="description.switch_account" /> |
| 39 | + {history.length > 1 && <NavBar />} |
| 40 | + <div className={styles.container}> |
| 41 | + {logoUrl && <img className={styles.logo} src={logoUrl} alt="app logo" />} |
| 42 | + <div className={styles.title}> |
| 43 | + <DynamicT |
| 44 | + forKey="description.account_mismatch_title" |
| 45 | + interpolation={{ account: currentAccountName }} |
| 46 | + /> |
| 47 | + </div> |
| 48 | + <div className={styles.message}> |
| 49 | + <DynamicT forKey="description.account_mismatch_description" /> |
| 50 | + </div> |
| 51 | + <SupportInfo /> |
| 52 | + <Button |
| 53 | + className={styles.button} |
| 54 | + type="primary" |
| 55 | + size="large" |
| 56 | + title="description.switch_account" |
| 57 | + onClick={() => { |
| 58 | + navigate('/sign-in'); |
| 59 | + }} |
| 60 | + /> |
| 61 | + </div> |
| 62 | + </StaticPageLayout> |
| 63 | + ); |
| 64 | +}; |
| 65 | + |
| 66 | +export default SwitchAccount; |
0 commit comments