42 lines
919 B
JavaScript
Vendored
42 lines
919 B
JavaScript
Vendored
import axios from "axios";
|
|
|
|
const state = {
|
|
monto_por_olla: undefined,
|
|
cantidad_de_ollas: 0,
|
|
};
|
|
|
|
const mutations = {
|
|
setMontoPorOlla(state, parametros) {
|
|
state.monto_por_olla = Number.parseInt(parametros.find(p => p.id === 'monto-olla').valor);
|
|
},
|
|
incrementar(state) {
|
|
state.cantidad_de_ollas += 1;
|
|
},
|
|
decrementar(state) {
|
|
state.cantidad_de_ollas -= 1;
|
|
},
|
|
};
|
|
|
|
const actions = {
|
|
async getMontoPorOlla({ commit }) {
|
|
const response = await axios.get('/api/parametros');
|
|
commit('setMontoPorOlla', response.data);
|
|
},
|
|
};
|
|
|
|
const getters = {
|
|
montoTotal() {
|
|
return state.monto_por_olla * state.cantidad_de_ollas;
|
|
},
|
|
montoSuperado: (state, getters, rootState) => {
|
|
return rootState.pedido.total > getters.montoTotal;
|
|
}
|
|
};
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state,
|
|
mutations,
|
|
actions,
|
|
getters,
|
|
};
|