@@ -30,26 +30,32 @@ const renderPDF = (pdfBlob: Blob, fileName = 'new-report') => {
30
30
31
31
// Hook to provide a function that request pdf-generator service to generate report blob
32
32
// and convert returned blob into pdf
33
- const usePDFExport = ( service : string ) => {
33
+ const usePDFExport = ( service : string , dispatch : any ) => {
34
34
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
+ ) ;
40
42
try {
41
43
const pdfBlob = await fetchPDF ( service , template , exportSettings ) ;
42
44
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
+ ) ;
47
51
} 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
+ ) ;
53
59
}
54
60
} ;
55
61
0 commit comments