Skip to content

Commit

Permalink
add new function isSelectedFeedExpired
Browse files Browse the repository at this point in the history
  • Loading branch information
waterim committed Dec 21, 2024
1 parent c50a2ec commit ce3d2fb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libs/CardUtils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {fromUnixTime, isBefore} from 'date-fns';
import groupBy from 'lodash/groupBy';
import Onyx from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
Expand Down Expand Up @@ -352,6 +353,14 @@ function getSelectedFeed(lastSelectedFeed: OnyxEntry<CompanyCardFeed>, cardFeeds
return lastSelectedFeed ?? defaultFeed;
}

function isSelectedFeedExpired(directFeed: DirectCardFeedData | undefined): boolean {
if (!directFeed) {
return false;
}

return isBefore(fromUnixTime(directFeed.expiration), new Date());
}

/** Returns list of cards which can be assigned */
function getFilteredCardList(list: WorkspaceCardsList | undefined, directFeed: DirectCardFeedData | undefined) {
const {cardList: customFeedCardsToAssign, ...cards} = list ?? {};
Expand Down Expand Up @@ -403,6 +412,7 @@ export {
getEligibleBankAccountsForCard,
sortCardsByCardholderName,
getCardFeedIcon,
isSelectedFeedExpired,
getCardFeedName,
getCompanyFeeds,
isCustomFeed,
Expand Down

0 comments on commit ce3d2fb

Please sign in to comment.