Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import AnalyticsContext from '../context/analytics';
import SelfieCaptureContext from '../context/selfie-capture';

interface DocumentCaptureWarningProps {
isResultCodeInvalid: boolean;
isFailedDocType: boolean;
isFailedResult: boolean;
isFailedSelfie: boolean;
Expand All @@ -24,12 +25,14 @@ interface DocumentCaptureWarningProps {
const DISPLAY_ATTEMPTS = 3;

type GetHeadingArguments = {
isResultCodeInvalid: boolean;
isFailedDocType: boolean;
isFailedSelfie: boolean;
isFailedSelfieLivenessOrQuality: boolean;
t: typeof I18n.prototype.t;
};
function getHeading({
isResultCodeInvalid,
isFailedDocType,
isFailedSelfie,
isFailedSelfieLivenessOrQuality,
Expand All @@ -38,6 +41,9 @@ function getHeading({
if (isFailedDocType) {
return t('errors.doc_auth.doc_type_not_supported_heading');
}
if (isResultCodeInvalid) {
return t('errors.doc_auth.rate_limited_heading');
}
if (isFailedSelfieLivenessOrQuality) {
return t('errors.doc_auth.selfie_not_live_or_poor_quality_heading');
}
Expand Down Expand Up @@ -67,6 +73,7 @@ function getSubheading({
}

function DocumentCaptureWarning({
isResultCodeInvalid,
isFailedDocType,
isFailedResult,
isFailedSelfie,
Expand All @@ -83,6 +90,7 @@ function DocumentCaptureWarning({

const nonIppOrFailedResult = !inPersonURL || isFailedResult;
const heading = getHeading({
isResultCodeInvalid,
isFailedDocType,
isFailedSelfie,
isFailedSelfieLivenessOrQuality,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ function DocumentCapture({ onStepChange = () => {} }: DocumentCaptureProps) {
submissionError instanceof UploadFormEntriesError
? withProps({
remainingSubmitAttempts: submissionError.remainingSubmitAttempts,
isResultCodeInvalid: submissionError.isResultCodeInvalid,
isFailedResult: submissionError.isFailedResult,
isFailedSelfie: submissionError.isFailedSelfie,
isFailedDocType: submissionError.isFailedDocType,
isFailedSelfie: submissionError.isFailedSelfie,
isFailedSelfieLivenessOrQuality:
submissionError.selfieNotLive || submissionError.selfieNotGoodQuality,
captureHints: submissionError.hints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface ReviewIssuesStepValue {

interface ReviewIssuesStepProps extends FormStepComponentProps<ReviewIssuesStepValue> {
remainingSubmitAttempts?: number;
isResultCodeInvalid?: boolean;
isFailedResult?: boolean;
isFailedSelfie?: boolean;
isFailedDocType?: boolean;
Expand All @@ -56,6 +57,7 @@ function ReviewIssuesStep({
registerField = () => undefined,
toPreviousStep = () => undefined,
remainingSubmitAttempts = Infinity,
isResultCodeInvalid = false,
isFailedResult = false,
isFailedDocType = false,
isFailedSelfie = false,
Expand Down Expand Up @@ -124,6 +126,7 @@ function ReviewIssuesStep({
// Warning(try again screen)
return (
<DocumentCaptureWarning
isResultCodeInvalid={isResultCodeInvalid}
isFailedDocType={isFailedDocType}
isFailedResult={isFailedResult}
isFailedSelfie={isFailedSelfie}
Expand Down
5 changes: 5 additions & 0 deletions app/javascript/packages/document-capture/context/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ export interface UploadErrorResponse {
*/
ocr_pii?: PII;

/**
* Whether the unsuccessful result was any result other than passed or attention with barcode.
*/
result_code_invalid: boolean;

/**
* Whether the unsuccessful result was the failure type.
*/
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/packages/document-capture/services/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export class UploadFormEntriesError extends FormError {

remainingSubmitAttempts = Infinity;

isResultCodeInvalid = false;

isFailedResult = false;

isFailedDocType = false;
Expand Down Expand Up @@ -126,6 +128,8 @@ const upload: UploadImplementation = async function (payload, { method = 'POST',
error.hints = result.hints;
}

error.isResultCodeInvalid = result.result_code_invalid;

error.isFailedResult = !!result.result_failed;

error.isFailedSelfie = result.selfie_status === 'fail';
Expand Down
6 changes: 6 additions & 0 deletions app/presenters/image_upload_response_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def as_json(*)
json[:hints] = true if show_hints?
json[:ocr_pii] = ocr_pii
json[:result_failed] = doc_auth_result_failed?
json[:result_code_invalid] = result_code_invalid?
json[:doc_type_supported] = doc_type_supported?
json[:selfie_status] = selfie_status if show_selfie_failures?
json[:selfie_live] = selfie_live? if show_selfie_failures?
Expand All @@ -67,6 +68,11 @@ def url_options

private

def result_code_invalid?
@form_response.to_h[:doc_auth_result] != DocAuth::LexisNexis::ResultCodes::PASSED.name &&
!attention_with_barcode?
end

def doc_auth_result_failed?
@form_response.to_h[:doc_auth_result] == DocAuth::LexisNexis::ResultCodes::FAILED.name
end
Expand Down
Loading