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 @@ -4,9 +4,9 @@ import {
MarketingSiteContextProvider,
ServiceProviderContextProvider,
} from '@18f/identity-document-capture';
import { FlowContext, FlowContextValue } from '@18f/identity-verify-flow';
import DocumentCaptureTroubleshootingOptions from './document-capture-troubleshooting-options';
import type { ServiceProviderContext } from '../context/service-provider';
import InPersonContext, { InPersonContextProps } from '../context/in-person';

describe('DocumentCaptureTroubleshootingOptions', () => {
const helpCenterRedirectURL = 'https://example.com/redirect/';
Expand Down Expand Up @@ -146,9 +146,9 @@ describe('DocumentCaptureTroubleshootingOptions', () => {

context('with inPersonURL', () => {
const wrapper: ComponentType = ({ children }) => (
<FlowContext.Provider value={{ inPersonURL } as FlowContextValue}>
<InPersonContext.Provider value={{ inPersonURL } as InPersonContextProps}>
{children}
</FlowContext.Provider>
</InPersonContext.Provider>
);

it('does not render in-person call to action', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useContext } from 'react';
import { FlowContext } from '@18f/identity-verify-flow';
import { TroubleshootingOptions } from '@18f/identity-components';
import { useI18n } from '@18f/identity-react-i18n';
import type { TroubleshootingOption } from '@18f/identity-components/troubleshooting-options';
import ServiceProviderContext from '../context/service-provider';
import MarketingSiteContext from '../context/marketing-site';
import InPersonCallToAction from './in-person-call-to-action';
import { InPersonContext } from '../context';

interface DocumentCaptureTroubleshootingOptionsProps {
/**
Expand Down Expand Up @@ -36,7 +36,7 @@ function DocumentCaptureTroubleshootingOptions({
showAlternativeProofingOptions,
}: DocumentCaptureTroubleshootingOptionsProps) {
const { t } = useI18n();
const { inPersonURL } = useContext(FlowContext);
const { inPersonURL } = useContext(InPersonContext);
const { getHelpCenterURL } = useContext(MarketingSiteContext);
const { name: spName, getFailureToProofURL } = useContext(ServiceProviderContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState, useMemo, useContext, useEffect } from 'react';
import { Alert } from '@18f/identity-components';
import { useI18n } from '@18f/identity-react-i18n';
import { FormSteps, PromptOnNavigate } from '@18f/identity-form-steps';
import { FlowContext, VerifyFlowStepIndicator, VerifyFlowPath } from '@18f/identity-verify-flow';
import { VerifyFlowStepIndicator, VerifyFlowPath } from '@18f/identity-verify-flow';
import { useDidUpdateEffect } from '@18f/identity-react-hooks';
import type { FormStep } from '@18f/identity-form-steps';
import { UploadFormEntriesError } from '../services/upload';
Expand All @@ -20,6 +20,7 @@ import { BackgroundEncryptedUploadError } from '../higher-order/with-background-
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.
Expand Down Expand Up @@ -57,7 +58,7 @@ function DocumentCapture({ isAsyncForm = false, onStepChange = () => {} }: Docum
const { t } = useI18n();
const { flowPath } = useContext(UploadContext);
const { trackSubmitEvent, trackVisitEvent } = useContext(AnalyticsContext);
const { inPersonURL } = useContext(FlowContext);
const { inPersonURL } = useContext(InPersonContext);
useDidUpdateEffect(onStepChange, [stepName]);
useEffect(() => {
if (stepName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import sinon from 'sinon';
import { fireEvent, render, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import type { ComponentType } from 'react';
import { FlowContext } from '@18f/identity-verify-flow';
import type { FlowContextValue } from '@18f/identity-verify-flow';
import { useSandbox } from '@18f/identity-test-helpers';
import { Provider as MarketingSiteContextProvider } from '../context/marketing-site';
import { AnalyticsContextProvider } from '../context/analytics';
import InPersonPrepareStep from './in-person-prepare-step';
import InPersonContext, { InPersonContextProps } from '../context/in-person';

describe('InPersonPrepareStep', () => {
const DEFAULT_PROPS = { toPreviousStep() {}, value: {} };
Expand All @@ -26,9 +25,9 @@ describe('InPersonPrepareStep', () => {
context('with in person URL', () => {
const inPersonURL = '#in_person';
const wrapper: ComponentType = ({ children }) => (
<FlowContext.Provider value={{ inPersonURL } as FlowContextValue}>
<InPersonContext.Provider value={{ inPersonURL } as InPersonContextProps}>
{children}
</FlowContext.Provider>
</InPersonContext.Provider>
);

it('logs prepare step submission when clicking continue', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
ProcessListItem,
} from '@18f/identity-components';
import { removeUnloadProtection } from '@18f/identity-url';
import { FlowContext } from '@18f/identity-verify-flow';
import { getConfigValue } from '@18f/identity-config';
import { useI18n } from '@18f/identity-react-i18n';
import { FormStepsButton } from '@18f/identity-form-steps';
Expand All @@ -20,11 +19,12 @@ import MarketingSiteContext from '../context/marketing-site';
import AnalyticsContext from '../context/analytics';
import BackButton from './back-button';
import InPersonTroubleshootingOptions from './in-person-troubleshooting-options';
import { InPersonContext } from '../context';

function InPersonPrepareStep({ toPreviousStep, value }) {
const { t } = useI18n();
const [isSubmitting, setIsSubmitting] = useState(false);
const { inPersonURL } = useContext(FlowContext);
const { inPersonURL } = useContext(InPersonContext);
const { flowPath } = useContext(UploadContext);
const { trackEvent } = useContext(AnalyticsContext);
const { securityAndPrivacyHowItWorksURL } = useContext(MarketingSiteContext);
Expand Down
15 changes: 0 additions & 15 deletions app/javascript/packages/document-capture/context/in-person.js

This file was deleted.

21 changes: 21 additions & 0 deletions app/javascript/packages/document-capture/context/in-person.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { createContext } from 'react';

export interface InPersonContextProps {
/**
* Feature flag for enabling address search
*/
arcgisSearchEnabled?: boolean;

/**
* URL to in-person proofing alternative flow, if enabled.
*/
inPersonURL?: string;
}

const InPersonContext = createContext<InPersonContextProps>({
arcgisSearchEnabled: false,
});

InPersonContext.displayName = 'InPersonContext';

export default InPersonContext;
5 changes: 0 additions & 5 deletions app/javascript/packages/verify-flow/context/flow-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ export interface FlowContextValue {
*/
cancelURL: string;

/**
* URL to in-person proofing alternative flow, if enabled.
*/
inPersonURL?: string;

/**
* Current step name.
*/
Expand Down
6 changes: 4 additions & 2 deletions app/javascript/packs/document-capture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ const trackEvent: typeof baseTrackEvent = (event, payload) => {
{
value: {
cancelURL,
inPersonURL,
currentStep: 'document_capture',
},
},
Expand All @@ -186,7 +185,10 @@ const trackEvent: typeof baseTrackEvent = (event, payload) => {
nativeCameraOnly: nativeCameraOnly === 'true',
},
],
[InPersonContext.Provider, { value: { arcgisSearchEnabled: arcgisSearchEnabled === 'true' } }],
[
InPersonContext.Provider,
{ value: { arcgisSearchEnabled: arcgisSearchEnabled === 'true', inPersonURL } },
],
[DocumentCapture, { isAsyncForm, onStepChange: keepAlive }],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
UploadContextProvider,
AcuantContextProvider,
DeviceContext,
InPersonContext,
} from '@18f/identity-document-capture';
import DocumentCapture, {
except,
Expand Down Expand Up @@ -494,11 +495,16 @@ describe('document-capture/components/document-capture', () => {
<FlowContext.Provider
value={{
cancelURL: '/cancel',
inPersonURL: '/in_person',
currentStep: 'document_capture',
}}
>
<DocumentCapture />
<InPersonContext.Provider
value={{
inPersonURL: '/in_person',
}}
>
<DocumentCapture />
</InPersonContext.Provider>
</FlowContext.Provider>
</ServiceProviderContextProvider>
</UploadContextProvider>,
Expand Down