Skip to content

Commit 951b82d

Browse files
committedJul 7, 2023
fix(usePDFExport): add missing dispatch call
1 parent 5d984d8 commit 951b82d

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed
 

‎packages/utils/src/useExportPDF/useExportPDF.ts

+21-15
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,32 @@ const renderPDF = (pdfBlob: Blob, fileName = 'new-report') => {
3030

3131
// Hook to provide a function that request pdf-generator service to generate report blob
3232
// and convert returned blob into pdf
33-
const usePDFExport = (service: string) => {
33+
const usePDFExport = (service: string, dispatch: any) => {
3434
const exportPDF = async (template: string, filename: string, exportSettings: Record<string, unknown>) => {
35-
addNotification({
36-
variant: 'info',
37-
title: 'Preparing export',
38-
description: 'Once complete, your download will start automatically.',
39-
});
35+
dispatch(
36+
addNotification({
37+
variant: 'info',
38+
title: 'Preparing export',
39+
description: 'Once complete, your download will start automatically.',
40+
})
41+
);
4042
try {
4143
const pdfBlob = await fetchPDF(service, template, exportSettings);
4244
renderPDF(pdfBlob, filename);
43-
addNotification({
44-
variant: 'success',
45-
title: 'Downloading export',
46-
});
45+
dispatch(
46+
addNotification({
47+
variant: 'success',
48+
title: 'Downloading export',
49+
})
50+
);
4751
} catch (e) {
48-
addNotification({
49-
variant: 'danger',
50-
title: 'Couldn’t download export',
51-
description: 'Reinitiate this export to try again.',
52-
});
52+
dispatch(
53+
addNotification({
54+
variant: 'danger',
55+
title: 'Couldn’t download export',
56+
description: 'Reinitiate this export to try again.',
57+
})
58+
);
5359
}
5460
};
5561

0 commit comments

Comments
 (0)
Please sign in to comment.