Skip to content

Commit 06e4e74

Browse files
authored
Merge pull request Expensify#88105 from Expensify/revert-87361-perf/extract-money-report-header-actions
[CP Staging] Revert "Extract secondary action hooks and components from MoneyReportHeader"
2 parents 19d70c2 + 458ed8b commit 06e4e74

18 files changed

Lines changed: 2055 additions & 2578 deletions

src/components/MoneyReportHeader.tsx

Lines changed: 1990 additions & 54 deletions
Large diffs are not rendered by default.

src/components/MoneyReportHeaderActions/MoneyReportHeaderSecondaryActions.tsx

Lines changed: 0 additions & 397 deletions
This file was deleted.

src/components/MoneyReportHeaderActions/MoneyReportHeaderSelectionDropdown.tsx

Lines changed: 0 additions & 532 deletions
This file was deleted.

src/components/MoneyReportHeaderActions/index.tsx

Lines changed: 0 additions & 101 deletions
This file was deleted.

src/components/MoneyReportHeaderActions/types.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/components/MoneyReportHeaderPrimaryAction/ApprovePrimaryAction.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import Button from '@components/Button';
3-
import {usePaymentAnimationsContext} from '@components/PaymentAnimationsContext';
43
import useLocalize from '@hooks/useLocalize';
54
import useOnyx from '@hooks/useOnyx';
65
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
@@ -10,10 +9,10 @@ import useConfirmApproval from './useConfirmApproval';
109

1110
type ApprovePrimaryActionProps = {
1211
reportID: string | undefined;
12+
startApprovedAnimation: () => void;
1313
};
1414

15-
function ApprovePrimaryAction({reportID}: ApprovePrimaryActionProps) {
16-
const {startApprovedAnimation} = usePaymentAnimationsContext();
15+
function ApprovePrimaryAction({reportID, startApprovedAnimation}: ApprovePrimaryActionProps) {
1716
const {translate} = useLocalize();
1817

1918
const [moneyRequestReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);

src/components/MoneyReportHeaderPrimaryAction/PayPrimaryAction.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {hasSeenTourSelector} from '@selectors/Onboarding';
22
import React from 'react';
33
import {useDelegateNoAccessActions, useDelegateNoAccessState} from '@components/DelegateNoAccessModalProvider';
44
import {useMoneyReportHeaderModals} from '@components/MoneyReportHeaderModalsContext';
5-
import {usePaymentAnimationsContext} from '@components/PaymentAnimationsContext';
65
import {useSearchStateContext} from '@components/Search/SearchContext';
76
import AnimatedSettlementButton from '@components/SettlementButton/AnimatedSettlementButton';
87
import type {PaymentActionParams} from '@components/SettlementButton/types';
@@ -30,10 +29,14 @@ import useTransactionThreadData from './useTransactionThreadData';
3029
type PayPrimaryActionProps = {
3130
reportID: string | undefined;
3231
chatReportID: string | undefined;
32+
isPaidAnimationRunning: boolean;
33+
isApprovedAnimationRunning: boolean;
34+
stopAnimation: () => void;
35+
startAnimation: () => void;
36+
startApprovedAnimation: () => void;
3337
};
3438

35-
function PayPrimaryAction({reportID, chatReportID}: PayPrimaryActionProps) {
36-
const {isPaidAnimationRunning, isApprovedAnimationRunning, stopAnimation, startAnimation, startApprovedAnimation} = usePaymentAnimationsContext();
39+
function PayPrimaryAction({reportID, chatReportID, isPaidAnimationRunning, isApprovedAnimationRunning, stopAnimation, startAnimation, startApprovedAnimation}: PayPrimaryActionProps) {
3740
const {isOffline} = useNetwork();
3841
const {accountID, email} = useCurrentUserPersonalDetails();
3942
const {isDelegateAccessRestricted} = useDelegateNoAccessState();

src/components/MoneyReportHeaderPrimaryAction/SubmitPrimaryAction.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {delegateEmailSelector} from '@selectors/Account';
22
import React from 'react';
33
import AnimatedSubmitButton from '@components/AnimatedSubmitButton';
4-
import {usePaymentAnimationsContext} from '@components/PaymentAnimationsContext';
54
import {useSearchStateContext} from '@components/Search/SearchContext';
65
import useConfirmPendingRTERAndProceed from '@hooks/useConfirmPendingRTERAndProceed';
76
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
@@ -25,10 +24,12 @@ import ONYXKEYS from '@src/ONYXKEYS';
2524

2625
type SubmitPrimaryActionProps = {
2726
reportID: string | undefined;
27+
isSubmittingAnimationRunning: boolean;
28+
stopAnimation: () => void;
29+
startSubmittingAnimation: () => void;
2830
};
2931

30-
function SubmitPrimaryAction({reportID}: SubmitPrimaryActionProps) {
31-
const {isSubmittingAnimationRunning, stopAnimation, startSubmittingAnimation} = usePaymentAnimationsContext();
32+
function SubmitPrimaryAction({reportID, isSubmittingAnimationRunning, stopAnimation, startSubmittingAnimation}: SubmitPrimaryActionProps) {
3233
const {translate} = useLocalize();
3334
const {isOffline} = useNetwork();
3435
const {accountID, email} = useCurrentUserPersonalDetails();

src/components/MoneyReportHeaderPrimaryAction/index.tsx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,53 @@ import ReviewDuplicatesPrimaryAction from './ReviewDuplicatesPrimaryAction';
1010
import SubmitPrimaryAction from './SubmitPrimaryAction';
1111
import type {MoneyReportHeaderPrimaryActionProps} from './types';
1212

13-
function MoneyReportHeaderPrimaryAction({reportID, chatReportID, primaryAction, onExportModalOpen}: MoneyReportHeaderPrimaryActionProps) {
13+
function MoneyReportHeaderPrimaryAction({
14+
reportID,
15+
chatReportID,
16+
primaryAction,
17+
isPaidAnimationRunning,
18+
isApprovedAnimationRunning,
19+
isSubmittingAnimationRunning,
20+
stopAnimation,
21+
startAnimation,
22+
startApprovedAnimation,
23+
startSubmittingAnimation,
24+
onExportModalOpen,
25+
}: MoneyReportHeaderPrimaryActionProps) {
1426
if (!primaryAction) {
1527
return null;
1628
}
1729

1830
if (primaryAction === CONST.REPORT.PRIMARY_ACTIONS.SUBMIT) {
19-
return <SubmitPrimaryAction reportID={reportID} />;
31+
return (
32+
<SubmitPrimaryAction
33+
reportID={reportID}
34+
isSubmittingAnimationRunning={isSubmittingAnimationRunning}
35+
stopAnimation={stopAnimation}
36+
startSubmittingAnimation={startSubmittingAnimation}
37+
/>
38+
);
2039
}
2140

2241
if (primaryAction === CONST.REPORT.PRIMARY_ACTIONS.APPROVE) {
23-
return <ApprovePrimaryAction reportID={reportID} />;
42+
return (
43+
<ApprovePrimaryAction
44+
reportID={reportID}
45+
startApprovedAnimation={startApprovedAnimation}
46+
/>
47+
);
2448
}
2549

2650
if (primaryAction === CONST.REPORT.PRIMARY_ACTIONS.PAY) {
2751
return (
2852
<PayPrimaryAction
2953
reportID={reportID}
3054
chatReportID={chatReportID}
55+
isPaidAnimationRunning={isPaidAnimationRunning}
56+
isApprovedAnimationRunning={isApprovedAnimationRunning}
57+
stopAnimation={stopAnimation}
58+
startAnimation={startAnimation}
59+
startApprovedAnimation={startApprovedAnimation}
3160
/>
3261
);
3362
}

src/components/MoneyReportHeaderPrimaryAction/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ type MoneyReportHeaderPrimaryActionProps = {
55
reportID: string | undefined;
66
chatReportID: string | undefined;
77
primaryAction: ValueOf<typeof CONST.REPORT.PRIMARY_ACTIONS> | ValueOf<typeof CONST.REPORT.TRANSACTION_PRIMARY_ACTIONS> | '';
8+
isPaidAnimationRunning: boolean;
9+
isApprovedAnimationRunning: boolean;
10+
isSubmittingAnimationRunning: boolean;
11+
stopAnimation: () => void;
12+
startAnimation: () => void;
13+
startApprovedAnimation: () => void;
14+
startSubmittingAnimation: () => void;
815
onExportModalOpen: () => void;
916
};
1017

0 commit comments

Comments
 (0)