Skip to content

Commit

Permalink
feat: identification screens added in verify by video
Browse files Browse the repository at this point in the history
Signed-off-by: jonnaup03 <jonnathan.up03>
  • Loading branch information
jonnaup03 committed Dec 28, 2024
1 parent 1463979 commit 5b8f9fe
Show file tree
Hide file tree
Showing 10 changed files with 410 additions and 9 deletions.
11 changes: 10 additions & 1 deletion packages/legacy/core/App/modules/send-video/localization/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@ export const en = {
"PersonAtServiceBC": "A person at Service Nova Scotia will watch the video. They need to hear and see you clearly.",
"YouShould": "You should",
"VideosWithInappropriateOffensive" : "Videos with inappropriate, offensive, or harrsing behavior will not be accepted.",
"StartRecordingVideo" : "Start Recording Video"
"StartRecordingVideo" : "Start Recording Video",
"Begin" : "Begin"
},
"Identification": {
"EnterIdentificationNumber": "Enter Identification Number",
"ClickImage": "Click Image",
"FrontOfCard": "Front of Card",
"BackOfCard": "Back of Card"
},
"Screens": {
"ThankYou": "Thank You",
"PleaseWaitWhileWeSubmitYourVideoVerification": "Please wait while we submit your video verification",
"VideoInstructions": "Video Instructions",
"Identification" : "Identification",
"CaptureCard" : "Capture Card",
"VerifyVideo": "Verify Video",
"Next": "Next",
"Done": "Done",
Expand Down
11 changes: 10 additions & 1 deletion packages/legacy/core/App/modules/send-video/localization/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@ export const fr = {
"PersonAtServiceBC": "A person at Service Nova Scotia will watch the video. They need to hear and see you clearly.",
"YouShould": "You should",
"VideosWithInappropriateOffensive" : "Videos with inappropriate, offensive, or harrsing behavior will not be accepted.",
"StartRecordingVideo" : "Start Recording Video"
"StartRecordingVideo" : "Start Recording Video",
"Begin" : "Begin"
},
"Identification": {
"EnterIdentificationNumber": "Enter Identification Number",
"ClickImage": "Click Image",
"FrontOfCard": "Front of Card",
"BackOfCard": "Back of Card"
},
"Screens": {
"ThankYou": "Thank You",
"PleaseWaitWhileWeSubmitYourVideoVerification": "Please wait while we submit your video verification",
"VideoInstructions": "Video Instructions",
"Identification" : "Identification",
"CaptureCard" : "Capture Card",
"VerifyVideo": "Verify Video",
"Next": "Next",
"Done": "Done",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@ export const ptBr = {
"PersonAtServiceBC": "A person at Service Nova Scotia will watch the video. They need to hear and see you clearly.",
"YouShould": "You should",
"VideosWithInappropriateOffensive" : "Videos with inappropriate, offensive, or harrsing behavior will not be accepted.",
"StartRecordingVideo" : "Start Recording Video"
"StartRecordingVideo" : "Start Recording Video",
"Begin" : "Begin"
},
"Identification": {
"EnterIdentificationNumber": "Enter Identification Number",
"ClickImage": "Click Image",
"FrontOfCard": "Front of Card",
"BackOfCard": "Back of Card"
},
"Screens": {
"ThankYou": "Thank You",
"PleaseWaitWhileWeSubmitYourVideoVerification": "Please wait while we submit your video verification",
"VideoInstructions": "Video Instructions",
"Identification" : "Identification",
"CaptureCard" : "Capture Card",
"VerifyVideo": "Verify Video",
"Next": "Next",
"Done": "Done",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { SendVideoStackParams, Screens } from '../types/navigators'
import SubmitVideo from '../screens/SubmitVideo'
import CaptureVideo from '../screens/CaptureVideo'
import VideoInstructions from '../screens/VideoInstructions'
import Identification from '../screens/Identification'
import CaptureCard from '../screens/CaptureCard'

const SendVideoStack: React.FC = () => {
const Stack = createStackNavigator<SendVideoStackParams>()
Expand Down Expand Up @@ -47,6 +49,24 @@ const SendVideoStack: React.FC = () => {
header: () => null,
})}
/>
<Stack.Screen
name={Screens.Identification}
component={Identification}
options={() => ({
title: t('SendVideo.Screens.Identification'),
headerRight: () => null,
})}
/>
<Stack.Screen
name={Screens.CaptureCard}
component={CaptureCard}
options={() => ({
title: t('SendVideo.Screens.CaptureCard'),
headerRight: () => null,
headerLeft: () => null,
header: () => null,
})}
/>
</Stack.Navigator>
)
}
Expand Down
147 changes: 147 additions & 0 deletions packages/legacy/core/App/modules/send-video/screens/CaptureCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import { useNavigation } from '@react-navigation/core'
import { StackScreenProps } from '@react-navigation/stack'
import React, { useEffect, useRef } from 'react'
import { useTranslation } from 'react-i18next'
import { StyleSheet, View } from 'react-native'

import { Camera, useCameraDevice } from 'react-native-vision-camera'

import Button, { ButtonType } from '../../../components/buttons/Button'
import Text from '../../../components/texts/Text'
import Title from '../../../components/texts/Title'
import { Screens, SendVideoStackParams } from '../types/navigators'
import Toast from 'react-native-toast-message'

const CaptureCard: React.FC<StackScreenProps<SendVideoStackParams, Screens.CaptureCard>> = ({ route }) => {
const navigation = useNavigation()
const { t } = useTranslation()
const camera = useRef<Camera | null>(null)
const device = useCameraDevice('back')
const type = route?.params?.type
const onImageCaptured = route?.params?.onImageCaptured

const capturePhoto = async () => {
try {
const capturedImage = await camera.current?.takePhoto()

if (capturedImage?.path && onImageCaptured) {
onImageCaptured(capturedImage?.path)
}

navigation.goBack()
} catch (error) {
Toast.show({
type: 'error',
autoHide: true,
text1: 'Error',
})
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
},
cameraWrapper: {
flex: 7,
},
subContainer: {
alignItems: 'center',
justifyContent: 'flex-start',
flex: 3,
},
actionContainer: {
justifyContent: 'center',
alignItems: 'center',
position: 'absolute',
bottom: '3%',
width: '100%',
},
sectionTitle: {
fontSize: 24,
fontFamily: 'Lato',
fontWeight: '700',
color: '#fff',
marginBottom: 8,
marginTop: 10,
},
ovalContainer: {
position: 'absolute',
left: '3%',
right: '3%',
borderWidth: 5,
height: '35%',
width: '94%',
top: '20%',
borderColor: '#32674e',
},
overlay: {
...StyleSheet.absoluteFillObject,

position: 'absolute',
left: '15%',
right: 0,
height: '45%',
width: '70%',
top: '20%',
borderRadius: 100,
},
buttonContainer: {
width: '90%',
},
step: {
fontSize: 16,
fontFamily: 'Lato',
color: '#F2F2F2',
fontWeight: '600',
opacity: 0.8,
marginTop: '8%',
},
})

useEffect(() => {
// Set the callback dynamically using navigation.setOptions
navigation.setOptions({
onImageCaptured: route.params?.onImageCaptured, // Safely access the callback
})
}, [route.params?.onImageCaptured, navigation])

return (
<View style={styles.container}>
<View style={styles.cameraWrapper}>
{device && (
<Camera
ref={camera}
style={StyleSheet.absoluteFill}
device={device}
isActive={true}
video={false}
photo={true}
torch={'off'}
/>
)}
</View>
<View style={styles.subContainer}>
<Text style={styles.step}> {type === 'front' ? 'Step 1' : 'Step 2'}</Text>
<Title style={styles.sectionTitle}>
{type === 'front' ? t('SendVideo.Identification.FrontOfCard') : t('SendVideo.Identification.BackOfCard')}
</Title>
</View>

<View style={styles.ovalContainer} />
<View style={styles.overlay} />
<View style={styles.actionContainer}>
<View style={styles.buttonContainer}>
<Button
title={t('SendVideo.Screens.Next')}
accessibilityLabel={'secondary'}
buttonType={ButtonType.Critical}
onPress={capturePhoto}
/>
</View>
</View>
</View>
)
}

export default CaptureCard
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const CaptureVideo: React.FC<StackScreenProps<SendVideoStackParams, Screens.Capt
])

const session = route.params.session
const idNumber = route.params.idNumber
const cardFrontImage = route.params.cardFrontImage
const cardBackImage = route.params.cardBackImage
const prompts = session.prompts.map((prompt) => prompt.text)

const styles = StyleSheet.create({
Expand Down Expand Up @@ -128,6 +131,13 @@ const CaptureVideo: React.FC<StackScreenProps<SendVideoStackParams, Screens.Capt
return videoName
}

const createImageName = () => {
const timestamp = new Date().getTime()
const imageName = `${timestamp}.png`

return imageName
}

const submitVideo = async (path: string) => {
try {
setApiCall(true)
Expand All @@ -143,6 +153,17 @@ const CaptureVideo: React.FC<StackScreenProps<SendVideoStackParams, Screens.Capt
name: createFileName(),
})
formData.append('sessionId', session.id)
formData.append('idNumber', idNumber)
formData.append('front_image', {
uri: cardFrontImage,
type: 'image/png',
name: createImageName(),
})
formData.append('back_image', {
uri: cardBackImage,
type: 'image/png',
name: createImageName(),
})

const response = await axios.post(`${Config.VIDEO_VERIFIER_HOST}/api/v1/submissions`, formData, {
headers: {
Expand Down
Loading

0 comments on commit 5b8f9fe

Please sign in to comment.