File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
app/controllers/event-invoice Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ import Controller from '@ember/controller' ;
2
+ import { action } from '@ember/object' ;
3
+
4
+ export default class extends Controller {
5
+ @action
6
+ async downloadEventInvoice ( eventName , orderId ) {
7
+ this . set ( 'isLoading' , true ) ;
8
+ try {
9
+ const result = this . loader . downloadFile ( `/events/invoices/${ this . orderId } ` ) ;
10
+ const anchor = document . createElement ( 'a' ) ;
11
+ anchor . style . display = 'none' ;
12
+ anchor . href = URL . createObjectURL ( new Blob ( [ result ] , { type : 'application/pdf' } ) ) ;
13
+ anchor . download = `${ eventName } -EventInvoice-${ orderId } .pdf` ;
14
+ document . body . appendChild ( anchor ) ;
15
+ anchor . click ( ) ;
16
+ this . notify . success ( this . l10n . t ( 'Here is your Event Invoice' ) ) ;
17
+ document . body . removeChild ( anchor ) ;
18
+ } catch ( e ) {
19
+ console . warn ( e ) ;
20
+ this . notify . error ( this . l10n . t ( 'Unexpected error occurred.' ) ) ;
21
+ }
22
+ this . set ( 'isLoading' , false ) ;
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments