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
33 changes: 24 additions & 9 deletions app/controllers/idv/cancellations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,30 @@ def new
analytics.idv_cancellation_visited(step: params[:step], **properties)
self.session_go_back_path = go_back_path || idv_path
@hybrid_session = hybrid_session?
@presenter = CancellationsPresenter.new(
sp_name: decorated_session.sp_name,
url_options: url_options,
)
end

def update
if params.key?(:cancel)
analytics.idv_cancellation_go_back(step: params[:step])
redirect_to session_go_back_path || idv_path
else
render :new
end
analytics.idv_cancellation_go_back(step: params[:step])
redirect_to session_go_back_path || idv_path
end

def destroy
analytics.idv_cancellation_confirmed(step: params[:step])
@return_to_sp_path = return_to_sp_failure_to_proof_path(location_params)
@hybrid_session = hybrid_session?
cancel_session
if hybrid_session?
render :destroy
else
render json: { redirect_url: cancelled_redirect_path }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Initially I wanted this to just be a plain redirect, but since this is submitted as a form, the redirect would be blocked due to CSP. Another option could be to have this be a GET request, but I think it makes sense the way it's implemented now, since it is technically a destructive action (cancelling = "destroying" the session).

end
end

private

def cancel_session
if hybrid_session?
cancel_document_capture_session
else
Expand All @@ -34,7 +43,13 @@ def destroy
end
end

private
def cancelled_redirect_path
if decorated_session.sp_name
return_to_sp_failure_to_proof_path(location_params)
else
account_path
end
end

def location_params
params.permit(:step, :location).to_h.symbolize_keys
Expand Down
1 change: 0 additions & 1 deletion app/controllers/verify_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def app_data

{
base_path: idv_app_path,
start_over_url: idv_session_path,
cancel_url: idv_cancel_path,
in_person_url: IdentityConfig.store.in_person_proofing_enabled ? idv_in_person_url : nil,
initial_values: initial_values,
Expand Down
67 changes: 0 additions & 67 deletions app/javascript/packages/components/button-to.spec.tsx

This file was deleted.

49 changes: 0 additions & 49 deletions app/javascript/packages/components/button-to.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion app/javascript/packages/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export { default as Accordion } from './accordion';
export { default as Alert } from './alert';
export { default as Button } from './button';
export { default as ButtonTo } from './button-to';
export { default as BlockLink } from './block-link';
export { default as Icon } from './icon';
export { default as FullScreen } from './full-screen';
export { default as Link } from './link';
export { default as PageFooter } from './page-footer';
export { default as PageHeading } from './page-heading';
export { default as ScrollIntoView } from './scroll-into-view';
export { default as SpinnerDots } from './spinner-dots';
Expand Down
10 changes: 10 additions & 0 deletions app/javascript/packages/components/page-footer.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { render } from '@testing-library/react';
import PageFooter from './page-footer';

describe('PageFooter', () => {
it('renders its children content', () => {
const { getByText } = render(<PageFooter>Content</PageFooter>);

expect(getByText('Content')).to.exist();
});
});
16 changes: 16 additions & 0 deletions app/javascript/packages/components/page-footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { ReactNode } from 'react';

interface PageFooterProps {
/**
* Footer contents.
*/
children: ReactNode;
}

function PageFooter({ children }: PageFooterProps) {
return (
<div className="margin-top-4 padding-top-2 border-top border-primary-light">{children}</div>
);
}

export default PageFooter;
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { useContext } from 'react';
import { useI18n } from '@18f/identity-react-i18n';
import { FormStepsButton, FormStepsContext } from '@18f/identity-form-steps';
import { PageHeading } from '@18f/identity-components';
import { Cancel } from '@18f/identity-verify-flow';
import DocumentSideAcuantCapture from './document-side-acuant-capture';
import DeviceContext from '../context/device';
import withBackgroundEncryptedUpload from '../higher-order/with-background-encrypted-upload';
import CaptureTroubleshooting from './capture-troubleshooting';
import DocumentCaptureTroubleshootingOptions from './document-capture-troubleshooting-options';
import StartOverOrCancel from './start-over-or-cancel';

/**
* @typedef {'front'|'back'} DocumentSide
Expand Down Expand Up @@ -67,7 +67,7 @@ function DocumentsStep({
))}
{isLastStep ? <FormStepsButton.Submit /> : <FormStepsButton.Continue />}
<DocumentCaptureTroubleshootingOptions hasErrors={!!errors.length} />
<StartOverOrCancel />
<Cancel />
</CaptureTroubleshooting>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useI18n } from '@18f/identity-react-i18n';
import { useDidUpdateEffect } from '@18f/identity-react-hooks';
import { FormStepsContext, FormStepsButton } from '@18f/identity-form-steps';
import { PageHeading } from '@18f/identity-components';
import { Cancel } from '@18f/identity-verify-flow';
import type { FormStepComponentProps } from '@18f/identity-form-steps';
import DeviceContext from '../context/device';
import DocumentSideAcuantCapture from './document-side-acuant-capture';
Expand All @@ -13,7 +14,6 @@ import ServiceProviderContext from '../context/service-provider';
import withBackgroundEncryptedUpload from '../higher-order/with-background-encrypted-upload';
import type { PII } from '../services/upload';
import DocumentCaptureTroubleshootingOptions from './document-capture-troubleshooting-options';
import StartOverOrCancel from './start-over-or-cancel';
import Warning from './warning';
import AnalyticsContext from '../context/analytics';
import BarcodeAttentionWarning from './barcode-attention-warning';
Expand Down Expand Up @@ -194,7 +194,7 @@ function ReviewIssuesStep({
)}
<FormStepsButton.Submit />
<DocumentCaptureTroubleshootingOptions />
<StartOverOrCancel />
<Cancel />
</>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { hasMediaAccess } from '@18f/identity-device';
import { useI18n } from '@18f/identity-react-i18n';
import { FormStepsButton } from '@18f/identity-form-steps';
import { PageHeading } from '@18f/identity-components';
import { Cancel } from '@18f/identity-verify-flow';
import DeviceContext from '../context/device';
import AcuantCapture from './acuant-capture';
import SelfieCapture from './selfie-capture';
import withBackgroundEncryptedUpload from '../higher-order/with-background-encrypted-upload';
import StartOverOrCancel from './start-over-or-cancel';

/**
* @typedef SelfieStepValue
Expand Down Expand Up @@ -59,7 +59,7 @@ function SelfieStep({
/>
)}
<FormStepsButton.Submit />
<StartOverOrCancel />
<Cancel />
</>
);
}
Expand Down

This file was deleted.

This file was deleted.

32 changes: 32 additions & 0 deletions app/javascript/packages/verify-flow/cancel.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { render } from '@testing-library/react';
import FlowContext from './context/flow-context';
import Cancel from './cancel';

describe('Cancel', () => {
it('renders cancel link', () => {
const { queryByText } = render(<Cancel />);

expect(queryByText('links.cancel')).to.exist();
});

context('with flow context', () => {
it('renders links with current step', () => {
const { getByText } = render(
<FlowContext.Provider
value={{
cancelURL: 'http://example.test/cancel',
currentStep: 'one',
basePath: '',
inPersonURL: null,
onComplete() {},
}}
>
<Cancel />
</FlowContext.Provider>,
);

const cancelLink = getByText('links.cancel') as HTMLAnchorElement;
expect(cancelLink.getAttribute('href')).to.equal('http://example.test/cancel?step=one');
});
});
});
18 changes: 18 additions & 0 deletions app/javascript/packages/verify-flow/cancel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useContext } from 'react';
import { useI18n } from '@18f/identity-react-i18n';
import { addSearchParams } from '@18f/identity-url';
import { PageFooter } from '@18f/identity-components';
import FlowContext from './context/flow-context';

function Cancel() {
const { currentStep: step, cancelURL } = useContext(FlowContext);
const { t } = useI18n();

return (
<PageFooter>
<a href={addSearchParams(cancelURL, { step })}>{t('links.cancel')}</a>
</PageFooter>
);
}

export default Cancel;
6 changes: 0 additions & 6 deletions app/javascript/packages/verify-flow/context/flow-context.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { createContext } from 'react';

export interface FlowContextValue {
/**
* URL to path for session restart.
*/
startOverURL: string;

/**
* URL to path for session cancel.
*/
Expand Down Expand Up @@ -33,7 +28,6 @@ export interface FlowContextValue {
}

const FlowContext = createContext<FlowContextValue>({
startOverURL: '',
cancelURL: '',
inPersonURL: null,
currentStep: '',
Expand Down
Loading