|
| 1 | +import React, { useRef } from 'react' |
| 2 | +import { useSelector } from 'react-redux' |
| 3 | +import { Button } from '@mui/material' |
| 4 | +import { P, H2 } from '@mxenabled/mxui' |
| 5 | +import { Icon } from '@mxenabled/mxui' |
| 6 | + |
| 7 | +import { __ } from 'src/utilities/Intl' |
| 8 | +import { InstitutionLogo } from '@mxenabled/mxui' |
| 9 | +import { SlideDown } from 'src/components/SlideDown' |
| 10 | +import { getSelectedInstitution } from 'src/redux/selectors/Connect' |
| 11 | + |
| 12 | +interface DemoConnectGuardProps { |
| 13 | + onReturnToSearch: () => void |
| 14 | +} |
| 15 | + |
| 16 | +export const DemoConnectGuard: React.FC<DemoConnectGuardProps> = ({ onReturnToSearch }) => { |
| 17 | + const institution = useSelector(getSelectedInstitution) |
| 18 | + const containerRef = useRef(null) |
| 19 | + const styles = getStyles() |
| 20 | + |
| 21 | + return ( |
| 22 | + <div ref={containerRef} style={styles.container}> |
| 23 | + <SlideDown> |
| 24 | + <div style={styles.logoContainer}> |
| 25 | + <InstitutionLogo |
| 26 | + alt={__('Logo for %1', institution.name)} |
| 27 | + aria-hidden={true} |
| 28 | + institutionGuid={institution.guid} |
| 29 | + logoUrl={institution.logo_url} |
| 30 | + size={64} |
| 31 | + /> |
| 32 | + <Icon color="error" fill={true} name="error" size={32} sx={styles.icon} /> |
| 33 | + </div> |
| 34 | + <H2 sx={styles.title} truncate={false}> |
| 35 | + {__('Demo mode active')} |
| 36 | + </H2> |
| 37 | + <P sx={styles.body} truncate={false}> |
| 38 | + {__( |
| 39 | + 'Live institutions are not available in the demo environment. Please select MX Bank to test the connection process.', |
| 40 | + )} |
| 41 | + </P> |
| 42 | + <Button |
| 43 | + data-test="done-button" |
| 44 | + fullWidth={true} |
| 45 | + onClick={onReturnToSearch} |
| 46 | + variant="contained" |
| 47 | + > |
| 48 | + {__('Return to institution selection')} |
| 49 | + </Button> |
| 50 | + </SlideDown> |
| 51 | + </div> |
| 52 | + ) |
| 53 | +} |
| 54 | + |
| 55 | +const getStyles = () => ({ |
| 56 | + container: { |
| 57 | + display: 'flex', |
| 58 | + flexDirection: 'column', |
| 59 | + alignItems: 'center', |
| 60 | + justifyContent: 'center', |
| 61 | + textAlign: 'center', |
| 62 | + paddingTop: 20, |
| 63 | + } as React.CSSProperties, |
| 64 | + logoContainer: { |
| 65 | + position: 'relative', |
| 66 | + display: 'inline-block', |
| 67 | + } as React.CSSProperties, |
| 68 | + icon: { |
| 69 | + position: 'absolute', |
| 70 | + top: '-16px', |
| 71 | + right: '-16px', |
| 72 | + background: 'white', |
| 73 | + borderRadius: '50%', |
| 74 | + }, |
| 75 | + title: { |
| 76 | + marginBottom: '4px', |
| 77 | + marginTop: '32px', |
| 78 | + fontSize: '23px', |
| 79 | + fontWeight: 700, |
| 80 | + lineHeight: '32px', |
| 81 | + textAlign: 'center', |
| 82 | + }, |
| 83 | + body: { |
| 84 | + textAlign: 'center', |
| 85 | + marginBottom: '32px', |
| 86 | + fontSize: '15px', |
| 87 | + fontWeight: 400, |
| 88 | + lineHeight: '24px', |
| 89 | + } as React.CSSProperties, |
| 90 | +}) |
0 commit comments