@@ -12,26 +12,26 @@ define([
1212 return function ( config , element ) {
1313 let order_id = config . order_id ,
1414 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' ,
2121
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' ,
2929
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 = `
3535mutation cancelOrder($order_id: ID!, $reason: String!) {
3636 cancelOrder(input: {order_id: $order_id, reason: $reason}) {
3737 error
@@ -41,45 +41,45 @@ mutation cancelOrder($order_id: ID!, $reason: String!) {
4141 }
4242}` ;
4343
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 ;
5959
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+ }
6767
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+ } ;
8383
8484 $ ( element ) . on ( 'click' , function ( ) {
8585 $ ( '#cancel-order-modal-' + order_id ) . modal ( 'openModal' ) ;
0 commit comments