pedi2/resources/js/store/modules/ui.js

34 lines
846 B
JavaScript
Vendored

import { dropWhile } from "lodash/array";
const state = {
show_chismosa: false,
show_devoluciones: false,
miga_inicial: { nombre: 'Categorias', action: 'productos/getProductos' },
migas: [{ nombre: 'Categorias', action: 'productos/getProductos' }],
};
const mutations = {
toggleChismosa(state) {
state.show_chismosa = !state.show_chismosa;
},
toggleDevoluciones(state) {
state.show_devoluciones = !state.show_devoluciones;
},
addMiga(state, miga) {
state.migas.push(miga);
},
};
const actions = {
clickMiga({ dispatch }, { miga }) {
dispatch(miga.action, null, { root: true });
state.migas = dropWhile(state.migas.reverse(),(m => m.nombre !== miga.nombre)).reverse();
}
};
export default {
namespaced: true,
state,
mutations,
actions,
};