Skip to content

Commit

Permalink
Merge pull request Expensify#35877 from ZhenjaHorbach/migrate-settlem…
Browse files Browse the repository at this point in the history
…entbutton-component-to-ts-2

[TS migration] Migrate 'SettlementButton.js' component to TypeScript PART-2
  • Loading branch information
mountiny authored Feb 6, 2024
2 parents 500dd09 + abcf695 commit 25e6a00
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/SettlementButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function SettlementButton({
}

if (iouPaymentType === CONST.IOU.REPORT_ACTION_TYPE.APPROVE) {
IOU.approveMoneyRequest(iouReport);
IOU.approveMoneyRequest(iouReport ?? {});
return;
}

Expand Down
5 changes: 2 additions & 3 deletions src/libs/API/parameters/PayMoneyRequestParams.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type CONST from '@src/CONST';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage';

type PayMoneyRequestParams = {
iouReportID: string;
chatReportID: string;
reportActionID: string;
paymentMethodType: DeepValueOf<typeof CONST.IOU.PAYMENT_TYPE>;
paymentMethodType: PaymentMethodType;
};

export default PayMoneyRequestParams;
5 changes: 2 additions & 3 deletions src/libs/API/parameters/SendMoneyParams.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type CONST from '@src/CONST';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage';

type SendMoneyParams = {
iouReportID: string;
chatReportID: string;
reportActionID: string;
paymentMethodType: DeepValueOf<typeof CONST.IOU.PAYMENT_TYPE>;
paymentMethodType: PaymentMethodType;
transactionID: string;
newIOUReportDetails: string;
createdReportActionID: string;
Expand Down
6 changes: 2 additions & 4 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ import type SCREENS from '@src/SCREENS';
import type * as OnyxTypes from '@src/types/onyx';
import type {Participant, Split} from '@src/types/onyx/IOU';
import type {ErrorFields, Errors} from '@src/types/onyx/OnyxCommon';
import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage';
import type ReportAction from '@src/types/onyx/ReportAction';
import type {OnyxData} from '@src/types/onyx/Request';
import type {Comment, Receipt, ReceiptSource, TaxRate, TransactionChanges, WaypointCollection} from '@src/types/onyx/Transaction';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
import type {EmptyObject} from '@src/types/utils/EmptyObject';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import * as Policy from './Policy';
Expand All @@ -63,8 +63,6 @@ type MoneyRequestRoute = StackScreenProps<MoneyRequestNavigatorParamList, typeof

type IOURequestType = ValueOf<typeof CONST.IOU.REQUEST_TYPE>;

type PaymentMethodType = DeepValueOf<typeof CONST.IOU.PAYMENT_TYPE>;

type OneOnOneIOUReport = OnyxTypes.Report | undefined | null;

type MoneyRequestInformation = {
Expand Down Expand Up @@ -3255,7 +3253,7 @@ function sendMoneyWithWallet(report: OnyxTypes.Report, amount: number, currency:
Report.notifyNewAction(params.chatReportID, managerID);
}

function approveMoneyRequest(expenseReport: OnyxTypes.Report) {
function approveMoneyRequest(expenseReport: OnyxTypes.Report | EmptyObject) {
const currentNextStep = allNextSteps[`${ONYXKEYS.COLLECTION.NEXT_STEP}${expenseReport.reportID}`] ?? null;

const optimisticApprovedReportAction = ReportUtils.buildOptimisticApprovedReportAction(expenseReport.total ?? 0, expenseReport.currency ?? '', expenseReport.reportID);
Expand Down

0 comments on commit 25e6a00

Please sign in to comment.