Skip to content

Commit 11005eb

Browse files
committed
add customIS templates to other report export views
1 parent 545fb78 commit 11005eb

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/hooks/useSelectedTransactionsActions.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ function useSelectedTransactionsActions({
171171
}
172172

173173
// Gets the list of options for the export sub-menu
174+
const [integrationsExportTemplates] = useOnyx(ONYXKEYS.NVP_INTEGRATION_SERVER_EXPORT_TEMPLATES, {canBeMissing: false});
174175
const getExportOptions = (): PopoverMenuItem[] => {
175176
// We provide the basic and expense level export options by default
176177
const exportOptions: PopoverMenuItem[] = [
@@ -210,6 +211,17 @@ function useSelectedTransactionsActions({
210211
});
211212
}
212213

214+
// If the user has any custom integration export templates, add them as export options
215+
if (integrationsExportTemplates && integrationsExportTemplates.length > 0) {
216+
for (const template of integrationsExportTemplates) {
217+
exportOptions.push({
218+
text: template.name,
219+
icon: Expensicons.Table,
220+
onSelected: () => beginExportWithTemplate(template.name, CONST.EXPORT_TEMPLATE_TYPES.INTEGRATIONS, selectedTransactionIDs),
221+
});
222+
}
223+
}
224+
213225
return exportOptions;
214226
};
215227

@@ -279,6 +291,7 @@ function useSelectedTransactionsActions({
279291
session?.accountID,
280292
showDeleteModal,
281293
beginExportWithTemplate,
294+
integrationsExportTemplates,
282295
]);
283296

284297
return {

src/pages/Search/SearchPage.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ function SearchPage({route}: SearchPageProps) {
7979
const [newParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${newReport?.parentReportID}`, {canBeMissing: true});
8080
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: false});
8181
const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`, {canBeMissing: true});
82+
const [integrationsExportTemplates] = useOnyx(ONYXKEYS.NVP_INTEGRATION_SERVER_EXPORT_TEMPLATES, {canBeMissing: false});
8283

8384
const [isOfflineModalVisible, setIsOfflineModalVisible] = useState(false);
8485
const [isDownloadErrorModalVisible, setIsDownloadErrorModalVisible] = useState(false);
@@ -198,6 +199,20 @@ function SearchPage({route}: SearchPageProps) {
198199
});
199200
}
200201

202+
// If the user has any custom integration export templates, add them as export options
203+
if (integrationsExportTemplates && integrationsExportTemplates.length > 0) {
204+
for (const template of integrationsExportTemplates) {
205+
exportOptions.push({
206+
text: template.name,
207+
icon: Expensicons.Table,
208+
onSelected: () => {
209+
// Custom IS templates are not policy specific, so we don't need to pass a policyID
210+
beginExportWithTemplate(template.name, CONST.EXPORT_TEMPLATE_TYPES.INTEGRATIONS, undefined);
211+
},
212+
});
213+
}
214+
}
215+
201216
return exportOptions;
202217
};
203218

@@ -433,6 +448,7 @@ function SearchPage({route}: SearchPageProps) {
433448
styles.fontWeightNormal,
434449
styles.textWrap,
435450
beginExportWithTemplate,
451+
integrationsExportTemplates,
436452
]);
437453

438454
const handleDeleteExpenses = () => {

0 commit comments

Comments
 (0)