Fix edit challenge twice bug (#11591)

Description: Use of a same object property group for differents types between a
challenge and workingChallenge
workingChallenge use group as and id but this.challenge have a group
object

Fix: Wait for server response for challenge edit. Set this.challenge
from response and not directly from form data workingChallenge
This commit is contained in:
Nik
2019-11-29 20:12:56 +01:00
committed by Matteo Pagliazzi
parent 59c4b32d69
commit 9379325731

View File

@@ -595,7 +595,7 @@ export default {
this.$root.$emit('bv::hide::modal', 'challenge-modal');
this.$router.push(`/challenges/${challenge._id}`);
},
updateChallenge () {
async updateChallenge () {
const categoryKeys = this.workingChallenge.categories;
const serverCategories = [];
categoryKeys.forEach(key => {
@@ -610,10 +610,8 @@ export default {
const challengeDetails = clone(this.workingChallenge);
challengeDetails.categories = serverCategories;
this.$emit('updatedChallenge', {
challenge: challengeDetails,
});
this.$store.dispatch('challenges:updateChallenge', { challenge: challengeDetails });
const challenge = await this.$store.dispatch('challenges:updateChallenge', { challenge: challengeDetails });
this.$emit('updatedChallenge', { challenge });
this.resetWorkingChallenge();
this.$root.$emit('bv::hide::modal', 'challenge-modal');
},