From 6b85ebee8986b982e05d49c8f1a326deb3e08bae Mon Sep 17 00:00:00 2001 From: rohan09-raj Date: Thu, 18 Aug 2022 11:43:03 +0530 Subject: Fixed components --- .../Update/DocumentScanner/DocumentScanner.jsx | 206 +++++++++++++++++---- 1 file changed, 167 insertions(+), 39 deletions(-) (limited to 'client/src/pages/Update/DocumentScanner') diff --git a/client/src/pages/Update/DocumentScanner/DocumentScanner.jsx b/client/src/pages/Update/DocumentScanner/DocumentScanner.jsx index ae8846c..14fb769 100644 --- a/client/src/pages/Update/DocumentScanner/DocumentScanner.jsx +++ b/client/src/pages/Update/DocumentScanner/DocumentScanner.jsx @@ -1,52 +1,180 @@ -import React from 'react' +/* eslint-disable multiline-ternary */ +import React, { useState } from 'react' +import Webcam from 'react-webcam' import Header from '../../../components/Header/Header' -import CardScanner from '../../../components/Card/CardScanner' import styles from './DocumentScanner.module.css' -import { Button, Grid, Typography } from '@mui/material' +import { + Button, + Grid, + Typography, + StepLabel, + Step, + Stepper, + Box +} from '@mui/material' import SubmitButton from '../../../components/SubmitButton/SubmitButton' import { useTranslation } from 'react-i18next' +import { userContext } from '../../../context/User' const DocumentScanner = () => { + const { userData, setUserData } = userContext() const { t } = useTranslation() + const steps = [ + t('PROOF_OF_IDENTITY'), + t('PROOF_OF_ADDRESS'), + t('PROOF_OF_DOB') + ] + const [documents, setDocuments] = useState({ POI: '', POA: '', DOB: '' }) + const [activeStep, setActiveStep] = React.useState(0) + + const [doccu] = useState({ POI: '', POA: '', DOB: '' }) + + console.log(documents) + + const webcamRef = React.useRef(null) + + const capture = React.useCallback((doc) => { + const imageSrc = webcamRef.current.getScreenshot() + doccu[doc] = imageSrc + setDocuments({ + ...documents, + POI: doccu.POI, + POA: doccu.POA, + DOB: doccu.DOB + }) + }) + + const handleNext = () => { + if (activeStep === steps.length - 1) { + setUserData({ ...userData, documents: documents }) + } + setActiveStep((prevActiveStep) => prevActiveStep + 1) + } + + const handleBack = () => { + setActiveStep((prevActiveStep) => prevActiveStep - 1) + } + + const WebcamComponent = ({ doc }) => { + return ( + <> +
+ {documents[doc] === '' ? ( + + ) : ( + + )} +
+ + + + + + + + +

+
+ + + {t('KINDLY_CLICK_THE_PICTURE_OF_YOUR_DOCUMENTS')} + + +
+ + ) + } + return ( <> -
-
- -
- - - - - - - - -

-
- - - {t('KINDLY_CLICK_THE_PICTURE_OF_YOUR_DOCUMENTS')} - - -
+
+ + + {steps.map((label, index) => { + const stepProps = {} + const labelProps = {} + return ( + + {label} + + ) + })} + + {activeStep === steps.length ? ( + + + {t('ALL_STEPS_COMPLETED')} + + + + + + ) : ( + + {activeStep === 0 ? ( + + ) : activeStep === 1 ? ( + + ) : ( + activeStep === 2 && + )} + + + + + + + )} + ) } -- cgit