@@ -109,27 +109,27 @@ export class DeletionModal extends Component {
109109 reason : values . reason ,
110110 comment : values . comment ,
111111 } ;
112- if ( "request_deletion" in record . links ) {
113- this . cancellableAction = withCancel (
114- http . post ( record . links . request_deletion , payload )
115- ) ;
116- try {
117- const response = await this . cancellableAction . promise ;
118- const data = response . data ;
112+ if ( ! ( "request_deletion" in record . links ) ) {
113+ this . setState ( { error : "Could not submit deletion request" , loading : false } ) ;
114+ return ;
115+ }
116+ this . cancellableAction = withCancel (
117+ http . post ( record . links . request_deletion , payload )
118+ ) ;
119+ try {
120+ const response = await this . cancellableAction . promise ;
121+ const data = response . data ;
119122
120- if ( response . status === 200 ) {
121- window . location . reload ( ) ;
122- } else if ( response . status === 201 ) {
123- window . location . href = data . links . self_html ;
124- }
125- } catch ( error ) {
126- this . setState ( { error : error } ) ;
127- console . error ( error ) ;
128- } finally {
129- this . setState ( { loading : false } ) ;
123+ if ( response . status === 200 ) {
124+ window . location . reload ( ) ;
125+ } else if ( response . status === 201 ) {
126+ window . location . href = data . links . self_html ;
130127 }
131- } else {
132- this . setState ( { error : "Could not submit deletion request" , loading : false } ) ;
128+ } catch ( error ) {
129+ this . setState ( { error : error } ) ;
130+ console . error ( error ) ;
131+ } finally {
132+ this . setState ( { loading : false } ) ;
133133 }
134134 } ;
135135
0 commit comments