diff --git a/src/CONST.ts b/src/CONST.ts index da106bdfec80..86992fda1e77 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3459,6 +3459,7 @@ const CONST = { }, TAB_SEARCH: { ALL: 'all', + DRAFTS: 'drafts', }, STATUS_TEXT_MAX_LENGTH: 100, @@ -4749,6 +4750,7 @@ const CONST = { SEARCH_DATA_TYPES: { TRANSACTION: 'transaction', + REPORT: 'report', }, } as const; diff --git a/src/components/Search.tsx b/src/components/Search.tsx index fbd352a798c6..bc8368c53b18 100644 --- a/src/components/Search.tsx +++ b/src/components/Search.tsx @@ -14,7 +14,7 @@ import ROUTES from '@src/ROUTES'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; import SelectionList from './SelectionList'; -import SearchTableHeader from './SelectionList/SearchTableHeader'; +import SearchTableHeader from './SelectionList/Search/SearchTableHeader'; import TableListItemSkeleton from './Skeletons/TableListItemSkeleton'; type SearchProps = { @@ -27,7 +27,116 @@ function Search({query}: SearchProps) { useCustomBackHandler(); const hash = SearchUtils.getQueryHash(query); - const [searchResults, searchResultsMeta] = useOnyx(`${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`); + // const [searchResults, searchResultsMeta] = useOnyx(`${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`); + + const searchResults = { + "data": { + "personalDetailsList": { + "645": { + "accountID": 645, + "avatar": "https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_22.png", + "displayName": "ccc@cc.com", + "firstName": "", + "lastName": "", + "login": "ccc@cc.com", + "payPalMeAddress": "", + "phoneNumber": "", + "pronouns": "", + "timezone": { + "automatic": true, + "selected": "America/Los_Angeles" + }, + "validated": "" + }, + "844": { + "accountID": 844, + "avatar": "https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_5.png", + "displayName": "long ass name to test text overflowing container dfdf", + "firstName": "long ass name to test text overflowing container", + "lastName": "dfdf", + "login": "cc2@cc.com", + "payPalMeAddress": "", + "phoneNumber": "", + "pronouns": "__predefined_thonThons", + "timezone": { + "automatic": true, + "selected": "America/Los_Angeles" + }, + "validated": "" + }, + }, + "report_5544039625114797": { + "reportID": 5544039625114797, + "reportName": "Dummy report", + "total": 2234, + "currency": "USD", + "action": "view", + }, + "transactions_1068903897709851923": { + "accountID": 844, + "action": "view", + "amount": -30885, + "canDelete": false, + "category": "Uncategorized", + "comment": { + "comment": "" + }, + "created": "2023-10-28", + "currency": "USD", + "hasEReceipt": false, + "managerID": 645, + "merchant": "NEWHAIR", + "modifiedAmount": 0, + "modifiedCreated": "", + "modifiedCurrency": "", + "modifiedMerchant": "", + "parentTransactionID": "", + "policyID": "296A4D9E7F12B910", + "reportID": "5544039625114797", + "reportType": "expense", + "tag": "", + "transactionID": "1068903897709851923", + "transactionThreadReportID": "0", + "type": "card" + }, + "transactions_1145103166671192292": { + "accountID": 844, + "action": "view", + "amount": 0, + "canDelete": true, + "category": "Ttt", + "comment": { + "comment": "" + }, + "created": "2024-05-09 20:43:28", + "currency": "CAD", + "hasEReceipt": false, + "managerID": 645, + "merchant": "(none)", + "modifiedAmount": -3300, + "modifiedCreated": "", + "modifiedCurrency": "CAD", + "modifiedMerchant": "test", + "parentTransactionID": "", + "policyID": "3CC70F43B8D5D63C", + "receipt": { + "source": "https://www.expensify.com.dev/receipts/w_db31f7b4f64a0285ba742b3eef356001ba39e076.png" + }, + "reportID": "5544039625114797", + "reportType": "expense", + "tag": "", + "taxAmount": 0, + "transactionID": "1145103166671192292", + "transactionThreadReportID": "3314198419415278", + "type": "cash" + }, + }, + "search": { + "hasMoreResults": true, + "offset": 0, + "type": "report" + } + } useEffect(() => { if (isOffline) { @@ -37,16 +146,16 @@ function Search({query}: SearchProps) { SearchActions.search(query); }, [query, isOffline]); - const isLoading = (!isOffline && isLoadingOnyxValue(searchResultsMeta)) || searchResults?.data === undefined; - const shouldShowEmptyState = !isLoading && isEmptyObject(searchResults?.data); + // const isLoading = (!isOffline && isLoadingOnyxValue(searchResultsMeta)) || searchResults?.data === undefined; + // const shouldShowEmptyState = !isLoading && isEmptyObject(searchResults?.data); - if (isLoading) { - return ; - } + // if (isLoading) { + // return ; + // } - if (shouldShowEmptyState) { - return ; - } + // if (shouldShowEmptyState) { + // return ; + // } const openReport = (reportID?: string) => { if (!reportID) { diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx new file mode 100644 index 000000000000..3131ed98f0a8 --- /dev/null +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -0,0 +1,125 @@ +import React from 'react'; +import {View} from 'react-native'; +import useWindowDimensions from '@hooks/useWindowDimensions'; +import useThemeStyles from '@hooks/useThemeStyles'; +import type {ListItem, ReportListItemProps, ReportListItemType, TransactionListItemType} from '@components/SelectionList/types'; +import BaseListItem from '@components/SelectionList/BaseListItem'; +import TextWithTooltip from '@components/TextWithTooltip'; +import useStyleUtils from '@hooks/useStyleUtils'; +import CONST from '@src/CONST'; +import type {ThemeStyles} from '@styles/index'; +import * as CurrencyUtils from '@libs/CurrencyUtils'; +import Button from '@components/Button'; +import useLocalize from '@hooks/useLocalize'; +import type {TranslationPaths} from '@src/languages/types'; +import type {Phrase, PhraseParameters} from '@libs/Localize'; +import TransactionListItem from './TransactionListItem'; + +const reportNameCell = (showTooltip: boolean, item: ReportListItemType, styles: ThemeStyles) => ( + +) + +const groupedExpensesCell = (showTooltip: boolean, item: ReportListItemType, styles: ThemeStyles, translate: (phraseKey: TKey, ...phraseParameters: PhraseParameters>) => string) => ( + +) + +const totalCell = (showTooltip: boolean, item: ReportListItemType, styles: ThemeStyles) => ( + +) + +const actionCell = (item: ReportListItemType, styles: ThemeStyles, translate: (phraseKey: TKey, ...phraseParameters: PhraseParameters>) => string, onSelectRow: (item: ReportListItemType) => void) => ( +