Skip to content
Draft
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
22 changes: 20 additions & 2 deletions src/libs/API/parameters/ResendValidateCodeParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,37 @@

type ResendValidateCodeBaseParams = {
// Exclude reasons that require parameters - redefine them as separate types below to enforce their parameters are always passed
reasonCode: Exclude<ValueOf<typeof CONST.VALIDATE_CODE_REASONS>, typeof CONST.VALIDATE_CODE_REASONS.REVEAL_CARD_DETAILS>;
reasonCode: Exclude<
ValueOf<typeof CONST.VALIDATE_CODE_REASONS>,
typeof CONST.VALIDATE_CODE_REASONS.REVEAL_CARD_DETAILS | typeof CONST.VALIDATE_CODE_REASONS.REPLACE_CARD | typeof CONST.VALIDATE_CODE_REASONS.REPORT_CARD_FRAUD

Check failure on line 8 in src/libs/API/parameters/ResendValidateCodeParams.ts

View workflow job for this annotation

GitHub Actions / ESLint check

'any' overrides all other types in this union type

Check failure on line 8 in src/libs/API/parameters/ResendValidateCodeParams.ts

View workflow job for this annotation

GitHub Actions / ESLint check

'any' overrides all other types in this union type

Check failure on line 8 in src/libs/API/parameters/ResendValidateCodeParams.ts

View workflow job for this annotation

GitHub Actions / ESLint check

'any' overrides all other types in this union type

Check failure on line 8 in src/libs/API/parameters/ResendValidateCodeParams.ts

View workflow job for this annotation

GitHub Actions / ESLint check

'any' overrides all other types in this union type

Check failure on line 8 in src/libs/API/parameters/ResendValidateCodeParams.ts

View workflow job for this annotation

GitHub Actions / typecheck

Property 'REPORT_CARD_FRAUD' does not exist on type '{ readonly SIGN_IN: "sign_in"; readonly ADD_CONTACT_METHOD: "add_contact_method"; readonly VALIDATE_ACCOUNT: "validate_account"; readonly REVEAL_CARD_DETAILS: "reveal_card_details"; readonly REGISTER_AUTHENTICATION_KEY: "register_authentication_key"; }'.

Check failure on line 8 in src/libs/API/parameters/ResendValidateCodeParams.ts

View workflow job for this annotation

GitHub Actions / typecheck

Property 'REPLACE_CARD' does not exist on type '{ readonly SIGN_IN: "sign_in"; readonly ADD_CONTACT_METHOD: "add_contact_method"; readonly VALIDATE_ACCOUNT: "validate_account"; readonly REVEAL_CARD_DETAILS: "reveal_card_details"; readonly REGISTER_AUTHENTICATION_KEY: "register_authentication_key"; }'.
>;
};

type ResendValidateCodeForRevealCardDetailsParams = {
reasonCode: typeof CONST.VALIDATE_CODE_REASONS.REVEAL_CARD_DETAILS;
reasonCardID: number;
};

type ResendValidateCodeForReplaceCardParams = {
reasonCode: typeof CONST.VALIDATE_CODE_REASONS.REPLACE_CARD;

Check failure on line 18 in src/libs/API/parameters/ResendValidateCodeParams.ts

View workflow job for this annotation

GitHub Actions / typecheck

Property 'REPLACE_CARD' does not exist on type '{ readonly SIGN_IN: "sign_in"; readonly ADD_CONTACT_METHOD: "add_contact_method"; readonly VALIDATE_ACCOUNT: "validate_account"; readonly REVEAL_CARD_DETAILS: "reveal_card_details"; readonly REGISTER_AUTHENTICATION_KEY: "register_authentication_key"; }'.
reasonCardID: number;
};

type ResendValidateCodeForReportCardFraudParams = {
reasonCode: typeof CONST.VALIDATE_CODE_REASONS.REPORT_CARD_FRAUD;

Check failure on line 23 in src/libs/API/parameters/ResendValidateCodeParams.ts

View workflow job for this annotation

GitHub Actions / typecheck

Property 'REPORT_CARD_FRAUD' does not exist on type '{ readonly SIGN_IN: "sign_in"; readonly ADD_CONTACT_METHOD: "add_contact_method"; readonly VALIDATE_ACCOUNT: "validate_account"; readonly REVEAL_CARD_DETAILS: "reveal_card_details"; readonly REGISTER_AUTHENTICATION_KEY: "register_authentication_key"; }'.
reasonCardID: number;
};

// Will be removed eventually
type ResendValidateCodeNotYetImplementedParams = {
reasonCode: null;
};

type ResendValidateCodeParams = ResendValidateCodeBaseParams | ResendValidateCodeNotYetImplementedParams | ResendValidateCodeForRevealCardDetailsParams;
type ResendValidateCodeParams =
| ResendValidateCodeBaseParams
| ResendValidateCodeNotYetImplementedParams
| ResendValidateCodeForRevealCardDetailsParams
| ResendValidateCodeForReplaceCardParams
| ResendValidateCodeForReportCardFraudParams;

export default ResendValidateCodeParams;
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
updatePersonalDetailsAndShipExpensifyCards,
} from '@libs/actions/PersonalDetails';
import {requestValidateCodeAction} from '@libs/actions/User';
import type ResendValidateCodeParams from '@libs/API/parameters/ResendValidateCodeParams';
import {normalizeCountryCode} from '@libs/CountryUtils';
import {getLatestError, getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils';
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
Expand All @@ -35,6 +36,7 @@
import type {OnyxEntry} from 'react-native-onyx';

import {areAllExpensifyCardsShipped} from '@selectors/Card';
import {CONST as COMMON_CONST} from 'expensify-common';
import React, {useCallback, useEffect, useMemo, useState} from 'react';

import {getSubPageValues} from './utils';
Expand Down Expand Up @@ -104,11 +106,19 @@
[countryCode, values, isVirtualCard, cardID],
);

// The validate code minted here must carry the reasonCode of the command handleSubmitForm will
// dispatch: virtual cards verify via SetPersonalDetailsAndRevealExpensifyCard (reveal_card_details)
// and physical cards via SetPersonalDetailsAndShipExpensifyCards (ship_card). The reasonCode is
// baked into the validate-code hash, so this branch must stay in lockstep with handleSubmitForm.
const resendValidateCodeParams: ResendValidateCodeParams = isVirtualCard
? {reasonCode: COMMON_CONST.VALIDATE_CODE_REASONS.REVEAL_CARD_DETAILS, reasonCardID: Number(cardID)}
: {reasonCode: COMMON_CONST.VALIDATE_CODE_REASONS.SHIP_CARD};

Check failure on line 115 in src/pages/MissingPersonalDetails/MissingPersonalDetailsMagicCodePage.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unsafe assignment of an error typed value

Check failure on line 115 in src/pages/MissingPersonalDetails/MissingPersonalDetailsMagicCodePage.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unsafe assignment of an error typed value

Check failure on line 115 in src/pages/MissingPersonalDetails/MissingPersonalDetailsMagicCodePage.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'SHIP_CARD' does not exist on type '{ readonly SIGN_IN: "sign_in"; readonly ADD_CONTACT_METHOD: "add_contact_method"; readonly VALIDATE_ACCOUNT: "validate_account"; readonly REVEAL_CARD_DETAILS: "reveal_card_details"; readonly REGISTER_AUTHENTICATION_KEY: "register_authentication_key"; }'.

return (
<ValidateCodeActionContent
title={translate('cardPage.validateCardTitle')}
descriptionPrimary={translate('cardPage.enterSecurityCode', primaryLogin ?? '')}
sendValidateCode={() => requestValidateCodeAction()}
sendValidateCode={() => requestValidateCodeAction(resendValidateCodeParams)}
validateCodeActionErrorField="personalDetails"
handleSubmitForm={handleSubmitForm}
validateError={!isEmptyObject(revealCardError) ? revealCardError : validateLoginError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';

import {CONST as COMMON_CONST} from 'expensify-common';
import {deepEqual} from 'fast-equals';
import React, {useEffect} from 'react';

Expand Down Expand Up @@ -91,7 +92,7 @@
isLoading={formData?.isLoading}
title={translate('cardPage.validateCardTitle')}
descriptionPrimary={translate('cardPage.enterSecurityCode', primaryLogin ?? '')}
sendValidateCode={() => requestValidateCodeAction()}
sendValidateCode={() => requestValidateCodeAction({reasonCode: COMMON_CONST.VALIDATE_CODE_REASONS.REPLACE_CARD, reasonCardID: Number.parseInt(cardID, 10)})}

Check failure on line 95 in src/pages/settings/Wallet/ReportCardLostConfirmMagicCodePage.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unsafe assignment of an error typed value

Check failure on line 95 in src/pages/settings/Wallet/ReportCardLostConfirmMagicCodePage.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unsafe assignment of an error typed value

Check failure on line 95 in src/pages/settings/Wallet/ReportCardLostConfirmMagicCodePage.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'REPLACE_CARD' does not exist on type '{ readonly SIGN_IN: "sign_in"; readonly ADD_CONTACT_METHOD: "add_contact_method"; readonly VALIDATE_ACCOUNT: "validate_account"; readonly REVEAL_CARD_DETAILS: "reveal_card_details"; readonly REGISTER_AUTHENTICATION_KEY: "register_authentication_key"; }'.
validateError={validateError}
clearError={() => {
if (!physicalCard?.cardID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import SCREENS from '@src/SCREENS';
import {isEmptyObject} from '@src/types/utils/EmptyObject';

import {CONST as COMMON_CONST} from 'expensify-common';
import React, {useEffect} from 'react';

type ReportVirtualCardFraudVerifyAccountPageProps = PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.WALLET.REPORT_VIRTUAL_CARD_FRAUD>;
Expand Down Expand Up @@ -79,7 +80,7 @@
<ValidateCodeActionContent
title={translate('cardPage.validateCardTitle')}
descriptionPrimary={translate('cardPage.enterSecurityCode', primaryLogin ?? '')}
sendValidateCode={() => requestValidateCodeAction()}
sendValidateCode={() => requestValidateCodeAction({reasonCode: COMMON_CONST.VALIDATE_CODE_REASONS.REPORT_CARD_FRAUD, reasonCardID: Number(cardID)})}

Check failure on line 83 in src/pages/settings/Wallet/ReportVirtualCardFraudVerifyAccountPage.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unsafe assignment of an error typed value

Check failure on line 83 in src/pages/settings/Wallet/ReportVirtualCardFraudVerifyAccountPage.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unsafe assignment of an error typed value

Check failure on line 83 in src/pages/settings/Wallet/ReportVirtualCardFraudVerifyAccountPage.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'REPORT_CARD_FRAUD' does not exist on type '{ readonly SIGN_IN: "sign_in"; readonly ADD_CONTACT_METHOD: "add_contact_method"; readonly VALIDATE_ACCOUNT: "validate_account"; readonly REVEAL_CARD_DETAILS: "reveal_card_details"; readonly REGISTER_AUTHENTICATION_KEY: "register_authentication_key"; }'.
validateCodeActionErrorField="reportVirtualCard"
handleSubmitForm={handleValidateCodeEntered}
validateError={{...cardError, ...codeError}}
Expand Down
Loading