import parser from "@/utils/parser";

export default {
  setFruits: (state, fruits) => {
    state.fruits = parser(fruits, "isFruit");
  },
  setFruit: (state, fruit) => {
    state.fruit = fruit;
  },
  addFruit: (state, fruit) => {
    state.fruits = [...state.fruits, fruit];
  },
  removeFruit: (state, id) => {
    state.fruits = state.fruits.filter(item => item.id != id);
  },
  toggleModal: state => {
    state.modalIsOpen = !state.modalIsOpen;
  },
  setLoading: (state, loading) => {
    state.loading = loading;
  },
  toggleDeleteMode: state => {
    state.deleteMode = !state.deleteMode;
  }
};
