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

[TS migration] Migrate 'EnablePayments' pages to TypeScript #35438

Merged
merged 57 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
2060d5e
TS-migration: TermsStep Page
jayeshmangwani Jan 30, 2024
744a3b5
TS-migration: ShortTermsForm Page
jayeshmangwani Jan 30, 2024
3f86b2e
TS-migration: LongTermsForm Page
jayeshmangwani Jan 30, 2024
f8cf10a
TS-migration: FailedKYC Page
jayeshmangwani Jan 30, 2024
b4c5a8a
TS-migration: ActivateStep Page
jayeshmangwani Jan 30, 2024
0ac0bed
TS-migration: OnfidoStep & OnfidoPrivacy Page
jayeshmangwani Jan 30, 2024
0feb8c4
TS-migration: EnablePaymentsPage Page
jayeshmangwani Jan 30, 2024
9ec235c
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Feb 5, 2024
9bd67d6
merge main, fix lint
jayeshmangwani Feb 5, 2024
55ebd45
Merge branch 'main' of https://github.com/Expensify/App into ts-migra…
jayeshmangwani Feb 5, 2024
c0f4f03
TS-migration: IdologyQuestions Page
jayeshmangwani Feb 5, 2024
61d24b8
TS-migration: AdditionalDetailsStep Page
jayeshmangwani Feb 5, 2024
57a4059
merge: resolved conflicts
jayeshmangwani Feb 5, 2024
78d30bd
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Feb 6, 2024
eee8a9c
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Feb 8, 2024
5f89ad6
merge main, lint fixed and prettified code
jayeshmangwani Feb 8, 2024
a379bd4
merge code
jayeshmangwani Feb 9, 2024
ed7c4d2
fix: lint
jayeshmangwani Feb 9, 2024
e6df088
updated key from ADDITIONAL_DETAILS_FORM to WALLET_ADDITIONAL_DETAILS
jayeshmangwani Feb 10, 2024
6137538
merge code
jayeshmangwani Feb 10, 2024
b369d2a
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Feb 12, 2024
01bcba2
rearranged import for GetPhysicalCardForm
jayeshmangwani Feb 12, 2024
8adbf8c
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Feb 12, 2024
ee76e50
updated IDOLOGY_QUESTIONS_FORM key name
jayeshmangwani Feb 12, 2024
1b5a973
resolved conflicts
jayeshmangwani Feb 16, 2024
2c34dbf
fixed additional details step and idology questions types errors
jayeshmangwani Feb 16, 2024
98ef693
code prettified & lint fixed
jayeshmangwani Feb 16, 2024
0cb9a6b
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Feb 18, 2024
98e9a51
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Feb 21, 2024
24fb379
fix loading issue for idology questions and fixed onValueChange for S…
jayeshmangwani Feb 21, 2024
708e818
extracted URLs to CONST and deleted unused files
jayeshmangwani Feb 21, 2024
45635f5
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Feb 21, 2024
e43ef46
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Feb 21, 2024
efd86d4
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Feb 22, 2024
07180ea
merge: resolved conflcits
jayeshmangwani Feb 28, 2024
45ce52a
Merge branch 'main' of https://github.com/Expensify/App into ts-migra…
jayeshmangwani Feb 28, 2024
4c852b4
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Feb 28, 2024
f2d910b
fix: updated IdologyQuestionsForm and AdditionalDetailStepForm values…
jayeshmangwani Feb 28, 2024
47c6030
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Mar 1, 2024
042d5e5
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Mar 1, 2024
73d2624
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Mar 2, 2024
ce048d5
revert the WALLET_ADDITIONAL_DETAILS key name
jayeshmangwani Mar 2, 2024
c6a9bf9
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Mar 4, 2024
0f1fb25
removed unused onyx/Form
jayeshmangwani Mar 4, 2024
3839512
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Mar 4, 2024
8a2b943
removed IdologyQuestionsForm instead used AdditionalDetailStepForm
jayeshmangwani Mar 4, 2024
d3a2e06
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Mar 5, 2024
e9140e1
updated setAdditionalDetailsQuestions prop to handle null and added m…
jayeshmangwani Mar 5, 2024
0246c5f
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Mar 6, 2024
01ca515
deleted unused walletTermsPropTypes
jayeshmangwani Mar 6, 2024
93563e9
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Mar 8, 2024
f806ec7
Merge branch 'main' into ts-migration/EnablePayments
jayeshmangwani Mar 11, 2024
7ec68d5
fixed restricted-imports for ScrollView
jayeshmangwani Mar 11, 2024
dd5b6e9
resolved conflicts
jayeshmangwani Mar 12, 2024
2f7e85e
revert package-lock.json file
jayeshmangwani Mar 12, 2024
990a440
revert package-lock.json file
jayeshmangwani Mar 12, 2024
4dd5b43
revert package-lock.json file
jayeshmangwani Mar 12, 2024
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
4 changes: 4 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ const CONST = {
TERMS_URL: `${USE_EXPENSIFY_URL}/terms`,
PRIVACY_URL: `${USE_EXPENSIFY_URL}/privacy`,
LICENSES_URL: `${USE_EXPENSIFY_URL}/licenses`,
ACH_TERMS_URL: `${USE_EXPENSIFY_URL}/achterms`,
WALLET_AGREEMENT_URL: `${USE_EXPENSIFY_URL}/walletagreement`,
HELP_LINK_URL: `${USE_EXPENSIFY_URL}/usa-patriot-act`,
ELECTRONIC_DISCLOSURES_URL: `${USE_EXPENSIFY_URL}/esignagreement`,
GITHUB_RELEASE_URL: 'https://api.github.com/repos/expensify/app/releases/latest',
ADD_SECONDARY_LOGIN_URL: encodeURI('settings?param={"section":"account","openModal":"secondaryLogin"}'),
MANAGE_CARDS_URL: 'domain_companycards',
Expand Down
3 changes: 3 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ const ONYXKEYS = {
EXIT_SURVEY_REASON_FORM_DRAFT: 'exitSurveyReasonFormDraft',
EXIT_SURVEY_RESPONSE_FORM: 'exitSurveyResponseForm',
EXIT_SURVEY_RESPONSE_FORM_DRAFT: 'exitSurveyResponseFormDraft',
WALLET_ADDITIONAL_DETAILS: 'walletAdditionalDetails',
WALLET_ADDITIONAL_DETAILS_DRAFT: 'walletAdditionalDetailsDraft',
},
} as const;

Expand Down Expand Up @@ -443,6 +445,7 @@ type OnyxFormValuesMapping = {
[ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM]: FormTypes.ReimbursementAccountForm;
[ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT]: FormTypes.PersonalBankAccountForm;
[ONYXKEYS.FORMS.WORKSPACE_DESCRIPTION_FORM]: FormTypes.WorkspaceDescriptionForm;
[ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS]: FormTypes.AdditionalDetailStepForm;
};

type OnyxFormDraftValuesMapping = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/withCurrentUserPersonalDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ export default function <TProps extends WithCurrentUserPersonalDetailsProps, TRe
}

export {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps};
export type {WithCurrentUserPersonalDetailsProps};
export type {WithCurrentUserPersonalDetailsProps, CurrentUserPersonalDetails};
3 changes: 2 additions & 1 deletion src/libs/PersonalDetailsUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Str from 'expensify-common/lib/str';
import type {OnyxEntry, OnyxUpdate} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {CurrentUserPersonalDetails} from '@components/withCurrentUserPersonalDetails';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {PersonalDetails, PersonalDetailsList, PrivatePersonalDetails} from '@src/types/onyx';
Expand Down Expand Up @@ -235,7 +236,7 @@ function createDisplayName(login: string, passedPersonalDetails: Pick<PersonalDe
* If the login is the same as the displayName, then they don't exist,
* so we return empty strings instead.
*/
function extractFirstAndLastNameFromAvailableDetails({login, displayName, firstName, lastName}: PersonalDetails): FirstAndLastName {
function extractFirstAndLastNameFromAvailableDetails({login, displayName, firstName, lastName}: CurrentUserPersonalDetails): FirstAndLastName {
// It's possible for firstName to be empty string, so we must use "||" to consider lastName instead.
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if (firstName || lastName) {
Expand Down
10 changes: 5 additions & 5 deletions src/libs/actions/Wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function openOnfidoFlow() {
API.read(READ_COMMANDS.OPEN_ONFIDO_FLOW, {}, {optimisticData, finallyData});
}

function setAdditionalDetailsQuestions(questions: WalletAdditionalQuestionDetails[], idNumber: string) {
function setAdditionalDetailsQuestions(questions: WalletAdditionalQuestionDetails[] | null, idNumber?: string) {
Onyx.merge(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, {questions, idNumber});
}

Expand All @@ -79,7 +79,7 @@ function updatePersonalDetails(personalDetails: UpdatePersonalDetailsForWalletPa
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.WALLET_ADDITIONAL_DETAILS,
key: ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS,
value: {
isLoading: true,
errors: null,
Expand All @@ -91,7 +91,7 @@ function updatePersonalDetails(personalDetails: UpdatePersonalDetailsForWalletPa
const finallyData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.WALLET_ADDITIONAL_DETAILS,
key: ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS,
value: {
isLoading: false,
},
Expand Down Expand Up @@ -232,7 +232,7 @@ function answerQuestionsForWallet(answers: WalletQuestionAnswer[], idNumber: str
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.WALLET_ADDITIONAL_DETAILS,
key: ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS,
value: {
isLoading: true,
},
Expand All @@ -242,7 +242,7 @@ function answerQuestionsForWallet(answers: WalletQuestionAnswer[], idNumber: str
const finallyData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.WALLET_ADDITIONAL_DETAILS,
key: ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS,
value: {
isLoading: false,
},
Expand Down
72 changes: 0 additions & 72 deletions src/pages/EnablePayments/ActivateStep.js

This file was deleted.

59 changes: 59 additions & 0 deletions src/pages/EnablePayments/ActivateStep.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import ConfirmationPage from '@components/ConfirmationPage';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import LottieAnimations from '@components/LottieAnimations';
import useLocalize from '@hooks/useLocalize';
import * as PaymentMethods from '@userActions/PaymentMethods';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {UserWallet, WalletTerms} from '@src/types/onyx';

type ActivateStepOnyxProps = {
/** Information about the user accepting the terms for payments */
walletTerms: OnyxEntry<WalletTerms>;
};

type ActivateStepProps = ActivateStepOnyxProps & {
/** The user's wallet */
userWallet: OnyxEntry<UserWallet>;
};

function ActivateStep({userWallet, walletTerms}: ActivateStepProps) {
const {translate} = useLocalize();
const isActivatedWallet = userWallet?.tierName && [CONST.WALLET.TIER_NAME.GOLD, CONST.WALLET.TIER_NAME.PLATINUM].some((name) => name === userWallet.tierName);

const animation = isActivatedWallet ? LottieAnimations.Fireworks : LottieAnimations.ReviewingBankInfo;
let continueButtonText = '';

if (walletTerms?.chatReportID) {
continueButtonText = translate('activateStep.continueToPayment');
} else if (walletTerms?.source === CONST.KYC_WALL_SOURCE.ENABLE_WALLET) {
continueButtonText = translate('common.continue');
} else {
continueButtonText = translate('activateStep.continueToTransfer');
}

return (
<>
<HeaderWithBackButton title={translate('activateStep.headerTitle')} />
<ConfirmationPage
animation={animation}
heading={translate(`activateStep.${isActivatedWallet ? 'activated' : 'checkBackLater'}Title`)}
description={translate(`activateStep.${isActivatedWallet ? 'activated' : 'checkBackLater'}Message`)}
shouldShowButton={isActivatedWallet}
buttonText={continueButtonText}
onButtonPress={() => PaymentMethods.continueSetup()}
/>
</>
);
}

ActivateStep.displayName = 'ActivateStep';

export default withOnyx<ActivateStepProps, ActivateStepOnyxProps>({
walletTerms: {
key: ONYXKEYS.WALLET_TERMS,
},
})(ActivateStep);
Loading
Loading