Skip to content

Commit

Permalink
fixing the the meal component refreshing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Achraffawzi committed Aug 6, 2021
1 parent 49a3abc commit bb3a179
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 2 additions & 0 deletions FRONT_END/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const END_POINTS = {
ADD_MEAL: "meals/addmeal",
DELETE_MEAL: "meals/deletemeal/",
UPDATE_MEAL: "meals/editmeal/",
GET_MANAGERS: "admin/users/all",
ADD_MANAGER: "admin/addmanager",
};

export const authAxois = axios.create({
Expand Down
18 changes: 13 additions & 5 deletions FRONT_END/src/views/Admin/Managers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<v-select
:items="genders"
label="Gender"
:rules="genderRule"
v-model="newManager.Gender"
></v-select>
</v-col>
Expand Down Expand Up @@ -182,6 +181,7 @@
</template>

<script>
import { END_POINTS, createApiEndPoints } from "@/api.js";
export default {
name: "Managers",
data() {
Expand Down Expand Up @@ -278,7 +278,7 @@ export default {
emailRule: [
function (email) {
let emailRegex = new RegExp(
"^[a-zA-Z0-9]+((._-)[a-zA-Z0-9]+)?@(gmail|yahoo|hotmail).(com|fr|uk|net)$"
"^[a-zA-Z0-9]+((._-)[a-zA-Z0-9]+)?@[a-zA-Z]+.(com|fr|uk|net)$"
);
if (!emailRegex.test(email)) {
return "please enter a valid email adresse";
Expand Down Expand Up @@ -315,11 +315,19 @@ export default {
methods: {
handleAddManager() {
// if(this.$refs.formAdd.validate()) {
if(this.$refs.formAdd.validate()) {
// } else {
createApiEndPoints(END_POINTS.ADD_MANAGER)
.create({...this.newManager})
.then(response => {
console.log(response);
console.log(this.newManager.Email);
})
.catch(error => console.log(error));
// }
} else {
console.log("form validation failed");
}
this.dialogAdd = false;
},
Expand Down
4 changes: 3 additions & 1 deletion FRONT_END/src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ export default {
localStorage.setItem("L_T", response.data.userDisplay.token);
// Get the current logged in user role to redirect to the right dashboard
if(response.data.userDisplay.role == "User") {
this.$router.push({ name: "UserDashboardMeals" });
this.$router.push({ name: "UserDashboardMeals" }, () => {
location.reload();
});
} else if(response.data.userDisplay.role == "Manager") {
this.$router.push({ name: "managerDashboard" });
} else if(response.data.userDisplay.role == "Admin") {
Expand Down
2 changes: 1 addition & 1 deletion FRONT_END/src/views/User/Meals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export default {
Name: this.editedItem.name,
Date: this.editedItem.date + "T" + this.editedItem.time,
Description: this.editedItem.description,
Calories: this.editedItem.calories,
Calories: parseInt(this.editedItem.calories),
};
createApiEndPoints(
END_POINTS.UPDATE_MEAL + "" + this.editedItem.id_Meal
Expand Down

0 comments on commit bb3a179

Please sign in to comment.