import {Alert, Image, Linking, Pressable, Text, View} from 'react-native'; import React, {useCallback, useEffect, useState} from 'react'; import {styles} from './styles'; const IDCARD = '../../assets/idcard.png'; const SELFIE = '../../assets/selfieimg.png'; const IDCARDBACK = '../../assets/backid.png'; const DLCARD = '../../assets/dl.png'; const Passport = '../../assets/passport.png'; import {CheckBox} from '@rneui/themed'; import {globalStyles} from '../../../globalStyles'; import {getBranding} from '../../branding'; import {useMyStepsVerification} from '../../provider/verification.context'; /** * A component for displaying the required documents for the KYC process and allowing the user to confirm their consent to the terms of use. * * @param {Object} props - The component props. * @param {boolean} props.isChecked - A boolean indicating whether the user has confirmed their consent. * @param {Function} props.handleCheckbox - A function that handles changes to the consent checkbox. * @param {string} props.selectedOption - The selected KYC document type. * @returns {JSX.Element} - The rendered component as a JSX element. */ type RequirementsDocumentsProps = { isChecked: boolean; handleCheckbox: () => void; selectedOption: string[]; consenttermofuseLink?: string; }; type DocStep = { type: 'doc_front' | 'doc_back' | 'doc_passport' | 'selfie'; docType?: string; label: string; }; const RequirementsDocuments = ({ isChecked, handleCheckbox, selectedOption, consenttermofuseLink, }: RequirementsDocumentsProps) => { const { t, isRTL } = useMyStepsVerification(); const [documentSteps, setDocumentSteps] = useState([]); useEffect(() => { const steps: DocStep[] = []; selectedOption.forEach(item => { const docLabel = t.docLabels[item] || item; if (item === 'Passport') { steps.push({ type: 'doc_passport', docType: item, label: t.pictureFirstPage.replace('{doc}', docLabel) }); } else { steps.push({ type: 'doc_front', docType: item, label: t.pictureFront.replace('{doc}', docLabel) }); steps.push({ type: 'doc_back', docType: item, label: t.pictureBack.replace('{doc}', docLabel) }); } }); steps.push({ type: 'selfie', label: t.takeSelfie }); setDocumentSteps(steps); }, [selectedOption, t]); const handleClick = async () => { if (consenttermofuseLink) { const supported = await Linking.canOpenURL(consenttermofuseLink); if (supported) { await Linking.openURL(consenttermofuseLink); } else { Alert.alert(`Don't know how to open this URL: ${consenttermofuseLink}`); } } }; return ( <> {documentSteps.map((item, index) => { return ( {item.type === 'selfie' ? ( ) : ( )} {item.label} ); })} {consenttermofuseLink && ( {consenttermofuseLink && ( {t.termsAndConditions} )}{' '} {t.termsAgreement} )} {!consenttermofuseLink && ( {t.readSteps} )} ); }; export default RequirementsDocuments;