saafe-redirection-flow 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build-and-deploy.yml +41 -0
- package/.gitlab-ci.yml +108 -0
- package/.releaserc.json +18 -0
- package/.storybook/main.ts +28 -0
- package/.storybook/preview.ts +16 -0
- package/.storybook/vitest.setup.ts +9 -0
- package/.vite/deps/@radix-ui_react-avatar.js +230 -0
- package/.vite/deps/@radix-ui_react-avatar.js.map +7 -0
- package/.vite/deps/@radix-ui_react-slot.js +12 -0
- package/.vite/deps/@radix-ui_react-slot.js.map +7 -0
- package/.vite/deps/_metadata.json +79 -0
- package/.vite/deps/chunk-5VGQBUCU.js +597 -0
- package/.vite/deps/chunk-5VGQBUCU.js.map +7 -0
- package/.vite/deps/chunk-DC5AMYBS.js +38 -0
- package/.vite/deps/chunk-DC5AMYBS.js.map +7 -0
- package/.vite/deps/chunk-HUIEPYH7.js +11265 -0
- package/.vite/deps/chunk-HUIEPYH7.js.map +7 -0
- package/.vite/deps/chunk-TKHB4QMX.js +281 -0
- package/.vite/deps/chunk-TKHB4QMX.js.map +7 -0
- package/.vite/deps/chunk-YLDSBLSF.js +1139 -0
- package/.vite/deps/chunk-YLDSBLSF.js.map +7 -0
- package/.vite/deps/class-variance-authority.js +63 -0
- package/.vite/deps/class-variance-authority.js.map +7 -0
- package/.vite/deps/lucide-react.js +36984 -0
- package/.vite/deps/lucide-react.js.map +7 -0
- package/.vite/deps/package.json +3 -0
- package/.vite/deps/react-dom_client.js +17917 -0
- package/.vite/deps/react-dom_client.js.map +7 -0
- package/.vite/deps/react-router-dom.js +452 -0
- package/.vite/deps/react-router-dom.js.map +7 -0
- package/.vite/deps/react-router.js +234 -0
- package/.vite/deps/react-router.js.map +7 -0
- package/.vite/deps/react.js +5 -0
- package/.vite/deps/react.js.map +7 -0
- package/.vite/deps/react_jsx-dev-runtime.js +470 -0
- package/.vite/deps/react_jsx-dev-runtime.js.map +7 -0
- package/CHANGELOG.md +420 -0
- package/LICENSE +21 -0
- package/README.md +129 -0
- package/RELEASE_CHEATSHEET.md +93 -0
- package/RELEASE_NOTES.md +120 -0
- package/components.json +21 -0
- package/docs/DEPLOYMENT_WORKFLOW.md +262 -0
- package/docs/RELEASE_GUIDE.md +591 -0
- package/docs/architecture.md +432 -0
- package/docs/components.md +199 -0
- package/docs/index.md +69 -0
- package/docs/local-release-workflow.md +234 -0
- package/docs/routes.md +118 -0
- package/docs/sdk-integration.md +325 -0
- package/docs/semantic-release.md +124 -0
- package/docs/user-flow.md +206 -0
- package/eslint.config.js +28 -0
- package/index.html +19 -0
- package/install.sh +198 -0
- package/package.json +115 -0
- package/public/images/bank-logo.png +0 -0
- package/public/saafe-icon.svg +9 -0
- package/src/App.tsx +171 -0
- package/src/__tests__/url-parameters.test.ts +82 -0
- package/src/assets/brand/applestore.svg +13 -0
- package/src/assets/brand/playstore.svg +23 -0
- package/src/assets/brand/saafe-color-white-logo.svg +14 -0
- package/src/assets/brand/saafe-icon.svg +9 -0
- package/src/assets/brand/saafe-logo.svg +18 -0
- package/src/assets/icons/check-icon-dark.svg +27 -0
- package/src/assets/icons/check-icon.svg +23 -0
- package/src/components/ErrorBoundary.tsx +132 -0
- package/src/components/alert/alert.tsx +27 -0
- package/src/components/auth/AuthGuard.tsx +76 -0
- package/src/components/cards/BankCard.stories.tsx +69 -0
- package/src/components/cards/BankCard.tsx +227 -0
- package/src/components/cards/OuterCard.tsx +109 -0
- package/src/components/cards/WrapperCard.tsx +64 -0
- package/src/components/documents/PrivacyContent.tsx +1 -0
- package/src/components/dummyFooter.tsx +29 -0
- package/src/components/icons/github.tsx +12 -0
- package/src/components/language/LanguageSwitcher.tsx +44 -0
- package/src/components/layouts/FrostedLayout.stories.tsx +42 -0
- package/src/components/layouts/FrostedLayout.tsx +333 -0
- package/src/components/layouts/MobileLayout.tsx +403 -0
- package/src/components/mobile-background.tsx +136 -0
- package/src/components/mobileAppDownload.tsx +30 -0
- package/src/components/modal/ModalComp.tsx +27 -0
- package/src/components/mode-toggle.tsx +36 -0
- package/src/components/page-header.tsx +50 -0
- package/src/components/session/SessionTimeoutScreen.tsx +134 -0
- package/src/components/session/SessionTimer.tsx +173 -0
- package/src/components/step-navigation.tsx +87 -0
- package/src/components/title/AppBar.stories.tsx +50 -0
- package/src/components/title/AppBar.tsx +150 -0
- package/src/components/title/SectionTitle.tsx +31 -0
- package/src/components/ui/AnimatedButton.module.css +13 -0
- package/src/components/ui/alert.tsx +66 -0
- package/src/components/ui/animatedButton.tsx +111 -0
- package/src/components/ui/avatar.tsx +51 -0
- package/src/components/ui/badge.tsx +36 -0
- package/src/components/ui/bottom-sheet.tsx +122 -0
- package/src/components/ui/button.tsx +59 -0
- package/src/components/ui/calendar.tsx +86 -0
- package/src/components/ui/card.tsx +92 -0
- package/src/components/ui/checkbox.stories.tsx +49 -0
- package/src/components/ui/checkbox.tsx +67 -0
- package/src/components/ui/collapsible.tsx +45 -0
- package/src/components/ui/dialog.tsx +134 -0
- package/src/components/ui/document-link.tsx +26 -0
- package/src/components/ui/dot-stepper.tsx +57 -0
- package/src/components/ui/dropdown-menu.tsx +255 -0
- package/src/components/ui/form.tsx +165 -0
- package/src/components/ui/frosted-panel.stories.tsx +86 -0
- package/src/components/ui/frosted-panel.tsx +276 -0
- package/src/components/ui/input.tsx +39 -0
- package/src/components/ui/label.stories.tsx +67 -0
- package/src/components/ui/label.tsx +23 -0
- package/src/components/ui/mobile-footer.tsx +54 -0
- package/src/components/ui/modal.tsx +90 -0
- package/src/components/ui/otp-input.stories.tsx +62 -0
- package/src/components/ui/otp-input.tsx +221 -0
- package/src/components/ui/platform-specific-behavior.tsx +28 -0
- package/src/components/ui/popover.tsx +46 -0
- package/src/components/ui/progress.tsx +103 -0
- package/src/components/ui/radio-group.tsx +45 -0
- package/src/components/ui/scroll-area.tsx +56 -0
- package/src/components/ui/sdk-params-docs.tsx +53 -0
- package/src/components/ui/select.tsx +159 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/sheet.tsx +137 -0
- package/src/components/ui/sidebar.tsx +724 -0
- package/src/components/ui/skeleton.stories.tsx +50 -0
- package/src/components/ui/skeleton.tsx +15 -0
- package/src/components/ui/sonner.tsx +23 -0
- package/src/components/ui/step.stories.tsx +132 -0
- package/src/components/ui/step.tsx +234 -0
- package/src/components/ui/stepper-progress.tsx +136 -0
- package/src/components/ui/stepper.tsx +259 -0
- package/src/components/ui/tabs.tsx +55 -0
- package/src/components/ui/tooltip.tsx +61 -0
- package/src/components/ui/url-decode-loader.tsx +36 -0
- package/src/components/ui/version-display.tsx +104 -0
- package/src/components/ui/web-footer.tsx +36 -0
- package/src/config/environments.ts +99 -0
- package/src/config/urls.ts +53 -0
- package/src/const/fiTypeCategoryMap.ts +19 -0
- package/src/contexts/LanguageContext.tsx +41 -0
- package/src/contexts/RTLContext.tsx +42 -0
- package/src/contexts/ThemeContext.tsx +93 -0
- package/src/hooks/use-account-discovery.ts +205 -0
- package/src/hooks/use-auth-query.ts +141 -0
- package/src/hooks/use-fip-query.ts +72 -0
- package/src/hooks/use-media-query.ts +32 -0
- package/src/hooks/use-mobile.ts +24 -0
- package/src/hooks/use-page-title.tsx +48 -0
- package/src/hooks/use-platform.ts +52 -0
- package/src/hooks/use-trusted-count.ts +21 -0
- package/src/hooks/use-url-decode.ts +90 -0
- package/src/hooks/useStep.ts +170 -0
- package/src/index.css +154 -0
- package/src/interfaces/app.interfaces.ts +39 -0
- package/src/interfaces/services.interfaces.ts +65 -0
- package/src/lib/i18n.ts +68 -0
- package/src/lib/utils.ts +6 -0
- package/src/locales/en/common.json +167 -0
- package/src/locales/hi/common.json +137 -0
- package/src/locales/kn/common.json +137 -0
- package/src/locales/ml/common.json +137 -0
- package/src/locales/ta/common.json +137 -0
- package/src/locales/te/common.json +137 -0
- package/src/locales/ur/common.json +138 -0
- package/src/main.tsx +46 -0
- package/src/pages/Login.tsx +363 -0
- package/src/pages/accounts/AccountsToProceed.tsx +396 -0
- package/src/pages/accounts/Discover.tsx +76 -0
- package/src/pages/accounts/DiscoverAccount.tsx +751 -0
- package/src/pages/accounts/LinkSelectedAccounts.tsx +638 -0
- package/src/pages/accounts/OldUser.tsx +329 -0
- package/src/pages/accounts/link-accounts.tsx +913 -0
- package/src/pages/consent/ReviewConsent.tsx +836 -0
- package/src/pages/consent/rejected.tsx +253 -0
- package/src/pages/consent/success.tsx +220 -0
- package/src/providers/query-provider.tsx +24 -0
- package/src/providers/toast-provider.tsx +26 -0
- package/src/services/api/account.service.ts +296 -0
- package/src/services/api/auth.service.ts +206 -0
- package/src/services/api/axios.ts +138 -0
- package/src/services/api/consent.service.ts +142 -0
- package/src/services/api/decode.service.ts +53 -0
- package/src/services/api/feedback.service.ts +34 -0
- package/src/services/api/fip.service.ts +187 -0
- package/src/services/api/index.ts +9 -0
- package/src/services/api/public.service.ts +18 -0
- package/src/services/api.ts +2 -0
- package/src/services/postMessage.service.ts +179 -0
- package/src/store/NavigationBlockContext.tsx +34 -0
- package/src/store/auth.store.ts +79 -0
- package/src/store/fip.store.ts +396 -0
- package/src/store/mandatoryConsent.store.ts +24 -0
- package/src/store/redirect.store.ts +73 -0
- package/src/store/step.store.ts +124 -0
- package/src/stories/Button.stories.ts +53 -0
- package/src/stories/Button.tsx +37 -0
- package/src/stories/Configure.mdx +364 -0
- package/src/stories/Header.stories.ts +33 -0
- package/src/stories/Header.tsx +56 -0
- package/src/stories/Page.stories.ts +32 -0
- package/src/stories/Page.tsx +73 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/page.css +68 -0
- package/src/styles/rtl-utils.css +90 -0
- package/src/styles/rtl.css +105 -0
- package/src/utils/api-error.ts +26 -0
- package/src/utils/cn.ts +10 -0
- package/src/utils/error-callback.ts +116 -0
- package/src/utils/formatAccountNumber.ts +9 -0
- package/src/utils/handleIdentifiers.ts +90 -0
- package/src/utils/posthog.ts +67 -0
- package/src/utils/toast-helpers.ts +61 -0
- package/src/vite-env.d.ts +1 -0
- package/stage-aa-2506251021.zip +0 -0
- package/tsconfig.app.json +33 -0
- package/tsconfig.json +13 -0
- package/tsconfig.node.json +24 -0
- package/vite.config.ts +45 -0
- package/vitest.shims.d.ts +1 -0
- package/vitest.workspace.ts +46 -0
@@ -0,0 +1,638 @@
|
|
1
|
+
import BankCard from '@/components/cards/BankCard'
|
2
|
+
import OuterCard from '@/components/cards/OuterCard'
|
3
|
+
import { AnimatedButton } from '@/components/ui/animatedButton'
|
4
|
+
import { useNavigate } from 'react-router-dom'
|
5
|
+
import React, { useEffect } from 'react'
|
6
|
+
import SectionTitle from '@/components/title/SectionTitle'
|
7
|
+
import { Repeat } from 'lucide-react'
|
8
|
+
import { Button } from '@/components/ui/button'
|
9
|
+
import { MobileFooter } from '@/components/ui/mobile-footer'
|
10
|
+
import WebFooter from '@/components/ui/web-footer'
|
11
|
+
import { useFipStore } from '@/store/fip.store'
|
12
|
+
import { Collapsible, CollapsibleContent } from '@/components/ui/collapsible'
|
13
|
+
import { Input } from '@/components/ui/input'
|
14
|
+
import { useMutation } from '@tanstack/react-query'
|
15
|
+
import { accountService } from '@/services/api'
|
16
|
+
import { trackEvent, EVENTS } from '@/utils/posthog'
|
17
|
+
import { motion } from 'framer-motion'
|
18
|
+
import checkIconDark from '../../assets/icons/check-icon-dark.svg'
|
19
|
+
import { useSetPageTitle } from '@/hooks/use-page-title'
|
20
|
+
import DummyFooter from '@/components/dummyFooter'
|
21
|
+
import { useTranslation } from 'react-i18next'
|
22
|
+
|
23
|
+
const SuccessAnimation = ({
|
24
|
+
startAnimation = false,
|
25
|
+
onAnimationComplete
|
26
|
+
}: {
|
27
|
+
startAnimation: boolean;
|
28
|
+
onAnimationComplete: () => void;
|
29
|
+
}) => (
|
30
|
+
<motion.div
|
31
|
+
initial={{ opacity: 0, scale: 0.5 }}
|
32
|
+
animate={
|
33
|
+
startAnimation ? { opacity: 1, scale: 1 } : { opacity: 0, scale: 0.5 }
|
34
|
+
}
|
35
|
+
transition={{
|
36
|
+
duration: 0.5,
|
37
|
+
ease: [0, 0.71, 0.2, 1.01]
|
38
|
+
}}
|
39
|
+
className='flex flex-col items-center justify-center gap-4'
|
40
|
+
onAnimationComplete={onAnimationComplete}
|
41
|
+
>
|
42
|
+
<motion.div
|
43
|
+
initial={{ scale: 0 }}
|
44
|
+
animate={startAnimation ? { scale: 1 } : { scale: 0 }}
|
45
|
+
transition={{
|
46
|
+
type: 'spring',
|
47
|
+
stiffness: 260,
|
48
|
+
damping: 20
|
49
|
+
}}
|
50
|
+
className='relative h-40 w-40'
|
51
|
+
>
|
52
|
+
<motion.img
|
53
|
+
src={checkIconDark}
|
54
|
+
alt='Check Icon'
|
55
|
+
className='absolute inset-0 z-10'
|
56
|
+
initial={{ scale: 0.2, opacity: 0, rotate: -50, top: -120 }}
|
57
|
+
animate={
|
58
|
+
startAnimation
|
59
|
+
? { scale: 0.2, opacity: 0.2, rotate: -50, top: 0 }
|
60
|
+
: { scale: 0.2, opacity: 0, rotate: -50, top: -120 }
|
61
|
+
}
|
62
|
+
exit={{ scale: 0, opacity: 0, top: 0 }}
|
63
|
+
transition={{
|
64
|
+
duration: 0.8,
|
65
|
+
delay: 0,
|
66
|
+
repeat: 0
|
67
|
+
}}
|
68
|
+
/>
|
69
|
+
<motion.img
|
70
|
+
src={checkIconDark}
|
71
|
+
alt='Check Icon'
|
72
|
+
className='absolute inset-0 z-11'
|
73
|
+
initial={{ scale: 0, opacity: 0, rotate: -50, top: 0 }}
|
74
|
+
animate={
|
75
|
+
startAnimation
|
76
|
+
? { scale: 1.1, opacity: 0.2, rotate: 0, top: 0 }
|
77
|
+
: { scale: 0, opacity: 0, rotate: -50, top: 0 }
|
78
|
+
}
|
79
|
+
exit={{ scale: 0, opacity: 0, rotate: 0, top: 0 }}
|
80
|
+
transition={{
|
81
|
+
duration: 1,
|
82
|
+
delay: 0.5,
|
83
|
+
repeat: 0,
|
84
|
+
repeatType: 'reverse'
|
85
|
+
}}
|
86
|
+
/>
|
87
|
+
<motion.img
|
88
|
+
src={checkIconDark}
|
89
|
+
alt='Check Icon'
|
90
|
+
className='absolute inset-0 z-12'
|
91
|
+
initial={{ scale: 0, rotate: -50, top: 0 }}
|
92
|
+
animate={
|
93
|
+
startAnimation
|
94
|
+
? { scale: 1, rotate: 0, top: 0 }
|
95
|
+
: { scale: 0, rotate: -50, top: 0 }
|
96
|
+
}
|
97
|
+
transition={{
|
98
|
+
type: 'spring',
|
99
|
+
damping: 8,
|
100
|
+
stiffness: 100,
|
101
|
+
delay: 0.5,
|
102
|
+
duration: 1
|
103
|
+
}}
|
104
|
+
/>
|
105
|
+
</motion.div>
|
106
|
+
<motion.p
|
107
|
+
initial={{ opacity: 0, y: 10 }}
|
108
|
+
animate={startAnimation ? { opacity: 1, y: 0 } : { opacity: 0, y: 10 }}
|
109
|
+
transition={{ delay: 0.3 }}
|
110
|
+
className='text-lg font-medium text-gray-900 dark:text-white'
|
111
|
+
>
|
112
|
+
Verified Successfully!
|
113
|
+
</motion.p>
|
114
|
+
</motion.div>
|
115
|
+
)
|
116
|
+
|
117
|
+
interface Account {
|
118
|
+
id: string;
|
119
|
+
fipId: string;
|
120
|
+
accounts: string;
|
121
|
+
otp: string;
|
122
|
+
}
|
123
|
+
|
124
|
+
interface LinkSelectedAccountsProps {
|
125
|
+
state?: {
|
126
|
+
category: string
|
127
|
+
selectedFips: string[]
|
128
|
+
selectedAccounts: string[]
|
129
|
+
signature?: string
|
130
|
+
}
|
131
|
+
currentCategory?: string | null
|
132
|
+
}
|
133
|
+
|
134
|
+
const LinkSelectedAccounts = ({
|
135
|
+
state,
|
136
|
+
currentCategory
|
137
|
+
}: LinkSelectedAccountsProps) => {
|
138
|
+
const { t } = useTranslation()
|
139
|
+
useSetPageTitle(t('linkAllSelectedAccounts'))
|
140
|
+
const navigate = useNavigate()
|
141
|
+
const [countdown, setCountdown] = React.useState(60)
|
142
|
+
const [otpResent, setOTPResent] = React.useState(false)
|
143
|
+
const [showSuccessAnimation, setShowSuccessAnimation] = React.useState(false)
|
144
|
+
const [isExpanded, setIsExpanded] = React.useState<{
|
145
|
+
item: Account | null;
|
146
|
+
expanded: boolean;
|
147
|
+
error?: string | null;
|
148
|
+
}>({ item: null, expanded: false, error: null })
|
149
|
+
const {
|
150
|
+
completeCategory,
|
151
|
+
categories,
|
152
|
+
setActiveCategory,
|
153
|
+
completedCategories,
|
154
|
+
activeCategory
|
155
|
+
} = useFipStore()
|
156
|
+
const category = state?.category || currentCategory || 'BANKS'
|
157
|
+
const {
|
158
|
+
selectedAccountToLink,
|
159
|
+
selectedMobileNumber,
|
160
|
+
signature,
|
161
|
+
accountsStatusArray,
|
162
|
+
setAccountsStatusArray
|
163
|
+
} = useFipStore()
|
164
|
+
|
165
|
+
const sendBankOTPQuery = useMutation({
|
166
|
+
mutationFn: ({ fipId, accounts }: { fipId: string; accounts: any[] }) =>
|
167
|
+
accountService.sendBankOTP({
|
168
|
+
signature: signature || '',
|
169
|
+
FipId: fipId || '',
|
170
|
+
Accounts: accounts
|
171
|
+
}),
|
172
|
+
onSuccess: () => {
|
173
|
+
setCountdown(60)
|
174
|
+
setIsExpanded(old => ({ ...old, error: null }))
|
175
|
+
},
|
176
|
+
onError: (error) => {
|
177
|
+
setCountdown(0)
|
178
|
+
setIsExpanded(old => ({
|
179
|
+
...old,
|
180
|
+
error: error?.response?.data?.errorMsg || 'Failed to send OTP. Please try again.'
|
181
|
+
}))
|
182
|
+
}
|
183
|
+
})
|
184
|
+
|
185
|
+
useEffect(() => {
|
186
|
+
const intervalId = setInterval(() => {
|
187
|
+
if (countdown > 0) {
|
188
|
+
setCountdown(countdown - 1)
|
189
|
+
}
|
190
|
+
}, 1000)
|
191
|
+
return () => clearInterval(intervalId)
|
192
|
+
}, [countdown])
|
193
|
+
|
194
|
+
useEffect(() => {
|
195
|
+
if (
|
196
|
+
accountsStatusArray?.find(i => i.id === isExpanded?.item?.id)?.status ===
|
197
|
+
'success'
|
198
|
+
) {
|
199
|
+
const timer = setTimeout(() => {
|
200
|
+
setShowSuccessAnimation(true)
|
201
|
+
}, 300)
|
202
|
+
return () => clearTimeout(timer)
|
203
|
+
}
|
204
|
+
}, [accountsStatusArray, isExpanded?.item?.id])
|
205
|
+
|
206
|
+
const handleNextActiveAccount = (type?: string) => {
|
207
|
+
const index = selectedAccountToLink.findIndex(
|
208
|
+
item => item.id === isExpanded?.item?.id
|
209
|
+
)
|
210
|
+
let nextIndex = -1
|
211
|
+
|
212
|
+
if (type == 'retry' && accountsStatusArray?.find(i => i.id == isExpanded?.item?.id)?.status == 'error') {
|
213
|
+
setIsExpanded((old) => ({ ...old, expanded: true, error: null }))
|
214
|
+
return;
|
215
|
+
}
|
216
|
+
|
217
|
+
for (let i = index + 1; i < selectedAccountToLink?.length; i++) {
|
218
|
+
if (
|
219
|
+
(accountsStatusArray.find(
|
220
|
+
item => item.id == selectedAccountToLink[i]?.id
|
221
|
+
)?.status === 'error' && type !== 'new') ||
|
222
|
+
(!accountsStatusArray.find(
|
223
|
+
item => item.id == selectedAccountToLink[i]?.id
|
224
|
+
)?.status &&
|
225
|
+
i >= 0) && index !== i
|
226
|
+
) {
|
227
|
+
nextIndex = i
|
228
|
+
break
|
229
|
+
}
|
230
|
+
}
|
231
|
+
|
232
|
+
if (
|
233
|
+
// index != -1 &&
|
234
|
+
nextIndex < selectedAccountToLink?.length &&
|
235
|
+
nextIndex != -1
|
236
|
+
) {
|
237
|
+
sendBankOTPQuery.mutate({
|
238
|
+
fipId: selectedAccountToLink[nextIndex].fipId,
|
239
|
+
accounts: selectedAccountToLink[nextIndex]?.['DiscoveredAccounts']
|
240
|
+
})
|
241
|
+
setIsExpanded({ item: selectedAccountToLink[nextIndex], expanded: true })
|
242
|
+
} else {
|
243
|
+
if (type != 'retry') { setIsExpanded({ item: null, expanded: false }) }
|
244
|
+
}
|
245
|
+
setOTPResent(false)
|
246
|
+
}
|
247
|
+
|
248
|
+
const verifyBankOTPQuery = useMutation({
|
249
|
+
mutationFn: ({ fipId }: { fipId: string }) =>
|
250
|
+
accountService.verifyBankOTP({
|
251
|
+
RefNumber: sendBankOTPQuery?.data?.refNumber || '',
|
252
|
+
token: isExpanded?.item?.otp || '',
|
253
|
+
fipId: fipId || ''
|
254
|
+
}),
|
255
|
+
onSuccess: data => {
|
256
|
+
if (data?.AccLinkDetails?.[0]?.status === 'LINKED') {
|
257
|
+
setIsExpanded(old => ({ ...old, error: null }))
|
258
|
+
trackEvent(EVENTS.LINK_ACCOUNT, {
|
259
|
+
category,
|
260
|
+
fipId: isExpanded?.item?.fipId,
|
261
|
+
accountId: isExpanded?.item?.id
|
262
|
+
})
|
263
|
+
const accountIndex = accountsStatusArray.findIndex(
|
264
|
+
i => i.id === isExpanded?.item?.id
|
265
|
+
)
|
266
|
+
if (accountIndex == -1) {
|
267
|
+
setAccountsStatusArray([
|
268
|
+
...accountsStatusArray,
|
269
|
+
{ ...isExpanded?.item, status: 'success' }
|
270
|
+
])
|
271
|
+
} else {
|
272
|
+
const accountsArr = [...accountsStatusArray]
|
273
|
+
accountsArr.splice(accountIndex, 1, {
|
274
|
+
...isExpanded?.item,
|
275
|
+
status: 'success'
|
276
|
+
})
|
277
|
+
setAccountsStatusArray([...accountsArr])
|
278
|
+
}
|
279
|
+
|
280
|
+
setTimeout(() => {
|
281
|
+
handleNextActiveAccount('new')
|
282
|
+
}, 2000)
|
283
|
+
}
|
284
|
+
},
|
285
|
+
onError: error => {
|
286
|
+
setIsExpanded(old => ({
|
287
|
+
...old,
|
288
|
+
error: error?.response?.data?.errorMsg || 'Invalid OTP. Please try again.'
|
289
|
+
}))
|
290
|
+
const accountIndex = accountsStatusArray.findIndex(
|
291
|
+
i => i.id === isExpanded?.item?.id
|
292
|
+
)
|
293
|
+
if (accountIndex == -1) {
|
294
|
+
setAccountsStatusArray([
|
295
|
+
...accountsStatusArray,
|
296
|
+
{ ...isExpanded?.item, status: 'error' }
|
297
|
+
])
|
298
|
+
} else {
|
299
|
+
const accountsArr = [...accountsStatusArray]
|
300
|
+
accountsArr.splice(accountIndex, 1, {
|
301
|
+
...isExpanded?.item,
|
302
|
+
status: 'error'
|
303
|
+
})
|
304
|
+
setAccountsStatusArray([...accountsArr])
|
305
|
+
handleNextActiveAccount('new')
|
306
|
+
}
|
307
|
+
}
|
308
|
+
})
|
309
|
+
|
310
|
+
useEffect(() => {
|
311
|
+
if (selectedAccountToLink?.length) {
|
312
|
+
setAccountsStatusArray([])
|
313
|
+
if (accountsStatusArray?.length) {
|
314
|
+
handleNextActiveAccount()
|
315
|
+
} else {
|
316
|
+
setIsExpanded({ item: selectedAccountToLink[0], expanded: true })
|
317
|
+
sendBankOTPQuery.mutate({
|
318
|
+
fipId: selectedAccountToLink[0].fipId,
|
319
|
+
accounts: selectedAccountToLink[0]?.['DiscoveredAccounts']
|
320
|
+
})
|
321
|
+
}
|
322
|
+
}
|
323
|
+
}, [selectedAccountToLink])
|
324
|
+
|
325
|
+
// Format category name for display
|
326
|
+
const formatCategoryName = (name: string) => {
|
327
|
+
return name
|
328
|
+
.split('_')
|
329
|
+
.map(word => word.charAt(0) + word.slice(1).toLowerCase())
|
330
|
+
.join(' ')
|
331
|
+
}
|
332
|
+
|
333
|
+
const handleComplete = () => {
|
334
|
+
// Mark this category as complete
|
335
|
+
setAccountsStatusArray([])
|
336
|
+
completeCategory(category)
|
337
|
+
trackEvent(EVENTS.SELECT_ALL_ACCOUNTS, { category })
|
338
|
+
|
339
|
+
// Check if there are more categories to process
|
340
|
+
const currentIndex = categories.indexOf(category)
|
341
|
+
if (currentIndex < categories.length - 1) {
|
342
|
+
// Move to the next category
|
343
|
+
const nextCategory = categories[currentIndex + 1]
|
344
|
+
setActiveCategory(nextCategory)
|
345
|
+
|
346
|
+
// Navigate directly to the next category path for proper step highlighting
|
347
|
+
navigate(`/link-accounts/${nextCategory.toLowerCase()}`, {
|
348
|
+
state: {
|
349
|
+
completedCategories: [...(completedCategories || []), category]
|
350
|
+
}
|
351
|
+
})
|
352
|
+
} else {
|
353
|
+
// All categories done, move to review consent
|
354
|
+
navigate('/review', {
|
355
|
+
state: {
|
356
|
+
selectedFips: state?.selectedFips,
|
357
|
+
completedCategories: [...(completedCategories || []), category]
|
358
|
+
}
|
359
|
+
})
|
360
|
+
}
|
361
|
+
}
|
362
|
+
|
363
|
+
return (
|
364
|
+
<div>
|
365
|
+
<div className='flex flex-col gap-1 w-full sm:px-4 md:px-14 gap-2'>
|
366
|
+
<SectionTitle
|
367
|
+
className='md:mt-4'
|
368
|
+
title={`Selected ${formatCategoryName(category)}${selectedAccountToLink.length > 1 ? 's' : ''}`}
|
369
|
+
|
370
|
+
// title={`Selected ${formatCategoryName(category)}`}
|
371
|
+
rightSection={
|
372
|
+
selectedAccountToLink.every(itemA =>
|
373
|
+
accountsStatusArray.some(itemB => itemB.id === itemA.id)
|
374
|
+
) &&
|
375
|
+
accountsStatusArray?.find(i => i.status === 'error') && (
|
376
|
+
<AnimatedButton
|
377
|
+
variant={'text'}
|
378
|
+
size={'text'}
|
379
|
+
onClick={() => {
|
380
|
+
handleNextActiveAccount('retry')
|
381
|
+
}}
|
382
|
+
>
|
383
|
+
<Repeat className='text-primary' />{' '}
|
384
|
+
<p className='text-primary'>Retry failed</p>
|
385
|
+
</AnimatedButton>
|
386
|
+
)
|
387
|
+
}
|
388
|
+
/>
|
389
|
+
{selectedAccountToLink.map((account: any) => (
|
390
|
+
<OuterCard
|
391
|
+
onClick={() => { }}
|
392
|
+
key={account.id}
|
393
|
+
hoverEffect={
|
394
|
+
!Boolean(
|
395
|
+
(isExpanded?.item?.id === account?.id && isExpanded.expanded) ||
|
396
|
+
accountsStatusArray?.find(i => i.id === account?.id)
|
397
|
+
?.status == 'linked'
|
398
|
+
)
|
399
|
+
}
|
400
|
+
>
|
401
|
+
<Collapsible
|
402
|
+
onOpenChange={value =>
|
403
|
+
accountsStatusArray?.find(i => i.id === account?.id)?.status !==
|
404
|
+
'success' && setIsExpanded({ item: null, expanded: value, error: null })
|
405
|
+
}
|
406
|
+
open={
|
407
|
+
isExpanded?.item?.id === account?.id &&
|
408
|
+
isExpanded.expanded &&
|
409
|
+
accountsStatusArray?.find(i => i.id === account?.id)?.status !==
|
410
|
+
'success'
|
411
|
+
}
|
412
|
+
className='flex flex-col gap-1 w-full'
|
413
|
+
>
|
414
|
+
{accountsStatusArray?.find(i => i.id === account?.id)?.status ===
|
415
|
+
'success' && isExpanded?.item?.id === account?.id ? (
|
416
|
+
<CollapsibleContent
|
417
|
+
className='flex flex-col gap-1 w-full h-[223px]'
|
418
|
+
open={
|
419
|
+
isExpanded?.item?.id === account?.id && isExpanded.expanded
|
420
|
+
}
|
421
|
+
>
|
422
|
+
<SuccessAnimation
|
423
|
+
startAnimation={showSuccessAnimation}
|
424
|
+
onAnimationComplete={() => {
|
425
|
+
setTimeout(() => {
|
426
|
+
setShowSuccessAnimation(false);
|
427
|
+
setIsExpanded(old => ({ ...old, expanded: false, error: null }));
|
428
|
+
}, 800)
|
429
|
+
}}
|
430
|
+
/>
|
431
|
+
</CollapsibleContent>
|
432
|
+
) : (
|
433
|
+
<>
|
434
|
+
<div
|
435
|
+
onClick={() => {
|
436
|
+
if (
|
437
|
+
accountsStatusArray?.find(i => i.id === account?.id)
|
438
|
+
?.status !== 'success' && !isExpanded?.expanded
|
439
|
+
) {
|
440
|
+
if (
|
441
|
+
account.id !== isExpanded.item?.id ||
|
442
|
+
!isExpanded.expanded
|
443
|
+
) {
|
444
|
+
sendBankOTPQuery.mutate({
|
445
|
+
fipId: account.fipId,
|
446
|
+
accounts: account?.['DiscoveredAccounts']
|
447
|
+
})
|
448
|
+
}
|
449
|
+
setIsExpanded({
|
450
|
+
item:
|
451
|
+
account.id === isExpanded.item?.id &&
|
452
|
+
isExpanded.expanded
|
453
|
+
? null
|
454
|
+
: account,
|
455
|
+
expanded:
|
456
|
+
account.id !== isExpanded.item?.id
|
457
|
+
? true
|
458
|
+
: !isExpanded.expanded
|
459
|
+
})
|
460
|
+
}
|
461
|
+
}}
|
462
|
+
>
|
463
|
+
<BankCard
|
464
|
+
loading={false}
|
465
|
+
badgeText={account.isNew ? 'New' : undefined}
|
466
|
+
bankName={account.fipName || 'Financial Institution'}
|
467
|
+
image={account?.['DiscoveredAccounts']?.[0]?.logoUrl || undefined}
|
468
|
+
subText={false}
|
469
|
+
rightSection={
|
470
|
+
isExpanded?.item?.id !== account?.id &&
|
471
|
+
accountsStatusArray?.find(i => i.id === account?.id)
|
472
|
+
?.id &&
|
473
|
+
(accountsStatusArray?.find(i => i.id === account?.id)
|
474
|
+
?.status === 'success' ? (
|
475
|
+
<Button
|
476
|
+
variant={'secondary'}
|
477
|
+
className='bg-green-100 text-green-700 hover:bg-green-200'
|
478
|
+
>
|
479
|
+
Linked
|
480
|
+
</Button>
|
481
|
+
) : accountsStatusArray?.find(i => i.id === account?.id)
|
482
|
+
?.status === 'error' ? (
|
483
|
+
<Button
|
484
|
+
variant={'secondary'}
|
485
|
+
className='bg-red-100 text-red-700 hover:bg-red-200'
|
486
|
+
>
|
487
|
+
Failed
|
488
|
+
</Button>
|
489
|
+
) : (
|
490
|
+
<Button
|
491
|
+
variant={'secondary'}
|
492
|
+
className='bg-yellow-100 text-yellow-700 hover:bg-yellow-200'
|
493
|
+
>
|
494
|
+
Skipped
|
495
|
+
</Button>
|
496
|
+
))
|
497
|
+
}
|
498
|
+
/>
|
499
|
+
</div>
|
500
|
+
<CollapsibleContent
|
501
|
+
className='flex flex-col gap-1 w-full'
|
502
|
+
open={
|
503
|
+
isExpanded?.item?.id === account?.id &&
|
504
|
+
isExpanded.expanded &&
|
505
|
+
accountsStatusArray?.find(i => i.id === account?.id)
|
506
|
+
?.status !== 'success'
|
507
|
+
}
|
508
|
+
>
|
509
|
+
<>
|
510
|
+
<div className='flex flex-col gap-1 w-full my-2 mt-3'>
|
511
|
+
<div className='font-[500] text-muted-secondary text-xs md:text-md'>
|
512
|
+
Enter the OTP you received from {account.fipName} to{' '}
|
513
|
+
<span className='text-consent-primary dark:text-card-foreground font-semibold'>
|
514
|
+
+91 {selectedMobileNumber}
|
515
|
+
</span>
|
516
|
+
</div>
|
517
|
+
</div>
|
518
|
+
<div className='flex flex-col gap-1 w-full'>
|
519
|
+
<Input
|
520
|
+
// type='text'
|
521
|
+
placeholder={t('login.enterOtp')}
|
522
|
+
className={`w-full h-12 border-gray-200 ${isExpanded.error ? 'border-red-500' : ''}`}
|
523
|
+
// Allow only numbers
|
524
|
+
// type="tel"
|
525
|
+
// inputMode="numeric"
|
526
|
+
value={isExpanded.item?.otp}
|
527
|
+
onChange={e => {
|
528
|
+
const value = e.target.value.replace(/[^0-9]/g, '');
|
529
|
+
setIsExpanded(old => ({
|
530
|
+
...old,
|
531
|
+
item: { ...old.item, otp: activeCategory === 'GST' ? e.target.value : value },
|
532
|
+
error: null
|
533
|
+
}))
|
534
|
+
}}
|
535
|
+
/>
|
536
|
+
</div>
|
537
|
+
{isExpanded.error ? (
|
538
|
+
<div className='h-6'>
|
539
|
+
<p className='text-[10px] md:text-sm text-red-500'>{isExpanded.error}</p>
|
540
|
+
</div>
|
541
|
+
) : null}
|
542
|
+
<p className='text-sm mt-1 text-muted-secondary'>
|
543
|
+
{countdown > 0 && !otpResent ? 'Resend OTP in ' : null}
|
544
|
+
{countdown > 0 && otpResent ? 'OTP resent, Resend OTP again in ' : null}
|
545
|
+
<span>
|
546
|
+
{countdown > 0
|
547
|
+
? `${String(Math.floor(countdown / 60)).padStart(
|
548
|
+
2,
|
549
|
+
'0'
|
550
|
+
)}:${String(countdown % 60).padStart(2, '0')}s`
|
551
|
+
: null}
|
552
|
+
</span>
|
553
|
+
{countdown === 0 && (
|
554
|
+
<AnimatedButton
|
555
|
+
onClick={() => {
|
556
|
+
sendBankOTPQuery.mutate({
|
557
|
+
fipId: account.fipId,
|
558
|
+
accounts: account?.['DiscoveredAccounts']
|
559
|
+
})
|
560
|
+
setOTPResent(true)
|
561
|
+
}}
|
562
|
+
variant={'text'}
|
563
|
+
size={'text'}
|
564
|
+
className='text-primary w-fit'
|
565
|
+
>
|
566
|
+
{t('login.resend')}
|
567
|
+
</AnimatedButton>
|
568
|
+
)}
|
569
|
+
</p>
|
570
|
+
<div className='flex justify-between gap-1 w-full flex-col-reverse md:flex-row '>
|
571
|
+
<AnimatedButton
|
572
|
+
onClick={() => {
|
573
|
+
const accountIndex = accountsStatusArray.findIndex(
|
574
|
+
i => i.id === account?.id
|
575
|
+
)
|
576
|
+
if (accountIndex == -1) {
|
577
|
+
setAccountsStatusArray([
|
578
|
+
...accountsStatusArray,
|
579
|
+
{ ...account, status: 'skipped' }
|
580
|
+
])
|
581
|
+
} else {
|
582
|
+
const accountsArr = [...accountsStatusArray]
|
583
|
+
accountsArr.splice(accountIndex, 1, {
|
584
|
+
...account,
|
585
|
+
status: 'skipped'
|
586
|
+
})
|
587
|
+
setAccountsStatusArray([...accountsArr])
|
588
|
+
}
|
589
|
+
|
590
|
+
handleNextActiveAccount()
|
591
|
+
}}
|
592
|
+
size={'lg'}
|
593
|
+
variant={'ghost'}
|
594
|
+
className='text-primary w-full md:w-[48%]'
|
595
|
+
>
|
596
|
+
{t('skip')}
|
597
|
+
</AnimatedButton>
|
598
|
+
<AnimatedButton
|
599
|
+
onClick={() => {
|
600
|
+
verifyBankOTPQuery.mutate({
|
601
|
+
fipId: account.fipId
|
602
|
+
})
|
603
|
+
}}
|
604
|
+
size={'lg'}
|
605
|
+
className='w-full md:w-[48%] mt-4 md:mt-0'
|
606
|
+
loading={verifyBankOTPQuery.isPending}
|
607
|
+
>
|
608
|
+
{t('link')}
|
609
|
+
</AnimatedButton>
|
610
|
+
</div>
|
611
|
+
</>
|
612
|
+
</CollapsibleContent>
|
613
|
+
</>
|
614
|
+
)}
|
615
|
+
</Collapsible>
|
616
|
+
</OuterCard>
|
617
|
+
))}
|
618
|
+
<DummyFooter />
|
619
|
+
</div>
|
620
|
+
|
621
|
+
<MobileFooter show={selectedAccountToLink.length === accountsStatusArray.length}>
|
622
|
+
<div className='flex flex-col items-center w-full gap-4'>
|
623
|
+
<AnimatedButton onClick={handleComplete} size='lg' className='w-full h-[50px]'>
|
624
|
+
{t('proceed')}
|
625
|
+
</AnimatedButton>
|
626
|
+
</div>
|
627
|
+
</MobileFooter>
|
628
|
+
|
629
|
+
<WebFooter show={selectedAccountToLink.length === accountsStatusArray.length}>
|
630
|
+
<AnimatedButton onClick={handleComplete} size='lg'>
|
631
|
+
{t('proceed')}
|
632
|
+
</AnimatedButton>
|
633
|
+
</WebFooter>
|
634
|
+
</div>
|
635
|
+
)
|
636
|
+
}
|
637
|
+
|
638
|
+
export default LinkSelectedAccounts
|