Skip to content

Commit 646d6d9

Browse files
author
Clement Mwimo
committed
feat: adds a new demo connect guard screen
1 parent 2604de3 commit 646d6d9

5 files changed

Lines changed: 101 additions & 0 deletions

File tree

src/components/RenderConnectStep.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { Microdeposits } from 'src/views/microdeposits/Microdeposits'
3434
import VerifyExistingMember from 'src/views/verification/VerifyExistingMember'
3535
import { VerifyError } from 'src/views/verification/VerifyError'
3636
import { ManualAccountConnect } from 'src/views/manualAccount/ManualAccountConnect'
37+
import { DemoConnectGuard } from 'src/views/demoConnectGuard/DemoConnectGuard'
3738
import AdditionalProductStep, {
3839
ADDITIONAL_PRODUCT_OPTIONS,
3940
} from 'src/views/additionalProduct/AdditionalProductStep'
@@ -110,6 +111,10 @@ const RenderConnectStep = (props) => {
110111
throw new Error('invalid product offer')
111112

112113
connectStepView = <AdditionalProductStep ref={props.navigationRef} />
114+
} else if (step === STEPS.DEMO_CONNECT_GUARD) {
115+
connectStepView = (
116+
<DemoConnectGuard institution={selectedInstitution} ref={props.navigationRef} />
117+
)
113118
} else if (step === STEPS.ADD_MANUAL_ACCOUNT) {
114119
connectStepView = (
115120
<ManualAccountConnect

src/const/Connect.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const STEPS = {
1111
CONNECTING: 'connecting',
1212
CONSENT: 'consent',
1313
DELETE_MEMBER_SUCCESS: 'deleteMemberSuccess',
14+
DEMO_CONNECT_GUARD: 'demoConnectGuard',
1415
DISCLOSURE: 'disclosure',
1516
ENTER_CREDENTIALS: 'enterCreds',
1617
EXISTING_MEMBER: 'existingMember',

src/hooks/useSelectInstitution.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const useSelectInstitution = () => {
1818
const dispatch = useDispatch()
1919
const consentIsEnabled = useSelector((state: RootState) => isConsentEnabled(state))
2020
const connectConfig = useSelector(selectConnectConfig)
21+
const user = useSelector((state: RootState) => state.profiles.user)
2122

2223
const handleSelectInstitution = useCallback(
2324
(institution: InstitutionResponseType) => {
@@ -42,6 +43,7 @@ const useSelectInstitution = () => {
4243
institutionStatus,
4344
consentIsEnabled: consentIsEnabled || false,
4445
additionalProductOption: connectConfig?.additional_product_option || null,
46+
user,
4547
},
4648
})
4749
}),

src/redux/reducers/Connect.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ const selectInstitutionSuccess = (state, action) => {
278278
// 2. Additional product - if the client is offering a product AND the institution has support for the product
279279
// 3. Consent - if the Client has enabled consent
280280
// 4. Institution disabled - if the institution is disabled by the client
281+
// 5. Demo connect guard - if the user is a demo user but the institution is not a demo institution
281282
let nextStep = STEPS.ENTER_CREDENTIALS
282283

283284
const canOfferVerification =
@@ -292,6 +293,8 @@ const selectInstitutionSuccess = (state, action) => {
292293
action.payload.institutionStatus === InstitutionStatus.UNAVAILABLE)
293294
) {
294295
nextStep = STEPS.INSTITUTION_STATUS_DETAILS
296+
} else if (action.payload.user?.is_demo && !action.payload.institution?.is_demo) {
297+
nextStep = STEPS.DEMO_CONNECT_GUARD
295298
} else if (canOfferVerification || canOfferAggregation) {
296299
nextStep = STEPS.ADDITIONAL_PRODUCT
297300
} else if (action.payload.consentIsEnabled) {
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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

Comments
 (0)