Skip to content
Merged
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
@@ -1,16 +1,11 @@
import { useContext } from 'react';
import { Button, StatusPage } from '@18f/identity-components';
import { SpinnerButton } from '@18f/identity-spinner-button';
import { t } from '@18f/identity-i18n';
import { trackEvent } from '@18f/identity-analytics';
import { removeUnloadProtection } from '@18f/identity-url';
import UploadContext from '../context/upload';
import { toFormData } from '../services/upload';
import type { PII } from '../services/upload';
import DocumentCaptureTroubleshootingOptions from './document-capture-troubleshooting-options';

const DOCUMENT_CAPTURE_ERRORS_API_URL = '/api/verify/v2/document_capture_errors';

interface BarcodeAttentionWarningProps {
/**
* Callback to trigger when user opts to try to take new photos rather than continue to next step.
Expand All @@ -24,16 +19,8 @@ interface BarcodeAttentionWarningProps {
}

function BarcodeAttentionWarning({ onDismiss, pii }: BarcodeAttentionWarningProps) {
const { formData } = useContext(UploadContext);

async function skipAttention() {
await Promise.all([
trackEvent('IdV: barcode warning continue clicked'),
window.fetch(DOCUMENT_CAPTURE_ERRORS_API_URL, {
method: 'DELETE',
body: toFormData({ document_capture_session_uuid: formData.document_capture_session_uuid }),
}),
]);
function skipAttention() {
trackEvent('IdV: barcode warning continue clicked');
Copy link
Contributor Author

@matthinz matthinz Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(trackEvent is no longer async, so this whole function can be made non-async)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also make the SpinnerButton that calls it a regular Button now as well, @matthinz ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, I'll follow up with a new PR

removeUnloadProtection();
const form = document.querySelector<HTMLFormElement>('.js-document-capture-form');
form?.submit();
Expand Down