From 74bb2fb45f2565251ab96d274016844b46d53b5a Mon Sep 17 00:00:00 2001 From: Alie Langston Date: Mon, 24 Aug 2020 12:56:51 -0400 Subject: [PATCH] added option for image upload added friction to allowing users to upload id image only shows picture within component if it has been uploaded, not if it was captured through the webcam --- src/id-verification/CameraHelpWithUpload.jsx | 53 +++++++++++++++++++ .../IdVerification.messages.js | 5 ++ src/id-verification/ImageFileUpload.jsx | 1 + src/id-verification/panels/SummaryPanel.jsx | 2 + .../panels/TakeIdPhotoPanel.jsx | 32 +++-------- .../tests/panels/SummaryPanel.test.jsx | 8 +++ 6 files changed, 76 insertions(+), 25 deletions(-) create mode 100644 src/id-verification/CameraHelpWithUpload.jsx diff --git a/src/id-verification/CameraHelpWithUpload.jsx b/src/id-verification/CameraHelpWithUpload.jsx new file mode 100644 index 0000000..ec46a36 --- /dev/null +++ b/src/id-verification/CameraHelpWithUpload.jsx @@ -0,0 +1,53 @@ +import React, { useState, useContext } from 'react'; +import PropTypes from 'prop-types'; +import { Collapsible } from '@edx/paragon'; +import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { sendTrackEvent } from '@edx/frontend-platform/analytics'; + +import messages from './IdVerification.messages'; +import ImageFileUpload from './ImageFileUpload'; +import { IdVerificationContext } from './IdVerificationContext'; +import ImagePreview from './ImagePreview'; + +function CameraHelpWithUpload(props) { + const { setIdPhotoFile, idPhotoFile, userId } = useContext(IdVerificationContext); + const [hasUploadedImage, setHasUploadedImage] = useState(false); + + function setAndTrackIdPhotoFile(image) { + sendTrackEvent('edx.id_verification.upload_id', { + category: 'id_verification', + user_id: userId, + }); + setHasUploadedImage(true); + setIdPhotoFile(image); + } + + return ( +
+ + {idPhotoFile && hasUploadedImage && } +

+ {props.intl.formatMessage(messages['id.verification.id.photo.instructions.upload'])} +

+ +
+
+ ); +} + +CameraHelpWithUpload.propTypes = { + intl: intlShape.isRequired, + isOpen: PropTypes.bool, +}; + +CameraHelpWithUpload.defaultProps = { + isOpen: false, +}; + +export default injectIntl(CameraHelpWithUpload); diff --git a/src/id-verification/IdVerification.messages.js b/src/id-verification/IdVerification.messages.js index b9db0fe..3958fd7 100644 --- a/src/id-verification/IdVerification.messages.js +++ b/src/id-verification/IdVerification.messages.js @@ -341,6 +341,11 @@ const messages = defineMessages({ defaultMessage: 'If you require assistance with taking a photo for submission, contact edX support for additional suggestions.', description: 'Confirming what to do if the user has difficult holding their head relative to the camera.', }, + 'id.verification.id.photo.unclear.question': { + id: 'id.verification.id.photo.unclear.question', + defaultMessage: 'Is your ID image not clear or too blurry?', + description: 'Question on what to do if the user\'s ID image is unclear', + }, 'id.verification.id.tips.title': { id: 'id.verification.id.tips.title', defaultMessage: 'Helpful ID Tips', diff --git a/src/id-verification/ImageFileUpload.jsx b/src/id-verification/ImageFileUpload.jsx index 18593d8..9d52ea1 100644 --- a/src/id-verification/ImageFileUpload.jsx +++ b/src/id-verification/ImageFileUpload.jsx @@ -17,6 +17,7 @@ export default function ImageFileUpload({ onFileChange }) { ); diff --git a/src/id-verification/panels/SummaryPanel.jsx b/src/id-verification/panels/SummaryPanel.jsx index 1aced6d..99dd110 100644 --- a/src/id-verification/panels/SummaryPanel.jsx +++ b/src/id-verification/panels/SummaryPanel.jsx @@ -11,6 +11,7 @@ import { IdVerificationContext } from '../IdVerificationContext'; import ImagePreview from '../ImagePreview'; import messages from '../IdVerification.messages'; +import CameraHelpWithUpload from '../CameraHelpWithUpload'; function SummaryPanel(props) { const panelSlug = 'summary'; @@ -101,6 +102,7 @@ function SummaryPanel(props) { +