Skip to content

Commit

Permalink
update type
Browse files Browse the repository at this point in the history
  • Loading branch information
hungvu193 committed Feb 7, 2025
1 parent d9a2b1a commit 639a80f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6634,10 +6634,10 @@ const CONST = {
},
},
LAST_PAYMENT_METHOD: {
DEFAULT: 'DEFAULT',
IOU: 'IOU',
EXPENSE: 'EXPENSE',
INVOICE: 'INVOICE',
LAST_USED: 'lastUsed',
IOU: 'Iou',
EXPENSE: 'Expense',
INVOICE: 'Invoice',
},
SKIPPABLE_COLLECTION_MEMBER_IDS: [String(DEFAULT_NUMBER_ID), '-1', 'undefined', 'null', 'NaN'] as string[],
SETUP_SPECIALIST_LOGIN: 'Setup Specialist',
Expand Down
4 changes: 2 additions & 2 deletions src/components/Search/SearchPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ function SearchPageHeader({queryJSON}: SearchPageHeaderProps) {
report.action === CONST.SEARCH.ACTION_TYPES.PAY &&
report.policyID &&
((!!lastPaymentMethods[report.policyID] && typeof lastPaymentMethods[report.policyID] === 'string') ||
!!(lastPaymentMethods[report.policyID] as LastPaymentMethodType)?.DEFAULT),
!!(lastPaymentMethods[report.policyID] as LastPaymentMethodType)?.lastUsed),
)
: selectedTransactionsKeys.every(
(id) =>
selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.PAY &&
selectedTransactions[id].policyID &&
((!!lastPaymentMethods[selectedTransactions[id].policyID] && typeof lastPaymentMethods[selectedTransactions[id].policyID] === 'string') ||
!!(lastPaymentMethods[selectedTransactions[id].policyID] as LastPaymentMethodType).DEFAULT),
!!(lastPaymentMethods[selectedTransactions[id].policyID] as LastPaymentMethodType).lastUsed),
));

if (shouldShowPayOption) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/SettlementButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function SettlementButton({
if (typeof paymentMethod?.[policyIDKey] === 'string') {
return paymentMethod?.[policyIDKey];
}
return (paymentMethod?.[policyIDKey] as LastPaymentMethodType)?.DEFAULT;
return (paymentMethod?.[policyIDKey] as LastPaymentMethodType)?.lastUsed;
},
});

Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function getLastPolicyPaymentMethod(policyID: string | undefined, lastPaymentMet
if (typeof lastPaymentMethods?.[policyID] === 'string') {
lastPolicyPaymentMethod = lastPaymentMethods?.[policyID] as ValueOf<typeof CONST.IOU.PAYMENT_TYPE>;
} else {
lastPolicyPaymentMethod = (lastPaymentMethods?.[policyID] as LastPaymentMethodType)?.DEFAULT as ValueOf<typeof CONST.IOU.PAYMENT_TYPE>;
lastPolicyPaymentMethod = (lastPaymentMethods?.[policyID] as LastPaymentMethodType)?.lastUsed as ValueOf<typeof CONST.IOU.PAYMENT_TYPE>;
}

return lastPolicyPaymentMethod;
Expand All @@ -97,7 +97,7 @@ function getPayActionCallback(hash: number, item: TransactionListItemType | Repo
if (typeof lastPaymentMethod?.[item.policyID] === 'string') {
lastPolicyPaymentMethod = lastPaymentMethod?.[item.policyID] as ValueOf<typeof CONST.IOU.PAYMENT_TYPE>;
} else {
lastPolicyPaymentMethod = (lastPaymentMethod?.[item.policyID] as LastPaymentMethodType)?.DEFAULT as ValueOf<typeof CONST.IOU.PAYMENT_TYPE>;
lastPolicyPaymentMethod = (lastPaymentMethod?.[item.policyID] as LastPaymentMethodType)?.lastUsed as ValueOf<typeof CONST.IOU.PAYMENT_TYPE>;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/types/onyx/LastPaymentMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
*/
type LastPaymentMethodType = {
/** The default last payment method, this one holds the existing data of the old lastPaymentMethod value which is string */
DEFAULT: string;
lastUsed: string;
/** The lastPaymentMethod of an IOU */
IOU: string;
Iou: string;
/** The lastPaymentMethod of an Expense */
EXPENSE: string;
Expense: string;
/** The lastPaymentMethod of an Invoice */
INVOICE: string;
Invoice: string;
};

/** Record of last payment methods, indexed by policy id */
Expand Down

0 comments on commit 639a80f

Please sign in to comment.