Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,19 @@ import AnalyticsContext from '../context/analytics';
import Submission from './submission';
import SubmissionStatus from './submission-status';
import { RetrySubmissionError } from './submission-complete';
import { BackgroundEncryptedUploadError } from '../higher-order/with-background-encrypted-upload';
import SuspenseErrorBoundary from './suspense-error-boundary';
import SubmissionInterstitial from './submission-interstitial';
import withProps from '../higher-order/with-props';
import { InPersonContext } from '../context';

/**
* Returns a new object with specified keys removed.
*
* @param object Original object.
* @param keys Keys to remove.
*
* @return Object with keys removed.
*/
export const except = <T extends Record<string, any>>(object: T, ...keys: string[]): Partial<T> =>
Object.entries(object).reduce((result, [key, value]) => {
if (!keys.includes(key)) {
result[key] = value;
}

return result;
}, {});

interface DocumentCaptureProps {
/**
* Whether submission should poll for async response.
*/
isAsyncForm?: boolean;

/**
* Callback triggered on step change.
*/
onStepChange?: () => void;
}

function DocumentCapture({ isAsyncForm = false, onStepChange = () => {} }: DocumentCaptureProps) {
function DocumentCapture({ onStepChange = () => {} }: DocumentCaptureProps) {
const [formValues, setFormValues] = useState<Record<string, any> | null>(null);
const [submissionError, setSubmissionError] = useState<Error | undefined>(undefined);
const [stepName, setStepName] = useState<string | undefined>(undefined);
Expand Down Expand Up @@ -82,10 +59,10 @@ function DocumentCapture({ isAsyncForm = false, onStepChange = () => {} }: Docum
const submissionFormValues = useMemo(
() =>
formValues && {
...(isAsyncForm ? except(formValues, 'front', 'back') : formValues),
...formValues,
flow_path: flowPath,
},
[isAsyncForm, formValues, flowPath],
[formValues, flowPath],
);

let initialActiveErrors;
Expand All @@ -94,17 +71,11 @@ function DocumentCapture({ isAsyncForm = false, onStepChange = () => {} }: Docum
field: error.field,
error,
}));
} else if (submissionError instanceof BackgroundEncryptedUploadError) {
initialActiveErrors = [{ field: submissionError.baseField, error: submissionError }];
}

let initialValues;
if (submissionError && formValues) {
initialValues = formValues;

if (submissionError instanceof BackgroundEncryptedUploadError) {
initialValues = except(initialValues, ...submissionError.fields);
}
}

const inPersonSteps: FormStep[] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import HybridDocCaptureWarning from './hybrid-doc-capture-warning';
import DocumentSideAcuantCapture from './document-side-acuant-capture';
import DeviceContext from '../context/device';
import UploadContext from '../context/upload';
import withBackgroundEncryptedUpload from '../higher-order/with-background-encrypted-upload';
import CaptureTroubleshooting from './capture-troubleshooting';
import DocumentCaptureTroubleshootingOptions from './document-capture-troubleshooting-options';

Expand Down Expand Up @@ -76,4 +75,4 @@ function DocumentsStep({
);
}

export default withBackgroundEncryptedUpload(DocumentsStep);
export default DocumentsStep;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { PageHeading } from '@18f/identity-components';
import { Cancel } from '@18f/identity-verify-flow';
import type { FormStepComponentProps } from '@18f/identity-form-steps';
import DocumentSideAcuantCapture from './document-side-acuant-capture';
import withBackgroundEncryptedUpload from '../higher-order/with-background-encrypted-upload';
import type { PII } from '../services/upload';
import DocumentCaptureTroubleshootingOptions from './document-capture-troubleshooting-options';
import Warning from './warning';
Expand Down Expand Up @@ -46,11 +45,11 @@ interface ReviewIssuesStepValue {
}

interface ReviewIssuesStepProps extends FormStepComponentProps<ReviewIssuesStepValue> {
remainingAttempts: number;
remainingAttempts?: number;

isFailedResult: boolean;
isFailedResult?: boolean;

captureHints: boolean;
captureHints?: boolean;

pii?: PII;
}
Expand Down Expand Up @@ -291,4 +290,4 @@ function ReviewIssuesStep({
);
}

export default withBackgroundEncryptedUpload(ReviewIssuesStep);
export default ReviewIssuesStep;
16 changes: 0 additions & 16 deletions app/javascript/packages/document-capture/context/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ const UploadContext = createContext({
getStatus: () => Promise.resolve({} as UploadSuccessResponse),
statusPollInterval: undefined as number | undefined,
isMockClient: false,
backgroundUploadURLs: {} as Record<string, string>,
backgroundUploadEncryptKey: undefined as CryptoKey | undefined,
flowPath: 'standard' as FlowPath,
formData: {} as Record<string, any>,
});
Expand Down Expand Up @@ -111,16 +109,6 @@ interface UploadContextProviderProps {
*/
isMockClient?: boolean;

/**
* URLs to which payload values corresponding to key should be uploaded as soon as possible.
*/
backgroundUploadURLs: Record<string, string>;

/**
* Background upload encryption key.
*/
backgroundUploadEncryptKey?: CryptoKey;

/**
* Endpoint to which payload should be sent.
*/
Expand Down Expand Up @@ -161,8 +149,6 @@ const DEFAULT_FORM_DATA = {};
function UploadContextProvider({
upload = defaultUpload,
isMockClient = false,
backgroundUploadURLs = {},
backgroundUploadEncryptKey,
endpoint,
statusEndpoint,
statusPollInterval,
Expand All @@ -181,8 +167,6 @@ function UploadContextProvider({
upload: uploadWithFormData,
getStatus,
statusPollInterval,
backgroundUploadURLs,
backgroundUploadEncryptKey,
isMockClient,
flowPath,
formData,
Expand Down

This file was deleted.

Loading