Tp 23331 | vkyc added (#220)

* TP-23331 | vkyc

* TP-23331 | vkyc changes

* TP-23331 | removed redundant changes

* TP-23331 | removed ^

* TP-23331 | Vkyc video added
This commit is contained in:
Aman Chaturvedi
2023-04-07 20:07:16 +05:30
committed by GitHub Enterprise
parent da59033129
commit 3acf19dc4c
4 changed files with 76 additions and 39 deletions

View File

@@ -190,3 +190,12 @@ export const getDocumentList = (caseDetails: CaseDetail) => {
export const findDocumentByDocumentType = (documentList: IDocument[] = [], documentType: DOCUMENT_TYPE) => {
return documentList?.find((documentItem) => documentItem.type === documentType);
}
export const checkS3Url = async(url: string): Promise<boolean> => {
try {
const response = await fetch(url, { method: "HEAD" });
return response.ok;
} catch (error) {
return false;
}
}

View File

@@ -1,4 +1,10 @@
import { Pressable, ScrollView, StyleSheet, View } from 'react-native';
import {
ActivityIndicator,
Pressable,
ScrollView,
StyleSheet,
View,
} from 'react-native';
import React, { useEffect, useState } from 'react';
import { SafeAreaView } from 'react-native-safe-area-context';
import { GenericStyles, SCREEN_WIDTH } from '../../../RN-UI-LIB/src/styles';
@@ -12,6 +18,7 @@ import useIsOnline from '../../hooks/useIsOnline';
import useFetchDocument from '../../hooks/useFetchDocument';
import {
RELATIVE_PATH_PREFIX,
checkS3Url,
findDocumentByDocumentType,
getDocumentList,
} from '../../components/utlis/commonFunctions';
@@ -20,6 +27,7 @@ import {
navigateToScreen,
} from '../../components/utlis/navigationUtlis';
import Text from '../../../RN-UI-LIB/src/components/Text';
import { ISignedRequest, getSignedApi } from '../../action/dataActions';
interface ICustomerProfile {
route: {
@@ -43,22 +51,47 @@ const CustomerProfile: React.FC<ICustomerProfile> = props => {
false,
);
const [vkycUri, setVkycUri] = useState<string>();
const [showVkyc, setShowVkyc] = useState<boolean>(false);
const updateVkycVideo = (uri: string) => {
setVkycUri(uri);
}
};
// useEffect(() => {
// if (caseDetail) {
// const docList: IDocument[] = getDocumentList(caseDetail) || [];
// const vkycDoc = findDocumentByDocumentType(
// docList,
// DOCUMENT_TYPE.VKYC_VIDEO,
// );
// const vkycUri = "https://s3.ap-south-1.amazonaws.com/navi-382c5a1109445386b9a74e2da9fa1f64/prod/833ce1b1-7b2a-4f09-bef9-245dabdfdc56.?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEFsaCXVzLWVhc3QtMSJGMEQCIFdbKpbj40xxvB4bNb9ipRRFpkieWMBs4cx6GqSKRJTNAiAf7FxoPIbdGvAxVchkFGXpmXQTm9FANAlRj%2BkETzywtyqyAghDEAIaDDU3MTMxNTA3Njc2MiIMSlrGCUlqie8RAr4qKo8CJ526pizufA5s3z14P3zCAuBT%2B5lQAXhjKaEes5V%2FkygPQKvwG%2BoIUeuaw4ixiigiSujOX2UeNIPUrdoHkVU0rwN6HDcqTehQZdVnf0KpExAk6ccD47NC6iuYAAZTRDLhBdMrclVv3PlUvXe4oCGbeQ2JAjaBrUyErF5pzk%2Bh25GGewFGLAHvjtaVqZwaVHUvZKKNZL55PPcWJi9RKes%2BrtMFNDhzfbMCe6Fgja3WsGma8fbjhtr2A12GWraVyUOebnie3ji75SWgPPHO7LL1o6LNx%2B%2BfN5ZU%2Fo1UrYluI58IMkOCMpA6hxs4IR5KUZoF6fcU3iRtCsYKabsRdWB3oIsxIgYD2wn4NwDAFPp1XzDS1b%2BhBjqeATsEx5puy76ZdisBqqFG9agdo0DNdOgJ%2B4she4HIQg2O4bl%2B%2Bu0hsfxE%2BFi6bvI6wJ9zA4sBqPMYboi3TZ%2Bxcayq5EWQtOM9AZMui0adAHwdIoM%2FfhrtyguTJDegUDZ8ISysqcwN8V83DIujB1py28RGVe5Zgajm2pczIT%2F4cnKGaOdZd7l1vG1%2FxjC9pdBDcHiZF1a5NiBq9zHezx7k&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230407T101051Z&X-Amz-SignedHeaders=host&X-Amz-Expires=43200&X-Amz-Credential=ASIAYKBIIH2NKNINJJLC%2F20230407%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Signature=20eca56f41fd4823f43278e1f468cc6571d87534ffe5ddec325fdf362a42fc1c";
// setVkycUri(vkycUri);
// }
// }, [caseDetail]);
useEffect(() => {
if (caseDetail) {
const docList: IDocument[] = getDocumentList(caseDetail) || [];
const vkycDoc = findDocumentByDocumentType(
docList,
DOCUMENT_TYPE.VKYC_VIDEO,
);
if (!vkycDoc?.referenceId) {
return;
}
setShowVkyc(true);
const vkycUri = vkycDoc?.uri;
async function checkUrl(url: string) {
const result = await checkS3Url(url);
if (result) {
setVkycUri(url);
} else {
const imageReferenceId = vkycDoc?.referenceId!!;
const signedRequestPayload: ISignedRequest = [
{
documentReferenceId: imageReferenceId,
caseId: caseDetail.id,
caseType: caseDetail.caseType,
},
];
const response = await getSignedApi(signedRequestPayload);
const url = response?.imageUrl || '';
setVkycUri(url);
}
}
if (vkycUri) {
checkUrl(vkycUri);
}
}
}, [caseDetail]);
const getImageURI = () => {
if (!isOnline) {
@@ -83,7 +116,10 @@ const CustomerProfile: React.FC<ICustomerProfile> = props => {
};
const handleVkycPress = () => {
navigateToScreen('customerProfileFull', { vkycUri, setVkycUri: updateVkycVideo });
navigateToScreen('vkycFull', {
vkycUri,
setVkycUri: updateVkycVideo,
});
};
const imageUri = getImageURI();
@@ -123,14 +159,22 @@ const CustomerProfile: React.FC<ICustomerProfile> = props => {
) : null}
</View>
</View>
{/* <View style={styles.vkyc}>
<Text bold dark>
VKYC video
</Text>
<Pressable onPress={handleVkycPress}>
<Text style={styles.openVideoTxt}>Open video</Text>
</Pressable>
</View> */}
{showVkyc ? (
<View style={styles.vkyc}>
<Text bold dark>
VKYC video
</Text>
{vkycUri ? (
<Pressable onPress={handleVkycPress}>
<Text style={styles.openVideoTxt}>
Open video
</Text>
</Pressable>
) : (
<ActivityIndicator color={COLORS.BASE.BLUE} />
)}
</View>
) : null}
{/* <Accordion title="VKYC Video" content={<VKYCVideo />} /> */}
</ScrollView>
</SafeAreaView>

View File

@@ -56,7 +56,6 @@ const UserDetailsSection: React.FC<IUserDetailsSection> = props => {
}
// setOpenImage(prev => !prev);
navigateToScreen('customerProfile', {caseDetail});
// navigateToScreen('customerProfileFull', {caseDetail});
}, []);
useEffect(() => {

View File

@@ -28,21 +28,6 @@ const VKYCFullScreen: React.FC<ICustomerProfile> = props => {
},
} = props;
const handleError = async() => {
const documentList = getDocumentList(caseDetail)
const imageReferenceId = findDocumentByDocumentType(documentList, DOCUMENT_TYPE.VKYC_VIDEO)?.referenceId || '';
const signedRequestPayload: ISignedRequest = [
{
documentReferenceId: imageReferenceId,
caseId: caseDetail.id,
caseType: caseDetail.caseType,
},
];
const response = await getSignedApi(signedRequestPayload);
const url = response?.imageUrl || '';
setVkycUri(url);
};
return (
<View style={GenericStyles.fill}>
<NavigationHeader onBack={() => goBack()} title="VKYC video" />
@@ -53,7 +38,7 @@ const VKYCFullScreen: React.FC<ICustomerProfile> = props => {
}}
resizeMode="cover"
style={styles.video}
onError={handleError}
autoplay
/>
</View>
</View>