Skip to content

Commit e49dbce

Browse files
authored
Merge pull request Expensify#66078 from s77rt/add-BankWithdrawalListItemHeader
Search: Add WithdrawalIDListItemHeader
2 parents 78be1f1 + bb177dc commit e49dbce

20 files changed

Lines changed: 323 additions & 14 deletions

File tree

src/CONST/index.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5320,6 +5320,35 @@ const CONST = {
53205320
USAA: 'usaa',
53215321
},
53225322

5323+
/**
5324+
* Bank account names (user friendly)
5325+
*/
5326+
get BANK_NAMES_USER_FRIENDLY() {
5327+
return {
5328+
[this.BANK_NAMES.EXPENSIFY]: 'Expensify',
5329+
[this.BANK_NAMES.AMERICAN_EXPRESS]: 'American Express',
5330+
[this.BANK_NAMES.BANK_OF_AMERICA]: 'Bank of America',
5331+
[this.BANK_NAMES.BB_T]: 'Truist',
5332+
[this.BANK_NAMES.CAPITAL_ONE]: 'Capital One',
5333+
[this.BANK_NAMES.CHASE]: 'Chase',
5334+
[this.BANK_NAMES.CHARLES_SCHWAB]: 'Charles Schwab',
5335+
[this.BANK_NAMES.CITIBANK]: 'Citibank',
5336+
[this.BANK_NAMES.CITIZENS_BANK]: 'Citizens',
5337+
[this.BANK_NAMES.DISCOVER]: 'Discover',
5338+
[this.BANK_NAMES.FIDELITY]: 'Fidelity',
5339+
[this.BANK_NAMES.GENERIC_BANK]: 'Bank',
5340+
[this.BANK_NAMES.HUNTINGTON_BANK]: 'Huntington',
5341+
[this.BANK_NAMES.HUNTINGTON_NATIONAL]: 'Huntington National',
5342+
[this.BANK_NAMES.NAVY_FEDERAL_CREDIT_UNION]: 'Navy Federal Credit Union',
5343+
[this.BANK_NAMES.PNC]: 'PNC',
5344+
[this.BANK_NAMES.REGIONS_BANK]: 'Regions',
5345+
[this.BANK_NAMES.SUNTRUST]: 'SunTrust',
5346+
[this.BANK_NAMES.TD_BANK]: 'TD Bank',
5347+
[this.BANK_NAMES.US_BANK]: 'U.S. Bank',
5348+
[this.BANK_NAMES.USAA]: 'USAA',
5349+
};
5350+
},
5351+
53235352
/**
53245353
* Constants for maxToRenderPerBatch parameter that is used for FlatList or SectionList. This controls the amount of items rendered per batch, which is the next chunk of items
53255354
* rendered on every scroll.
@@ -6397,6 +6426,7 @@ const CONST = {
63976426
ASSIGNEE: 'assignee',
63986427
IN: 'in',
63996428
CARD: 'card',
6429+
WITHDRAWAL_ID: 'withdrawalID',
64006430
},
64016431
SYNTAX_OPERATORS: {
64026432
AND: 'and',

src/components/MoneyRequestReportView/MoneyRequestReportTableHeader.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const shouldShowColumnConfig: Record<SortableColumnName, (isIOUReport: boolean)
3131
[CONST.SEARCH.TABLE_COLUMNS.TITLE]: () => false,
3232
[CONST.SEARCH.TABLE_COLUMNS.ASSIGNEE]: () => false,
3333
[CONST.SEARCH.TABLE_COLUMNS.CARD]: () => false,
34+
[CONST.SEARCH.TABLE_COLUMNS.WITHDRAWAL_ID]: () => false,
3435
};
3536

3637
const columnConfig: ColumnConfig[] = [

src/components/Search/index.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141
isTransactionGroupListItemType,
4242
isTransactionListItemType,
4343
isTransactionMemberGroupListItemType,
44+
isTransactionWithdrawalIDGroupListItemType,
4445
shouldShowEmptyState,
4546
shouldShowYear as shouldShowYearUtil,
4647
} from '@libs/SearchUIUtils';
@@ -542,6 +543,10 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS
542543
return;
543544
}
544545

546+
if (isTransactionWithdrawalIDGroupListItemType(item)) {
547+
return;
548+
}
549+
545550
const isFromSelfDM = item.reportID === CONST.REPORT.UNREPORTED_REPORT_ID;
546551
const isTransactionItem = isTransactionListItemType(item);
547552

@@ -610,7 +615,13 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS
610615

611616
const isChat = type === CONST.SEARCH.DATA_TYPES.CHAT;
612617
const isTask = type === CONST.SEARCH.DATA_TYPES.TASK;
613-
const canSelectMultiple = !isChat && !isTask && (!isSmallScreenWidth || isMobileSelectionModeEnabled) && groupBy !== CONST.SEARCH.GROUP_BY.FROM && groupBy !== CONST.SEARCH.GROUP_BY.CARD;
618+
const canSelectMultiple =
619+
!isChat &&
620+
!isTask &&
621+
(!isSmallScreenWidth || isMobileSelectionModeEnabled) &&
622+
groupBy !== CONST.SEARCH.GROUP_BY.FROM &&
623+
groupBy !== CONST.SEARCH.GROUP_BY.CARD &&
624+
groupBy !== CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID;
614625
const ListItem = getListItem(type, status, groupBy);
615626
const sortedSelectedData = useMemo(
616627
() =>

src/components/SelectionList/Search/TransactionGroupListItem.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {
1313
TransactionListItemType,
1414
TransactionMemberGroupListItemType,
1515
TransactionReportGroupListItemType,
16+
TransactionWithdrawalIDGroupListItemType,
1617
} from '@components/SelectionList/types';
1718
import Text from '@components/Text';
1819
import TransactionItemRow from '@components/TransactionItemRow';
@@ -32,6 +33,7 @@ import ROUTES from '@src/ROUTES';
3233
import CardListItemHeader from './CardListItemHeader';
3334
import MemberListItemHeader from './MemberListItemHeader';
3435
import ReportListItemHeader from './ReportListItemHeader';
36+
import WithdrawalIDListItemHeader from './WithdrawalIDListItemHeader';
3537

3638
function TransactionGroupListItem<TItem extends ListItem>({
3739
item,
@@ -138,8 +140,13 @@ function TransactionGroupListItem<TItem extends ListItem>({
138140
/>
139141
),
140142
[CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: (
141-
// Will be implemented as part of https://github.com/Expensify/App/pull/66078
142-
<View />
143+
<WithdrawalIDListItemHeader
144+
withdrawalID={groupItem as TransactionWithdrawalIDGroupListItemType}
145+
onSelectRow={onSelectRow}
146+
onCheckboxPress={onCheckboxPress}
147+
isDisabled={isDisabledOrEmpty}
148+
canSelectMultiple={canSelectMultiple}
149+
/>
143150
),
144151
};
145152

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import React from 'react';
2+
import {View} from 'react-native';
3+
import Checkbox from '@components/Checkbox';
4+
import Icon from '@components/Icon';
5+
import getBankIcon from '@components/Icon/BankIcons';
6+
import type {ListItem, TransactionWithdrawalIDGroupListItemType} from '@components/SelectionList/types';
7+
import TextWithTooltip from '@components/TextWithTooltip';
8+
import useLocalize from '@hooks/useLocalize';
9+
import useResponsiveLayout from '@hooks/useResponsiveLayout';
10+
import useStyleUtils from '@hooks/useStyleUtils';
11+
import useThemeStyles from '@hooks/useThemeStyles';
12+
import DateUtils from '@libs/DateUtils';
13+
import CONST from '@src/CONST';
14+
import ActionCell from './ActionCell';
15+
import TotalCell from './TotalCell';
16+
17+
type WithdrawalIDListItemHeaderProps<TItem extends ListItem> = {
18+
/** The withdrawal ID currently being looked at */
19+
withdrawalID: TransactionWithdrawalIDGroupListItemType;
20+
21+
/** Callback to fire when the item is pressed */
22+
onSelectRow: (item: TItem) => void;
23+
24+
/** Callback to fire when a checkbox is pressed */
25+
onCheckboxPress?: (item: TItem) => void;
26+
27+
/** Whether this section items disabled for selection */
28+
isDisabled?: boolean | null;
29+
30+
/** Whether selecting multiple transactions at once is allowed */
31+
canSelectMultiple: boolean | undefined;
32+
};
33+
34+
function WithdrawalIDListItemHeader<TItem extends ListItem>({
35+
withdrawalID: withdrawalIDItem,
36+
onSelectRow,
37+
onCheckboxPress,
38+
isDisabled,
39+
canSelectMultiple,
40+
}: WithdrawalIDListItemHeaderProps<TItem>) {
41+
const styles = useThemeStyles();
42+
const StyleUtils = useStyleUtils();
43+
const {translate} = useLocalize();
44+
const {isLargeScreenWidth} = useResponsiveLayout();
45+
const {icon, iconSize, iconStyles} = getBankIcon({bankName: withdrawalIDItem.bankName, styles});
46+
const formattedBankName = CONST.BANK_NAMES_USER_FRIENDLY[withdrawalIDItem.bankName];
47+
const formattedWithdrawalDate = DateUtils.formatWithUTCTimeZone(
48+
withdrawalIDItem.debitPosted,
49+
DateUtils.doesDateBelongToAPastYear(withdrawalIDItem.debitPosted) ? CONST.DATE.MONTH_DAY_YEAR_ABBR_FORMAT : CONST.DATE.MONTH_DAY_ABBR_FORMAT,
50+
);
51+
const shouldShowAction = isLargeScreenWidth;
52+
53+
return (
54+
<View>
55+
<View style={[styles.pv1Half, styles.ph3, styles.flexRow, styles.alignItemsCenter, styles.justifyContentStart]}>
56+
<View style={[styles.flexRow, styles.alignItemsCenter, styles.mnh40, styles.flex1, styles.gap3]}>
57+
{!!canSelectMultiple && (
58+
<Checkbox
59+
onPress={() => onCheckboxPress?.(withdrawalIDItem as unknown as TItem)}
60+
isChecked={withdrawalIDItem.isSelected}
61+
disabled={!!isDisabled || withdrawalIDItem.isDisabledCheckbox}
62+
accessibilityLabel={translate('common.select')}
63+
/>
64+
)}
65+
<View style={[styles.flexRow, styles.flex1, styles.gap3]}>
66+
<Icon
67+
src={icon}
68+
width={iconSize}
69+
height={iconSize}
70+
additionalStyles={iconStyles}
71+
/>
72+
<View style={[styles.gapHalf, styles.flexShrink1]}>
73+
<TextWithTooltip
74+
text={`${formattedBankName} xx${withdrawalIDItem.accountNumber.slice(-4)}`}
75+
style={[styles.optionDisplayName, styles.sidebarLinkTextBold, styles.pre]}
76+
/>
77+
<TextWithTooltip
78+
text={`${formattedWithdrawalDate} ${translate('common.withdrawalID')}: ${withdrawalIDItem.entryID}`}
79+
style={[styles.textLabelSupporting, styles.lh16, styles.pre]}
80+
/>
81+
</View>
82+
</View>
83+
</View>
84+
<View style={[styles.flexShrink0, styles.mr3]}>
85+
<TotalCell
86+
total={withdrawalIDItem.total}
87+
currency={withdrawalIDItem.currency}
88+
/>
89+
</View>
90+
{shouldShowAction && (
91+
<View style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.ACTION)]}>
92+
<ActionCell
93+
action={CONST.SEARCH.ACTION_TYPES.VIEW}
94+
goToItem={() => onSelectRow(withdrawalIDItem as unknown as TItem)}
95+
isSelected={withdrawalIDItem.isSelected}
96+
/>
97+
</View>
98+
)}
99+
</View>
100+
</View>
101+
);
102+
}
103+
104+
WithdrawalIDListItemHeader.displayName = 'WithdrawalIDListItemHeader';
105+
106+
export default WithdrawalIDListItemHeader;

src/components/SelectionList/SearchTableHeader.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const shouldShowColumnConfig: Record<SortableColumnName, ShouldShowSearchColumnF
3434
[CONST.SEARCH.TABLE_COLUMNS.ASSIGNEE]: () => true,
3535
[CONST.SEARCH.TABLE_COLUMNS.IN]: () => true,
3636
[CONST.SEARCH.TABLE_COLUMNS.CARD]: () => false,
37+
[CONST.SEARCH.TABLE_COLUMNS.WITHDRAWAL_ID]: () => false,
3738
// This column is never displayed on Search
3839
[CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS]: () => false,
3940
};
@@ -81,6 +82,10 @@ const expenseHeaders: SearchColumnConfig[] = [
8182
columnName: CONST.SEARCH.TABLE_COLUMNS.TAG,
8283
translationKey: 'common.tag',
8384
},
85+
{
86+
columnName: CONST.SEARCH.TABLE_COLUMNS.WITHDRAWAL_ID,
87+
translationKey: 'common.withdrawalID',
88+
},
8489
{
8590
columnName: CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT,
8691
translationKey: 'common.tax',
@@ -178,6 +183,9 @@ function SearchTableHeader({
178183
if (groupBy === CONST.SEARCH.GROUP_BY.CARD) {
179184
return columnName === CONST.SEARCH.TABLE_COLUMNS.CARD || columnName === CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT || columnName === CONST.SEARCH.TABLE_COLUMNS.ACTION;
180185
}
186+
if (groupBy === CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID) {
187+
return columnName === CONST.SEARCH.TABLE_COLUMNS.WITHDRAWAL_ID || columnName === CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT || columnName === CONST.SEARCH.TABLE_COLUMNS.ACTION;
188+
}
181189

182190
const shouldShowFun = shouldShowColumnConfig[columnName];
183191
return shouldShowFun(data, metadata);

src/components/SelectionList/types.ts

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

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

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

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

src/languages/de.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ const translations = {
587587
network: 'Netzwerk',
588588
reportID: 'Berichts-ID',
589589
longID: 'Lange ID',
590+
withdrawalID: 'Auszahlungs-ID',
590591
bankAccounts: 'Bankkonten',
591592
chooseFile: 'Datei auswählen',
592593
chooseFiles: 'Dateien auswählen',

src/languages/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ const translations = {
579579
network: 'Network',
580580
reportID: 'Report ID',
581581
longID: 'Long ID',
582+
withdrawalID: 'Withdrawal ID',
582583
bankAccounts: 'Bank accounts',
583584
chooseFile: 'Choose file',
584585
chooseFiles: 'Choose files',

src/languages/es.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ const translations = {
571571
network: 'La red',
572572
reportID: 'ID del informe',
573573
longID: 'ID largo',
574+
withdrawalID: 'ID de retiro',
574575
bankAccounts: 'Cuentas bancarias',
575576
chooseFile: 'Elegir archivo',
576577
chooseFiles: 'Elegir archivos',

0 commit comments

Comments
 (0)