Skip to content

Commit

Permalink
Merge pull request #43095 from VickyStash/bugfix/send-invoice-params
Browse files Browse the repository at this point in the history
Update `SendInvoiceParams` typing
  • Loading branch information
puneetlath authored Jun 5, 2024
2 parents e8f46a8 + 72b8618 commit 0efe60a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 31 deletions.
41 changes: 23 additions & 18 deletions src/libs/API/parameters/SendInvoiceParams.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
type SendInvoiceParams = {
senderWorkspaceID: string;
accountID: number;
receiverEmail?: string;
receiverInvoiceRoomID?: string;
amount: number;
currency: string;
comment: string;
merchant: string;
date: string;
category?: string;
invoiceRoomReportID?: string;
createdChatReportActionID: string;
invoiceReportID: string;
reportPreviewReportActionID: string;
transactionID: string;
transactionThreadReportID: string;
};
import type {RequireAtLeastOne} from 'type-fest';

type SendInvoiceParams = RequireAtLeastOne<
{
senderWorkspaceID: string;
accountID: number;
receiverEmail?: string;
receiverInvoiceRoomID?: string;
amount: number;
currency: string;
comment: string;
merchant: string;
date: string;
category?: string;
invoiceRoomReportID?: string;
createdChatReportActionID: string;
invoiceReportID: string;
reportPreviewReportActionID: string;
transactionID: string;
transactionThreadReportID: string;
},
'receiverEmail' | 'receiverInvoiceRoomID'
>;

export default SendInvoiceParams;
15 changes: 2 additions & 13 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3514,7 +3514,7 @@ function sendInvoice(
const {senderWorkspaceID, receiver, invoiceRoom, createdChatReportActionID, invoiceReportID, reportPreviewReportActionID, transactionID, transactionThreadReportID, onyxData} =
getSendInvoiceInformation(transaction, currentUserAccountID, invoiceChatReport, receiptFile, policy, policyTagList, policyCategories);

let parameters: SendInvoiceParams = {
const parameters: SendInvoiceParams = {
senderWorkspaceID,
accountID: currentUserAccountID,
amount: transaction?.amount ?? 0,
Expand All @@ -3529,20 +3529,9 @@ function sendInvoice(
reportPreviewReportActionID,
transactionID,
transactionThreadReportID,
...(invoiceChatReport?.reportID ? {receiverInvoiceRoomID: invoiceChatReport.reportID} : {receiverEmail: receiver.login ?? ''}),
};

if (invoiceChatReport) {
parameters = {
...parameters,
receiverInvoiceRoomID: invoiceChatReport.reportID,
};
} else {
parameters = {
...parameters,
receiverEmail: receiver.login,
};
}

API.write(WRITE_COMMANDS.SEND_INVOICE, parameters, onyxData);

Navigation.dismissModalWithReport(invoiceRoom);
Expand Down

0 comments on commit 0efe60a

Please sign in to comment.