diff options
author | Blaster4385 <[email protected]> | 2022-08-18 20:28:10 +0530 |
---|---|---|
committer | Blaster4385 <[email protected]> | 2022-08-18 20:28:10 +0530 |
commit | f2947397f4e99911fe0f8b38c1b1a0c2661dd3e2 (patch) | |
tree | 7ac5376fa9cdcc5a1a0d780eac8ba556bb5bfc3f /client/src/pages/Enrollment/PhotoCapture/PhotoCapture.jsx | |
parent | 6c924aef55707885cbbf9af8348564526ac146ee (diff) |
Switch to context api for enrollment form
Diffstat (limited to 'client/src/pages/Enrollment/PhotoCapture/PhotoCapture.jsx')
-rw-r--r-- | client/src/pages/Enrollment/PhotoCapture/PhotoCapture.jsx | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/client/src/pages/Enrollment/PhotoCapture/PhotoCapture.jsx b/client/src/pages/Enrollment/PhotoCapture/PhotoCapture.jsx index a54085f..17fe3df 100644 --- a/client/src/pages/Enrollment/PhotoCapture/PhotoCapture.jsx +++ b/client/src/pages/Enrollment/PhotoCapture/PhotoCapture.jsx @@ -7,22 +7,23 @@ import SubmitButton from '../../../components/SubmitButton/SubmitButton' import styles from './PhotoCapture.module.css' import { Button, Grid, Typography } from '@mui/material' import { t } from 'i18next' +import { userContext } from '../../../context/User' -const PhotoCapture = ({ formData, setFormData }) => { +const PhotoCapture = () => { const navigate = useNavigate() - + const { userData, setUserData } = userContext() const webcamRef = React.useRef(null) const capture = React.useCallback(() => { const imageSrc = webcamRef.current.getScreenshot() - setFormData({ ...formData, photo: imageSrc }) + setUserData({ ...userData, photo: imageSrc }) }) return ( <> <Header subheading={t('ENROLLMENT')} /> <div className={styles.card__container}> - {formData.photo === '' ? ( + {!userData.photo ? ( <Webcam audio={false} height={400} @@ -36,7 +37,7 @@ const PhotoCapture = ({ formData, setFormData }) => { }} /> ) : ( - <img src={formData.photo} /> + <img src={userData.photo} /> )} </div> <Grid container columnSpacing={10} justifyContent="center"> @@ -62,7 +63,7 @@ const PhotoCapture = ({ formData, setFormData }) => { variant="contained" onClick={(e) => { e.preventDefault() - setFormData({ ...formData, photo: '' }) + setUserData({ ...userData, photo: '' }) }} > {t('RESET')} |