Skip to content

Commit

Permalink
fix: improve shuftipro iframe (#1429)
Browse files Browse the repository at this point in the history
* fix: improve shuftipro iframe

* simplify step logic
  • Loading branch information
JP authored May 30, 2023
1 parent 7b3a614 commit e3d9561
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import { Box } from '@centrifuge/fabric'

type Props = {
verificationURL: string
}

export const ManualBusinessVerification = ({ verificationURL }: Props) => {
return (
<Box height="100%">
<iframe
dataset-removable="true"
name="shuftipro-iframe"
id="shuftipro-iframe"
src={verificationURL}
title="shufti-pro-identity-verification"
allow="camera"
width="100%"
height="100%"
style={{
border: 'none',
}}
/>
</Box>
<iframe
dataset-removable="true"
name="shuftipro-iframe"
id="shuftipro-iframe"
src={verificationURL}
title="shufti-pro-identity-verification"
allow="camera"
width="100%"
height="100%"
style={{
border: 'none',
}}
/>
)
}
32 changes: 19 additions & 13 deletions centrifuge-app/src/pages/Onboarding/KnowYourBusiness/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Box, Dialog } from '@centrifuge/fabric'
import { useFormik } from 'formik'
import * as React from 'react'
import { object, string } from 'yup'
Expand All @@ -21,9 +22,7 @@ export const validationSchema = object({
})

export function KnowYourBusiness() {
const [activeKnowYourBusinessStep, setActiveKnowYourBusinessStep] = React.useState<number>(0)

const nextKnowYourBusinessStep = () => setActiveKnowYourBusinessStep((current) => current + 1)
const [isKnowYourBusinessDialogOpen, setIsKnowYourBusinessDialogOpen] = React.useState(false)

const { onboardingUser, nextStep } = useOnboarding<EntityUser>()

Expand Down Expand Up @@ -75,17 +74,24 @@ export function KnowYourBusiness() {

React.useEffect(() => {
if (verifyBusinessData?.verification_url) {
nextKnowYourBusinessStep()
setIsKnowYourBusinessDialogOpen(true)
}
}, [verifyBusinessData])

if (activeKnowYourBusinessStep === 0) {
return <BusinessInformation formik={formik} isLoading={isVerifyBusinessLoading} isError={isError} />
}

if (activeKnowYourBusinessStep === 1) {
return <ManualBusinessVerification verificationURL={verifyBusinessData?.verification_url} />
}

return null
return (
<>
<BusinessInformation formik={formik} isLoading={isVerifyBusinessLoading} isError={isError} />
{verifyBusinessData?.verification_url && (
<Dialog
isOpen={isKnowYourBusinessDialogOpen}
onClose={() => setIsKnowYourBusinessDialogOpen(false)}
width="850px"
>
<Box height="500px">
<ManualBusinessVerification verificationURL={verifyBusinessData.verification_url} />
</Box>
</Dialog>
)}
</>
)
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import { Box } from '@centrifuge/fabric'

type Props = {
verificationURL: string
}

export const IdentityVerification = ({ verificationURL }: Props) => (
<Box height="100%">
<iframe
dataset-removable="true"
name="shuftipro-iframe"
id="shuftipro-iframe"
src={verificationURL}
title="shufti-pro-identity-verification"
allow="camera"
width="100%"
height="100%"
style={{
border: 'none',
}}
/>
</Box>
<iframe
dataset-removable="true"
name="shuftipro-iframe"
id="shuftipro-iframe"
src={verificationURL}
title="shufti-pro-identity-verification"
allow="camera"
width="100%"
height="100%"
style={{
border: 'none',
}}
/>
)
62 changes: 34 additions & 28 deletions centrifuge-app/src/pages/Onboarding/KnowYourCustomer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Stack } from '@centrifuge/fabric'
import { Box, Button, Dialog, Flex, Stack } from '@centrifuge/fabric'
import { useFormik } from 'formik'
import * as React from 'react'
import { boolean, date, object, string } from 'yup'
Expand All @@ -24,7 +24,8 @@ const getValidationSchema = (investorType: 'individual' | 'entity') =>
})

export const KnowYourCustomer = () => {
const [activeKnowYourCustomerStep, setActiveKnowYourCustomerStep] = React.useState<number>(0)
const [isKnowYourCustomerDialogOpen, setIsKnowYourCustomerDialogOpen] = React.useState(false)

const [verificationDeclined, setVerificationDeclined] = React.useState(false)

const { onboardingUser } = useOnboarding()
Expand Down Expand Up @@ -76,34 +77,39 @@ export const KnowYourCustomer = () => {

React.useEffect(() => {
if (startKYCData?.verification_url) {
setActiveKnowYourCustomerStep(1)
setIsKnowYourCustomerDialogOpen(true)
}
}, [startKYCData])

if (activeKnowYourCustomerStep === 0) {
return <SignerVerification formik={formik} isLoading={isStartKYCLoading} isCompleted={isCompleted} />
}

if (activeKnowYourCustomerStep === 1) {
return (
<>
<IdentityVerification verificationURL={startKYCData.verification_url} />
{verificationDeclined && (
<Stack>
<Button
variant="primary"
onClick={() => {
setVerificationDeclined(false)
setActiveKnowYourCustomerStep(0)
}}
>
Restart verification
</Button>
return (
<>
<SignerVerification formik={formik} isLoading={isStartKYCLoading} isCompleted={isCompleted} />
{startKYCData?.verification_url && (
<Dialog
isOpen={isKnowYourCustomerDialogOpen}
onClose={() => setIsKnowYourCustomerDialogOpen(false)}
width="850px"
>
<Stack justifyContent="space-between">
<Box height="500px">
<IdentityVerification verificationURL={startKYCData.verification_url} />
</Box>
{verificationDeclined && (
<Flex justifyContent="flex-end">
<Button
variant="primary"
onClick={() => {
setVerificationDeclined(false)
setIsKnowYourCustomerDialogOpen(false)
}}
>
Restart verification
</Button>
</Flex>
)}
</Stack>
)}
</>
)
}

return null
</Dialog>
)}
</>
)
}

0 comments on commit e3d9561

Please sign in to comment.