@@ -12,26 +12,26 @@ define([
12
12
return function ( config , element ) {
13
13
let order_id = config . order_id ,
14
14
options = {
15
- type : 'popup' ,
16
- responsive : true ,
17
- title : 'Cancel Order' ,
18
- buttons : [ {
19
- text : $ . mage . __ ( 'Close' ) ,
20
- class : 'action-secondary action-dismiss close-modal-button' ,
15
+ type : 'popup' ,
16
+ responsive : true ,
17
+ title : 'Cancel Order' ,
18
+ buttons : [ {
19
+ text : $ . mage . __ ( 'Close' ) ,
20
+ class : 'action-secondary action-dismiss close-modal-button' ,
21
21
22
- /** @inheritdoc */
23
- click : function ( ) {
24
- this . closeModal ( ) ;
25
- }
26
- } , {
27
- text : $ . mage . __ ( 'Confirm' ) ,
28
- class : 'action-primary action-accept cancel-order-button' ,
22
+ /** @inheritdoc */
23
+ click : function ( ) {
24
+ this . closeModal ( ) ;
25
+ }
26
+ } , {
27
+ text : $ . mage . __ ( 'Confirm' ) ,
28
+ class : 'action-primary action-accept cancel-order-button' ,
29
29
30
- /** @inheritdoc */
31
- click : function ( ) {
32
- let thisModal = this ,
33
- reason = $ ( '#cancel-order-reason-' + order_id ) . find ( ':selected' ) . text ( ) ,
34
- mutation = `
30
+ /** @inheritdoc */
31
+ click : function ( ) {
32
+ let thisModal = this ,
33
+ reason = $ ( '#cancel-order-reason-' + order_id ) . find ( ':selected' ) . text ( ) ,
34
+ mutation = `
35
35
mutation cancelOrder($order_id: ID!, $reason: String!) {
36
36
cancelOrder(input: {order_id: $order_id, reason: $reason}) {
37
37
error
@@ -41,45 +41,45 @@ mutation cancelOrder($order_id: ID!, $reason: String!) {
41
41
}
42
42
}` ;
43
43
44
- $ . ajax ( {
45
- showLoader : true ,
46
- type : 'POST' ,
47
- url : `${ config . url } graphql` ,
48
- contentType : 'application/json' ,
49
- data : JSON . stringify ( {
50
- query : mutation ,
51
- variables : {
52
- 'order_id' : config . order_id ,
53
- 'reason' : reason
54
- }
55
- } ) ,
56
- complete : function ( response ) {
57
- let type = 'success' ,
58
- message ;
44
+ $ . ajax ( {
45
+ showLoader : true ,
46
+ type : 'POST' ,
47
+ url : `${ config . url } graphql` ,
48
+ contentType : 'application/json' ,
49
+ data : JSON . stringify ( {
50
+ query : mutation ,
51
+ variables : {
52
+ 'order_id' : config . order_id ,
53
+ 'reason' : reason
54
+ }
55
+ } ) ,
56
+ complete : function ( response ) {
57
+ let type = 'success' ,
58
+ message ;
59
59
60
- if ( response . responseJSON . data . cancelOrder . error !== null ) {
61
- message = $ . mage . __ ( response . responseJSON . data . cancelOrder . error ) ;
62
- type = 'error' ;
63
- } else {
64
- message = $ . mage . __ ( response . responseJSON . data . cancelOrder . order . status ) ;
65
- location . reload ( ) ;
66
- }
60
+ if ( response . responseJSON . data . cancelOrder . error !== null ) {
61
+ message = $ . mage . __ ( response . responseJSON . data . cancelOrder . error ) ;
62
+ type = 'error' ;
63
+ } else {
64
+ message = $ . mage . __ ( response . responseJSON . data . cancelOrder . order . status ) ;
65
+ location . reload ( ) ;
66
+ }
67
67
68
- setTimeout ( function ( ) {
69
- customerData . set ( 'messages' , {
70
- messages : [ {
71
- text : message ,
72
- type : type
73
- } ]
74
- } ) ;
75
- } , 1000 ) ;
76
- }
77
- } ) . always ( function ( ) {
78
- thisModal . closeModal ( true ) ;
79
- } ) ;
80
- }
81
- } ]
82
- } ;
68
+ setTimeout ( function ( ) {
69
+ customerData . set ( 'messages' , {
70
+ messages : [ {
71
+ text : message ,
72
+ type : type
73
+ } ]
74
+ } ) ;
75
+ } , 1000 ) ;
76
+ }
77
+ } ) . always ( function ( ) {
78
+ thisModal . closeModal ( true ) ;
79
+ } ) ;
80
+ }
81
+ } ]
82
+ } ;
83
83
84
84
$ ( element ) . on ( 'click' , function ( ) {
85
85
$ ( '#cancel-order-modal-' + order_id ) . modal ( 'openModal' ) ;
0 commit comments