diff --git a/src/components/WorkoutsSeries/Modals/AddWorkoutModal.vue b/src/components/WorkoutsSeries/Modals/AddWorkoutModal.vue index 0584ab3..b887c13 100644 --- a/src/components/WorkoutsSeries/Modals/AddWorkoutModal.vue +++ b/src/components/WorkoutsSeries/Modals/AddWorkoutModal.vue @@ -2,7 +2,8 @@ @@ -172,7 +173,7 @@ export default { }, }, methods: { - ...mapActions("workoutToSeries", ["loadWorkoutsToSeries", "addWorkoutToSeries"]), + ...mapActions("workoutToSeries", ["loadWorkoutsToSeries", "attachWorkoutToSeries"]), ...mapMutations("workoutToSeries", ["SET_FILTER_WORKOUTS_TO_SERIES"]), closeModal() { this.SET_FILTER_WORKOUTS_TO_SERIES({}); @@ -180,20 +181,25 @@ export default { async joinWorkout(id) { this.workoutId = id; let repository = new WorkoutToSeriesRepository(); - this.selectedWorkout = await repository.show(this.workoutId); + let response = await repository.show(this.workoutId); + this.selectedWorkout = response; + this.form["set"] = response.suggested_set; + this.form["per_set"] = response.suggested_per_set; + this.form["estimate_time"] = response.suggested_time; }, async WorkoutToSeries() { + console.log(this.workoutId); if (this.workoutId) { - await this.addWorkoutToSeries({ + await this.attachWorkoutToSeries({ data: this.form, - seriesId: Number(this.getCurrentSeriesId), + seriesId: +this.getCurrentSeriesId, workoutId: this.workoutId, }); this.isLoading = false; this.$_closeModal(); return; } - return toast.error("Please select a workout firstt", "Error"); + toast.error("Please select a workout first", "Error"); }, }, async created() { diff --git a/src/store/modules/workoutToSeries/actions.js b/src/store/modules/workoutToSeries/actions.js index 82430c0..046e145 100644 --- a/src/store/modules/workoutToSeries/actions.js +++ b/src/store/modules/workoutToSeries/actions.js @@ -26,7 +26,7 @@ export default { // const resource = await repository.show(workoutId); // commit("SET_WORKOUT_TO_SERIES", resource); // }, - async addWorkoutToSeries({ commit }, { data, seriesId, workoutId }) { + async attachWorkoutToSeries({ commit }, { data, seriesId, workoutId }) { const resource = await repository.store(data, seriesId, workoutId); commit("SET_PROGRAM_SERIES_WORKOUTS", resource.data);