refactors old ProfilUpdate controller functions

This commit is contained in:
SimonGschnell
2024-09-13 12:27:07 +02:00
parent 2b9406b172
commit cf1cb44afa
3 changed files with 245 additions and 142 deletions
@@ -54,6 +54,14 @@ export default {
this.fileID = newFileID;
},
handleFailedError: function (err) {
console.error(err);
this.loading = false;
this.setLoading(false);
this.result = false;
this.hide();
},
async submitProfilChange() {
//? check if data is valid before making a request
@@ -99,31 +107,19 @@ export default {
this.editData.updateID,
this.fileID ? this.fileID[0] : null
)
.then((res) => {
handleApiResponse(res);
})
.catch((err) => {
console.error(err);
this.loading = false;
this.setLoading(false);
this.result = false;
this.hide();
})
: this.$fhcApi.factory.profilUpdate.insertProfilRequest(
.then((res) => {
handleApiResponse(res);
})
.catch((err) => this.handleFailedError)
: this.$fhcApi.factory.profilUpdate.insertProfilRequest(
this.topic,
this.profilUpdate,
this.fileID ? this.fileID[0] : null
)
.then((res) => {
handleApiResponse(res);
})
.catch((err) => {
console.error(err);
this.loading = false;
this.setLoading(false);
this.result = false;
this.hide();
});
.then((res) => {
handleApiResponse(res);
})
.catch((err) => this.handleFailedError);
}
},