-
Notifications
You must be signed in to change notification settings - Fork 13
[TASK-13870] Feat: Add identity verification button in profile page #1169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/app/(mobile-ui)/profile/identity-verification/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import PageContainer from '@/components/0_Bruddle/PageContainer' | ||
| import IdentityVerificationView from '@/components/Profile/views/IdentityVerification.view' | ||
|
|
||
| export default function IdentityVerificationPage() { | ||
| return ( | ||
| <PageContainer> | ||
| <IdentityVerificationView /> | ||
| </PageContainer> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { FC, SVGProps } from 'react' | ||
|
|
||
| export const ShieldIcon: FC<SVGProps<SVGSVGElement>> = (props) => { | ||
| return ( | ||
| <svg width="17" height="21" viewBox="0 0 17 21" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}> | ||
| <path | ||
| d="M8.69141 0.5L0.691406 3.5V9.59C0.691406 14.64 4.10141 19.35 8.69141 20.5C13.2814 19.35 16.6914 14.64 16.6914 9.59V3.5L8.69141 0.5ZM14.6914 9.59C14.6914 13.59 12.1414 17.29 8.69141 18.42C5.24141 17.29 2.69141 13.6 2.69141 9.59V4.89L8.69141 2.64L14.6914 4.89V9.59Z" | ||
| fill="currentColor" | ||
| /> | ||
| <path | ||
| d="M7.3982 12.0774L5.98444 10.6636C5.8269 10.5061 5.57647 10.5061 5.41893 10.6636C5.2614 10.8212 5.2614 11.0716 5.41893 11.2291L7.11141 12.9216C7.26894 13.0792 7.52342 13.0792 7.68095 12.9216L11.9626 8.64398C12.1202 8.48645 12.1202 8.23601 11.9626 8.07848C11.8051 7.92094 11.5547 7.92094 11.3971 8.07848L7.3982 12.0774Z" | ||
| fill="currentColor" | ||
| /> | ||
| </svg> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
src/components/Profile/views/IdentityVerification.view.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| 'use client' | ||
| import { updateUserById } from '@/app/actions/users' | ||
Zishan-7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { Button } from '@/components/0_Bruddle' | ||
| import { UserDetailsForm, UserDetailsFormData } from '@/components/AddMoney/UserDetailsForm' | ||
| import ErrorAlert from '@/components/Global/ErrorAlert' | ||
| import IframeWrapper from '@/components/Global/IframeWrapper' | ||
| import NavHeader from '@/components/Global/NavHeader' | ||
| import { KycVerificationInProgressModal } from '@/components/Kyc/KycVerificationInProgressModal' | ||
| import { useAuth } from '@/context/authContext' | ||
| import { useKycFlow } from '@/hooks/useKycFlow' | ||
| import { useRouter } from 'next/navigation' | ||
| import React, { useMemo, useRef, useState } from 'react' | ||
|
|
||
| const IdentityVerificationView = () => { | ||
| const { user, fetchUser } = useAuth() | ||
| const router = useRouter() | ||
| const formRef = useRef<{ handleSubmit: () => void }>(null) | ||
| const [isUserDetailsFormValid, setIsUserDetailsFormValid] = useState(false) | ||
| const [isUpdatingUser, setIsUpdatingUser] = useState(false) | ||
| const [userUpdateError, setUserUpdateError] = useState<string | null>(null) | ||
| const { | ||
| iframeOptions, | ||
| handleInitiateKyc, | ||
| handleIframeClose, | ||
| isVerificationProgressModalOpen, | ||
| closeVerificationProgressModal, | ||
| error: kycError, | ||
| isLoading: isKycLoading, | ||
| } = useKycFlow() | ||
|
|
||
| const [firstName, ...lastNameParts] = (user?.user.fullName ?? '').split(' ') | ||
| const lastName = lastNameParts.join(' ') | ||
|
|
||
| const initialUserDetails: Partial<UserDetailsFormData> = useMemo( | ||
| () => ({ | ||
| firstName: user?.user.fullName ? firstName : '', | ||
| lastName: user?.user.fullName ? lastName : '', | ||
| email: user?.user.email ?? '', | ||
| }), | ||
| [user?.user.fullName, user?.user.email, firstName, lastName] | ||
| ) | ||
|
|
||
| const handleUserDetailsSubmit = async (data: UserDetailsFormData) => { | ||
| setIsUpdatingUser(true) | ||
| setUserUpdateError(null) | ||
| try { | ||
| if (!user?.user.userId) throw new Error('User not found') | ||
| const result = await updateUserById({ | ||
| userId: user.user.userId, | ||
| fullName: `${data.firstName} ${data.lastName}`, | ||
| email: data.email, | ||
| }) | ||
| if (result.error) { | ||
| throw new Error(result.error) | ||
| } | ||
| await fetchUser() | ||
| // setStep('kyc') | ||
| await handleInitiateKyc() | ||
| } catch (error: any) { | ||
| setUserUpdateError(error.message) | ||
| return { error: error.message } | ||
| } finally { | ||
| setIsUpdatingUser(false) | ||
| } | ||
| return {} | ||
| } | ||
|
|
||
| return ( | ||
| <div className="flex min-h-[inherit] flex-col"> | ||
| <NavHeader title="Identity Verification" onPrev={() => router.replace('/profile')} /> | ||
| <div className="my-auto"> | ||
| <h1 className="mb-3 font-bold">Provide information to begin verification</h1> | ||
| <UserDetailsForm | ||
| ref={formRef} | ||
| onSubmit={handleUserDetailsSubmit} | ||
| isSubmitting={isUpdatingUser} | ||
| onValidChange={setIsUserDetailsFormValid} | ||
| initialData={initialUserDetails} | ||
| /> | ||
|
|
||
| <Button | ||
| onClick={() => formRef.current?.handleSubmit()} | ||
| loading={isUpdatingUser || isKycLoading} | ||
| variant="purple" | ||
| shadowSize="4" | ||
| className="mt-3 w-full" | ||
| disabled={!isUserDetailsFormValid || isUpdatingUser || isKycLoading} | ||
| icon="check-circle" | ||
| > | ||
| Verify now | ||
| </Button> | ||
|
|
||
| {(userUpdateError || kycError) && <ErrorAlert description={userUpdateError ?? kycError ?? ''} />} | ||
|
|
||
| <IframeWrapper {...iframeOptions} onClose={handleIframeClose} /> | ||
|
|
||
| <KycVerificationInProgressModal | ||
| isOpen={isVerificationProgressModalOpen} | ||
| onClose={closeVerificationProgressModal} | ||
| /> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default IdentityVerificationView | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.