Skip to content

Commit

Permalink
fix(usePDFExport): add missing dispatch call
Browse files Browse the repository at this point in the history
  • Loading branch information
mkholjuraev committed Jul 7, 2023
1 parent 5d984d8 commit 951b82d
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions packages/utils/src/useExportPDF/useExportPDF.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,32 @@ const renderPDF = (pdfBlob: Blob, fileName = 'new-report') => {

// Hook to provide a function that request pdf-generator service to generate report blob
// and convert returned blob into pdf
const usePDFExport = (service: string) => {
const usePDFExport = (service: string, dispatch: any) => {
const exportPDF = async (template: string, filename: string, exportSettings: Record<string, unknown>) => {
addNotification({
variant: 'info',
title: 'Preparing export',
description: 'Once complete, your download will start automatically.',
});
dispatch(
addNotification({
variant: 'info',
title: 'Preparing export',
description: 'Once complete, your download will start automatically.',
})
);
try {
const pdfBlob = await fetchPDF(service, template, exportSettings);
renderPDF(pdfBlob, filename);
addNotification({
variant: 'success',
title: 'Downloading export',
});
dispatch(
addNotification({
variant: 'success',
title: 'Downloading export',
})
);
} catch (e) {
addNotification({
variant: 'danger',
title: 'Couldn’t download export',
description: 'Reinitiate this export to try again.',
});
dispatch(
addNotification({
variant: 'danger',
title: 'Couldn’t download export',
description: 'Reinitiate this export to try again.',
})
);
}
};

Expand Down

0 comments on commit 951b82d

Please sign in to comment.