Skip to content

Commit 207c3c1

Browse files
committed
implement getWithdrawalIDSections and getSortedWithdrawalIDData
1 parent df194a6 commit 207c3c1

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

src/components/SelectionList/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ type TransactionMemberGroupListItemType = TransactionGroupListItemType & {groupe
354354

355355
type TransactionCardGroupListItemType = TransactionGroupListItemType & {groupedBy: typeof CONST.SEARCH.GROUP_BY.CARD} & SearchPersonalDetails & SearchCardGroup;
356356

357-
type TransactionWithdrawalIDGroupListItemType = TransactionGroupListItemType & {groupedBy: typeof CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID} & SearchPersonalDetails & SearchWithdrawalIDGroup;
357+
type TransactionWithdrawalIDGroupListItemType = TransactionGroupListItemType & {groupedBy: typeof CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID} & SearchWithdrawalIDGroup;
358358

359359
type ListItemProps<TItem extends ListItem> = CommonListItemProps<TItem> & {
360360
/** The section list item */

src/libs/SearchUIUtils.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import type {
5454
SearchTask,
5555
SearchTransaction,
5656
SearchTransactionAction,
57+
SearchWithdrawalIDGroup,
5758
} from '@src/types/onyx/SearchResults';
5859
import type IconAsset from '@src/types/utils/IconAsset';
5960
import {canApproveIOU, canIOUBePaid, canSubmitReport} from './actions/IOU';
@@ -1392,8 +1393,21 @@ function getCardSections(data: OnyxTypes.SearchResults['data']): TransactionCard
13921393
* Do not use directly, use only via `getSections()` facade.
13931394
*/
13941395
function getWithdrawalIDSections(data: OnyxTypes.SearchResults['data']): TransactionWithdrawalIDGroupListItemType[] {
1395-
// Will be implemented as part of https://github.com/Expensify/App/pull/66078
1396-
return data ? [] : [];
1396+
const withdrawalIDSections: Record<string, TransactionWithdrawalIDGroupListItemType> = {};
1397+
1398+
for (const key in data) {
1399+
if (isGroupEntry(key)) {
1400+
const withdrawalIDGroup = data[key] as SearchWithdrawalIDGroup;
1401+
1402+
withdrawalIDSections[key] = {
1403+
groupedBy: CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID,
1404+
transactions: [],
1405+
...withdrawalIDGroup,
1406+
};
1407+
}
1408+
}
1409+
1410+
return Object.values(withdrawalIDSections);
13971411
}
13981412

13991413
/**
@@ -1481,7 +1495,7 @@ function getSortedSections(
14811495
case CONST.SEARCH.GROUP_BY.CARD:
14821496
return getSortedCardData(data as TransactionCardGroupListItemType[], localeCompare);
14831497
case CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID:
1484-
return getSortedWithdrawalIDData(data as TransactionWithdrawalIDGroupListItemType[]);
1498+
return getSortedWithdrawalIDData(data as TransactionWithdrawalIDGroupListItemType[], localeCompare);
14851499
}
14861500
}
14871501

@@ -1576,27 +1590,26 @@ function getSortedReportData(data: TransactionReportGroupListItemType[], localeC
15761590

15771591
/**
15781592
* @private
1579-
* Sorts report sections based on a specified column and sort order.
1593+
* Sorts member sections based on a specified column and sort order.
15801594
*/
15811595
function getSortedMemberData(data: TransactionMemberGroupListItemType[], localeCompare: LocaleContextProps['localeCompare']) {
15821596
return data.sort((a, b) => localeCompare(a.displayName ?? a.login ?? '', b.displayName ?? b.login ?? ''));
15831597
}
15841598

15851599
/**
15861600
* @private
1587-
* Sorts report sections based on a specified column and sort order.
1601+
* Sorts card sections based on a specified column and sort order.
15881602
*/
15891603
function getSortedCardData(data: TransactionCardGroupListItemType[], localeCompare: LocaleContextProps['localeCompare']) {
15901604
return data.sort((a, b) => localeCompare(a.displayName ?? a.login ?? '', b.displayName ?? b.login ?? ''));
15911605
}
15921606

15931607
/**
15941608
* @private
1595-
* Sorts report sections based on a specified column and sort order.
1609+
* Sorts withdrawal ID sections based on a specified column and sort order.
15961610
*/
1597-
function getSortedWithdrawalIDData(data: TransactionWithdrawalIDGroupListItemType[]) {
1598-
// Will be implemented as part of https://github.com/Expensify/App/pull/66078
1599-
return data ? [] : [];
1611+
function getSortedWithdrawalIDData(data: TransactionWithdrawalIDGroupListItemType[], localeCompare: LocaleContextProps['localeCompare']) {
1612+
return data.sort((a, b) => localeCompare(b.debitPosted, a.debitPosted));
16001613
}
16011614

16021615
/**

0 commit comments

Comments
 (0)