File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -430,19 +430,24 @@ window.QPixel = {
430430 } ,
431431
432432 handleJSONResponse : ( data , onSuccess , onFinally ) => {
433- const is_modified = data . status === 'modified' ;
434- const is_success = data . status === 'success' ;
433+ const is_failed = data . status === 'failed' ;
435434
436- if ( is_modified || is_success ) {
437- onSuccess ( /** @type {Parameters<typeof onSuccess>[0] } */ ( data ) ) ;
435+ if ( is_failed ) {
436+ if ( data . message ) {
437+ QPixel . createNotification ( 'danger' , data . message ) ;
438+ }
439+
440+ for ( const error of data . errors ?? [ ] ) {
441+ QPixel . createNotification ( 'danger' , error ) ;
442+ }
438443 }
439444 else {
440- QPixel . createNotification ( 'danger' , data . message ) ;
445+ onSuccess ( /** @type { Parameters<typeof onSuccess>[0] } */ ( data ) ) ;
441446 }
442447
443448 onFinally ?. ( data ) ;
444449
445- return is_success ;
450+ return ! is_failed ;
446451 } ,
447452
448453 flag : async ( flag ) => {
You can’t perform that action at this time.
0 commit comments