Skip to content

Commit

Permalink
Merge pull request #47759 from Expensify/cmartins-sendJSONQueryOnExport
Browse files Browse the repository at this point in the history
Sends jsonQuery to the API
  • Loading branch information
luacmartins authored Aug 21, 2024
2 parents 6bd0782 + 617e176 commit 12037ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/components/Search/SearchPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,12 @@ function SearchPageHeader({queryJSON, hash, onSelectDeleteOption, setOfflineModa
}

const reportIDList = (selectedReports?.filter((report) => !!report) as string[]) ?? [];
SearchActions.exportSearchItemsToCSV({query: status, reportIDList, transactionIDList: selectedTransactionsKeys, policyIDs: [activeWorkspaceID ?? '']}, () => {
setDownloadErrorModalOpen?.();
});
SearchActions.exportSearchItemsToCSV(
{query: status, jsonQuery: JSON.stringify(queryJSON), reportIDList, transactionIDList: selectedTransactionsKeys, policyIDs: [activeWorkspaceID ?? '']},
() => {
setDownloadErrorModalOpen?.();
},
);
},
});

Expand Down Expand Up @@ -247,6 +250,7 @@ function SearchPageHeader({queryJSON, hash, onSelectDeleteOption, setOfflineModa

return options;
}, [
queryJSON,
status,
selectedTransactionsKeys,
selectedTransactions,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/API/parameters/ExportSearchItemsToCSVParams.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type {SearchStatus} from '@components/Search/types';
import type {SearchQueryString, SearchStatus} from '@components/Search/types';

type ExportSearchItemsToCSVParams = {
query: SearchStatus;
jsonQuery: SearchQueryString;
reportIDList: string[];
transactionIDList: string[];
policyIDs: string[];
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ function deleteMoneyRequestOnSearch(hash: number, transactionIDList: string[]) {

type Params = Record<string, ExportSearchItemsToCSVParams>;

function exportSearchItemsToCSV({query, reportIDList, transactionIDList, policyIDs}: ExportSearchItemsToCSVParams, onDownloadFailed: () => void) {
function exportSearchItemsToCSV({query, jsonQuery, reportIDList, transactionIDList, policyIDs}: ExportSearchItemsToCSVParams, onDownloadFailed: () => void) {
const finalParameters = enhanceParameters(WRITE_COMMANDS.EXPORT_SEARCH_ITEMS_TO_CSV, {
query,
jsonQuery,
reportIDList,
transactionIDList,
policyIDs,
Expand Down

0 comments on commit 12037ee

Please sign in to comment.