Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes create/update MHV accounts from CTA #23438

Merged
merged 3 commits into from
Mar 13, 2023
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
@@ -1,12 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import AdditionalInfo from '@department-of-veterans-affairs/component-library/AdditionalInfo';
import Telephone, {
CONTACTS,
} from '@department-of-veterans-affairs/component-library/Telephone';
import CallToActionAlert from '../CallToActionAlert';

const RegisterFailed = ({ createAndUpgradeMHVAccount }) => {
const RegisterFailed = () => {
const content = {
heading: 'We couldn’t create a MyHealtheVet account for you',
alertText: (
Expand All @@ -16,24 +15,11 @@ const RegisterFailed = ({ createAndUpgradeMHVAccount }) => {
use our online health tools, you’ll need to create an account.
</p>
<h5>What you can do</h5>
<p className="vads-u-margin-top--0">Please try again.</p>
<button
className="usa-button-primary"
onClick={createAndUpgradeMHVAccount}
>
Try again to create your account
</button>
<p>
<strong>
If you try again and continue to see this error, you can create a My
HealtheVet account in one of these ways:
</strong>
</p>
<AdditionalInfo triggerText="Call the My HealtheVet help desk">
<p>
Call us at <a href="tel:877-327-0022">877-327-0022</a>. We’re here
Monday through Friday, 8:00 a.m. to 8:00 p.m. ET. If you have
hearing loss, call TTY: <Telephone contact={CONTACTS.HELP_TTY} />.
Call us at <va-telephone contact="8773270022" />. We’re here Monday
through Friday, 8:00 a.m. to 8:00 p.m. ET. If you have hearing loss,
call TTY: <Telephone contact={CONTACTS.HELP_TTY} />.
</p>
<p>
Tell the representative that you tried to sign in to use the online
Expand Down Expand Up @@ -92,8 +78,4 @@ const RegisterFailed = ({ createAndUpgradeMHVAccount }) => {
return <CallToActionAlert {...content} />;
};

RegisterFailed.propTypes = {
createAndUpgradeMHVAccount: PropTypes.func.isRequired,
};

export default RegisterFailed;
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import AdditionalInfo from '@department-of-veterans-affairs/component-library/AdditionalInfo';
import Telephone, {
CONTACTS,
} from '@department-of-veterans-affairs/component-library/Telephone';
import CallToActionAlert from '../CallToActionAlert';

const UpgradeFailed = ({ upgradeMHVAccount }) => {
const UpgradeFailed = () => {
const content = {
heading: 'We couldn’t upgrade your My HealtheVet account',
alertText: (
Expand All @@ -17,21 +16,11 @@ const UpgradeFailed = ({ upgradeMHVAccount }) => {
until we can fix the problem.
</p>
<h5>What you can do</h5>
<p className="vads-u-margin-top--0">Please try again.</p>
<button className="usa-button-primary" onClick={upgradeMHVAccount}>
Try again to upgrade your account
</button>
<p>
<strong>
If you try again and continue to see this error, you can upgrade
your My HealtheVet account in one of these ways:
</strong>
</p>
<AdditionalInfo triggerText="Call the My HealtheVet help desk">
<p>
Call us at <a href="tel:877-327-0022">877-327-0022</a>. We’re here
Monday through Friday, 8:00 a.m. to 8:00 p.m. ET. If you have
hearing loss, call TTY: <Telephone contact={CONTACTS.HELP_TTY} />.
Call us at <va-telephone contact="8773270022" />. We’re here Monday
through Friday, 8:00 a.m. to 8:00 p.m. ET. If you have hearing loss,
call TTY: <Telephone contact={CONTACTS.HELP_TTY} />.
</p>
<p>
Tell the representative that you tried to sign in to use the online
Expand Down Expand Up @@ -90,8 +79,4 @@ const UpgradeFailed = ({ upgradeMHVAccount }) => {
return <CallToActionAlert {...content} />;
};

UpgradeFailed.propTypes = {
upgradeMHVAccount: PropTypes.func.isRequired,
};

export default UpgradeFailed;
60 changes: 12 additions & 48 deletions src/applications/static-pages/cta-widget/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ import { connect } from 'react-redux';
// Relative imports.
import LoadingIndicator from '@department-of-veterans-affairs/component-library/LoadingIndicator';
import recordEvent from 'platform/monitoring/record-event';
import {
createAndUpgradeMHVAccount,
fetchMHVAccount,
upgradeMHVAccount,
} from 'platform/user/profile/actions';
import { fetchMHVAccount } from 'platform/user/profile/actions';
import { mhvUrl } from 'platform/site-wide/mhv/utilities';

import { isAuthenticatedWithSSOe } from 'platform/user/authentication/selectors';
import { isLoggedIn, selectProfile } from 'platform/user/selectors';
Expand Down Expand Up @@ -61,10 +58,8 @@ export class CallToActionWidget extends Component {
mviStatus: PropTypes.string,
profile: PropTypes.object,
// From mapDispatchToProps.
createAndUpgradeMHVAccount: PropTypes.func.isRequired,
fetchMHVAccount: PropTypes.func.isRequired,
toggleLoginModal: PropTypes.func.isRequired,
upgradeMHVAccount: PropTypes.func.isRequired,
ariaLabel: PropTypes.string,
ariaDescribedby: PropTypes.string,
};
Expand Down Expand Up @@ -117,7 +112,7 @@ export class CallToActionWidget extends Component {
this._toolUrl = url;
if (redirect && !this._popup) this.goToTool();
} else if (this.isHealthTool()) {
const { accountLevel, accountState, loading } = this.props.mhvAccount;
const { accountState, loading } = this.props.mhvAccount;

if (loading) return;

Expand All @@ -129,11 +124,7 @@ export class CallToActionWidget extends Component {
// Since T&C is still required to support the existing account states,
// check the existence of a query param that gets appended after
// successful T&C acceptance to complete account creation or upgrade.
if (!accountLevel && accountState !== 'register_failed') {
this.props.createAndUpgradeMHVAccount();
} else if (accountLevel && accountState !== 'upgrade_failed') {
this.props.upgradeMHVAccount();
}
/* We are no longer creating or upgrading MHV accounts on VA.gov */
}
}
}
Expand Down Expand Up @@ -292,6 +283,10 @@ export class CallToActionWidget extends Component {
return null;
};

sendToMHV = () => {
window.location = mhvUrl(this.props.authenticatedWithSSOe, 'home');
};

getInaccessibleHealthToolContent = () => {
const { accountState } = this.props.mhvAccount;

Expand Down Expand Up @@ -324,40 +319,11 @@ export class CallToActionWidget extends Component {
case ACCOUNT_STATES.MULTIPLE_IDS:
return <MultipleIds />;

/* Handling for these states to be re-introduced after brand consolidation
* when VA patient and T&C acceptance checks will no longer gate access, so
* access to these tools will be accurately reported by the services list.
* For now, MHV account level requirements will be validated client-side.
*
* case 'no_account':
* return {
* heading: `You’ll need to create a My HealtheVet account before you can ${this._serviceDescription`,
* primaryButtonText: 'Create a My HealtheVet Account',
* primaryButtonHandler: this.props.createAndUpgradeMHVAccount,
* status: 'continue'
* };

* case 'existing':
* case 'registered':
* return {
* heading: `You’ll need to upgrade your account before you can ${this._serviceDescription}`,
* primaryButtonText: 'Upgrade Your Account',
* primaryButtonHandler: this.props.upgradeMHVAccount,
* status: 'continue'
* };
*/

case ACCOUNT_STATES.REGISTER_FAILED:
return (
<RegisterFailed
createAndUpgradeMHVAccount={this.props.createAndUpgradeMHVAccount}
/>
);
return <RegisterFailed />;

case ACCOUNT_STATES.UPGRADE_FAILED:
return (
<UpgradeFailed upgradeMHVAccount={this.props.upgradeMHVAccount} />
);
return <UpgradeFailed />;

default: // Handle other content outside of block.
}
Expand All @@ -383,7 +349,7 @@ export class CallToActionWidget extends Component {
primaryButtonHandler={
accountState === 'needs_terms_acceptance'
? redirectToTermsAndConditions
: this.props.createAndUpgradeMHVAccount
: this.sendToMHV
}
secondaryButtonHandler={this.signOut}
/>
Expand All @@ -396,7 +362,7 @@ export class CallToActionWidget extends Component {
primaryButtonHandler={
accountState === 'needs_terms_acceptance'
? redirectToTermsAndConditions
: this.props.upgradeMHVAccount
: this.sendToMHV
}
/>
);
Expand Down Expand Up @@ -567,10 +533,8 @@ const mapStateToProps = state => {
};

const mapDispatchToProps = {
createAndUpgradeMHVAccount,
fetchMHVAccount,
toggleLoginModal,
upgradeMHVAccount,
};

export default connect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,79 +260,6 @@ describe('<CallToActionWidget>', () => {
tree.unmount();
});

it('should create and upgrade MHV account when necessary', () => {
const createAndUpgradeMHVAccount = sinon.spy();
const tree = mount(
<CallToActionWidget
createAndUpgradeMHVAccount={createAndUpgradeMHVAccount}
appId={CTA_WIDGET_TYPES.RX}
profile={{
loading: false,
verified: true,
multifactor: false,
}}
mhvAccount={{
loading: true,
}}
mviStatus={{}}
featureToggles={{
loading: false,
}}
/>,
);
expect(createAndUpgradeMHVAccount.called).to.be.false;

global.dom.reconfigure({ url: 'http://localhost?tc_accepted=true' });
tree.setProps({
isLoggedIn: true,
mhvAccount: {
loading: false,
accountState: 'something',
},
});

expect(createAndUpgradeMHVAccount.called).to.be.true;
tree.unmount();
global.dom.reconfigure({ url: 'http://localhost' });
});

it('should upgrade MHV account when necessary', () => {
const upgradeMHVAccount = sinon.spy();
const tree = mount(
<CallToActionWidget
upgradeMHVAccount={upgradeMHVAccount}
appId={CTA_WIDGET_TYPES.RX}
profile={{
loading: false,
verified: true,
multifactor: false,
}}
mhvAccount={{
loading: true,
}}
mviStatus={{}}
featureToggles={{
loading: false,
}}
/>,
);
expect(upgradeMHVAccount.called).to.be.false;

global.dom.reconfigure({ url: 'http://localhost?tc_accepted=true' });
tree.setProps({
isLoggedIn: true,
mhvAccount: {
loading: false,
accountState: 'something',
accountLevel: 'Basic',
},
});

expect(upgradeMHVAccount.called).to.be.true;
tree.unmount();
global.dom.reconfigure({ url: 'http://localhost' });
});

it('should open myhealthevet popup', () => {
const { props, mockStore } = getData({
profile: { loading: false, verified: true, multifactor: false },
Expand Down
Loading