Skip to content

Commit 22116f7

Browse files
authored
Merge pull request #97680 from marufsharifi/fix/66327-money-request-builder-phone-formatter-part25
[Part 25] Remove Onyx.connect from LocalePhoneNumber
2 parents ba756ed + 9249441 commit 22116f7

27 files changed

Lines changed: 205 additions & 18 deletions

src/components/AddExistingExpenseFooter.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type AddExistingExpenseFooterProps = {
4747
};
4848

4949
function AddExistingExpenseFooter({selectedIds, report, reportToConfirm, policy, policyCategories, errorMessage, setErrorMessage}: AddExistingExpenseFooterProps) {
50-
const {translate} = useLocalize();
50+
const {translate, formatPhoneNumber} = useLocalize();
5151
const styles = useThemeStyles();
5252
const {isBetaEnabled} = usePermissions();
5353
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
@@ -96,6 +96,7 @@ function AddExistingExpenseFooter({selectedIds, report, reportToConfirm, policy,
9696
selfDMReportActions,
9797
delegateAccountID,
9898
isTrackIntentUser,
99+
formatPhoneNumber,
99100
});
100101
} else {
101102
changeTransactionsReport({

src/hooks/useDeleteTransactions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {useCurrencyListActions} from './useCurrencyList';
3636
import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails';
3737
import useDelegateAccountID from './useDelegateAccountID';
3838
import useEnvironment from './useEnvironment';
39+
import useLocalize from './useLocalize';
3940
import useNetwork from './useNetwork';
4041
import useOnyx from './useOnyx';
4142
import usePermissions from './usePermissions';
@@ -110,6 +111,7 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac
110111
const restrictedActionPolicyID = useRestrictedActionPolicyID(policy);
111112
const {isOffline} = useNetwork();
112113
const {isProduction} = useEnvironment();
114+
const {formatPhoneNumber} = useLocalize();
113115

114116
const getSplitExpenseEditTransactionOnDelete = useCallback(
115117
(transactionIDs: string[]): Transaction | undefined => {
@@ -343,6 +345,7 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac
343345
isOffline,
344346
delegateAccountID,
345347
isTrackIntentUser,
348+
formatPhoneNumber,
346349
});
347350
}
348351

@@ -422,6 +425,7 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac
422425
personalPolicy?.outputCurrency,
423426
delegateAccountID,
424427
isTrackIntentUser,
428+
formatPhoneNumber,
425429
getCurrencyDecimals,
426430
getCurrencySymbol,
427431
],

src/libs/IOUAmountSubmission.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {LocalizedTranslate} from '@components/LocaleContextProvider';
1+
import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleContextProvider';
22

33
import type {CurrencyListActionsContextType} from '@hooks/useCurrencyList';
44

@@ -82,6 +82,7 @@ type SubmitAmountArgs = {
8282
amount: string;
8383
paymentMethod?: PaymentMethodType;
8484
translate: LocalizedTranslate;
85+
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
8586

8687
// Submit-time Onyx data — supplied by the screen via AmountSubmitDataSync so this module owns no subscriptions.
8788
allPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetailsList>;
@@ -323,6 +324,7 @@ function submitSkipConfirmationExpense(args: SubmitAmountArgs, ctx: SubmitAmount
323324
action,
324325
currentUserPersonalDetails,
325326
isTrackIntentUser,
327+
formatPhoneNumber,
326328
getCurrencyDecimals,
327329
} = args;
328330
const {currentUserAccountID, currentUserEmail, existingTransactionID, isASAPSubmitBetaEnabled, newAmount: backendAmount} = ctx;
@@ -410,6 +412,7 @@ function submitSkipConfirmationExpense(args: SubmitAmountArgs, ctx: SubmitAmount
410412
optimisticTransactionID,
411413
delegateAccountID,
412414
isTrackIntentUser,
415+
formatPhoneNumber,
413416
getCurrencyDecimals,
414417
});
415418
}

src/libs/actions/IOU/Duplicate.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,7 @@ function duplicateExpenseTransaction({
872872
shouldDeferAutoSubmit,
873873
isTrackIntentUser,
874874
delegateAccountID,
875+
formatPhoneNumber,
875876
getCurrencyDecimals,
876877
};
877878

@@ -1108,6 +1109,7 @@ function duplicateReport({
11081109
shouldDeferAutoSubmit: !isLastExpense,
11091110
isTrackIntentUser,
11101111
delegateAccountID,
1112+
formatPhoneNumber,
11111113
getCurrencyDecimals,
11121114
};
11131115

src/libs/actions/IOU/MoneyRequest.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ type CreateTransactionParams = {
102102
currentUserLocalCurrency: string | undefined;
103103
isTrackIntentUser: boolean | undefined;
104104
delegateAccountID: number | undefined;
105+
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
105106
getCurrencyDecimals: CurrencyListActionsContextType['getCurrencyDecimals'];
106107
};
107108

@@ -146,6 +147,7 @@ function createTransaction({
146147
currentUserLocalCurrency,
147148
isTrackIntentUser,
148149
delegateAccountID,
150+
formatPhoneNumber,
149151
getCurrencyDecimals,
150152
}: CreateTransactionParams) {
151153
const draftTransactionIDs = Object.keys(allTransactionDrafts ?? {});
@@ -256,6 +258,7 @@ function createTransaction({
256258
optimisticTransactionID,
257259
isTrackIntentUser,
258260
delegateAccountID,
261+
formatPhoneNumber,
259262
getCurrencyDecimals,
260263
});
261264
}

src/libs/actions/IOU/MoneyRequestBuilder.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import type {LocaleContextProps} from '@components/LocaleContextProvider';
2+
13
import type {CurrencyListActionsContextType} from '@hooks/useCurrencyList';
24

35
import DateUtils from '@libs/DateUtils';
46
import {getMicroSecondOnyxErrorObject, getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils';
57
import {isLocalFile} from '@libs/fileDownload/FileUtils';
68
import type {MinimalTransaction} from '@libs/Formula';
79
import {updateIOUOwnerAndTotal} from '@libs/IOUUtils';
8-
import {formatPhoneNumber} from '@libs/LocalePhoneNumber';
910
import {translateLocal} from '@libs/Localize';
1011
import {buildOptimisticNextStep} from '@libs/NextStepUtils';
1112
import {rand64} from '@libs/NumberUtils';
@@ -196,6 +197,7 @@ type RequestMoneyInformation = {
196197
shouldDeferAutoSubmit?: boolean;
197198
delegateAccountID: number | undefined;
198199
isTrackIntentUser: boolean | undefined;
200+
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
199201
getCurrencyDecimals: CurrencyListActionsContextType['getCurrencyDecimals'];
200202
};
201203

@@ -232,6 +234,7 @@ type MoneyRequestInformationParams = {
232234
personalDetails: OnyxEntry<OnyxTypes.PersonalDetailsList>;
233235
isTrackIntentUser: boolean | undefined;
234236
delegateAccountID: number | undefined;
237+
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
235238
getCurrencyDecimals: CurrencyListActionsContextType['getCurrencyDecimals'];
236239
};
237240

@@ -1285,6 +1288,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma
12851288
betas,
12861289
delegateAccountID,
12871290
isTrackIntentUser,
1291+
formatPhoneNumber,
12881292
getCurrencyDecimals,
12891293
} = moneyRequestInformation;
12901294
const {payeeAccountID = currentUserAccountIDParam, payeeEmail = currentUserEmailParam, participant} = participantParams;

src/libs/actions/IOU/Split.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
22292229
delegateAccountID,
22302230
isTrackIntentUser,
22312231
optimisticChatReportID,
2232+
formatPhoneNumber,
22322233
getCurrencyDecimals,
22332234
});
22342235

src/libs/actions/IOU/SplitTransactionUpdate.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type {LocaleContextProps} from '@components/LocaleContextProvider';
12
import type {SearchActionsContextValue, SearchStateContextValue} from '@components/Search/types';
23

34
import type {CurrencyListActionsContextType} from '@hooks/useCurrencyList';
@@ -121,6 +122,7 @@ type UpdateSplitTransactionsParams = {
121122
isOffline: boolean;
122123
delegateAccountID: number | undefined;
123124
isTrackIntentUser: boolean | undefined;
125+
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
124126
getCurrencyDecimals: CurrencyListActionsContextType['getCurrencyDecimals'];
125127
};
126128

@@ -203,6 +205,7 @@ function updateSplitTransactions({
203205
isOffline,
204206
delegateAccountID,
205207
isTrackIntentUser,
208+
formatPhoneNumber,
206209
getCurrencyDecimals,
207210
}: UpdateSplitTransactionsParams) {
208211
const parentTransactionReport = getReportOrDraftReport(transactionReport?.parentReportID);
@@ -666,6 +669,7 @@ function updateSplitTransactions({
666669
personalDetails,
667670
delegateAccountID,
668671
isTrackIntentUser,
672+
formatPhoneNumber,
669673
getCurrencyDecimals,
670674
} as MoneyRequestInformationParams;
671675

@@ -781,6 +785,7 @@ function updateSplitTransactions({
781785
personalDetails,
782786
delegateAccountID,
783787
isTrackIntentUser,
788+
formatPhoneNumber,
784789
getCurrencyDecimals,
785790
});
786791

src/libs/actions/IOU/TrackExpense.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import ReceiptGeneric from '@assets/images/receipt-generic.png';
22

3+
import type {LocaleContextProps} from '@components/LocaleContextProvider';
4+
35
import type {CurrencyListActionsContextType} from '@hooks/useCurrencyList';
46

57
import * as API from '@libs/API';
@@ -1666,6 +1668,7 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation): {iouRep
16661668
shouldDeferAutoSubmit,
16671669
delegateAccountID,
16681670
isTrackIntentUser,
1671+
formatPhoneNumber,
16691672
getCurrencyDecimals,
16701673
} = requestMoneyInformation;
16711674
const {payeeAccountID} = participantParams;
@@ -1777,6 +1780,7 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation): {iouRep
17771780
personalDetails,
17781781
delegateAccountID,
17791782
isTrackIntentUser,
1783+
formatPhoneNumber,
17801784
getCurrencyDecimals,
17811785
});
17821786
const activeReportID = isMoneyRequestReport ? report?.reportID : chatReport.reportID;
@@ -1973,6 +1977,7 @@ function convertBulkTrackedExpensesToIOU({
19731977
selfDMReportActions,
19741978
delegateAccountID,
19751979
isTrackIntentUser,
1980+
formatPhoneNumber,
19761981
getCurrencyDecimals,
19771982
}: {
19781983
transactions: OnyxTypes.Transaction[];
@@ -1990,6 +1995,7 @@ function convertBulkTrackedExpensesToIOU({
19901995
selfDMReportActions: OnyxEntry<OnyxTypes.ReportActions>;
19911996
delegateAccountID: number | undefined;
19921997
isTrackIntentUser: boolean | undefined;
1998+
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
19931999
getCurrencyDecimals: CurrencyListActionsContextType['getCurrencyDecimals'];
19942000
}) {
19952001
const iouReportID = iouReport?.reportID;
@@ -2111,6 +2117,7 @@ function convertBulkTrackedExpensesToIOU({
21112117
},
21122118
delegateAccountID,
21132119
isTrackIntentUser,
2120+
formatPhoneNumber,
21142121
getCurrencyDecimals,
21152122
});
21162123

src/pages/Share/SubmitDetailsPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function SubmitDetailsPage({
8383
},
8484
}: ShareDetailsPageProps) {
8585
const styles = useThemeStyles();
86-
const {translate, dateFnsLocale} = useLocalize();
86+
const {translate, dateFnsLocale, formatPhoneNumber} = useLocalize();
8787
const {getCurrencyDecimals} = useCurrencyListActions();
8888
const delegateAccountID = useDelegateAccountID();
8989
const [unknownUserDetails] = useOnyx(ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS);
@@ -457,6 +457,7 @@ function SubmitDetailsPage({
457457
optimisticTransactionID,
458458
isTrackIntentUser,
459459
delegateAccountID,
460+
formatPhoneNumber,
460461
optimisticChatReportID: routeReportID,
461462
});
462463
}

0 commit comments

Comments
 (0)