const state = { lastFetch: null, pedido_id: null, nombre: null, productos: null, aprobado: null, total: null, total_transporte: null, cantidad_transporte: null, total_sin_devoluciones: null, devoluciones_total: null, devoluciones_notas: null, }; const mutations = { setState(state, pedido) { state.lastFetch = new Date(); state.pedido_id = pedido.id; state.nombre = pedido.nombre; state.productos = pedido.productos; state.aprobado = pedido.aprobado; state.total = pedido.total; state.total_transporte = pedido.total_transporte; state.cantidad_transporte = pedido.cantidad_transporte; state.total_sin_devoluciones = pedido.total_sin_devoluciones; state.devoluciones_total = pedido.devoluciones_total; state.devoluciones_notas = pedido.devoluciones_notas; }, }; const actions = { async crearPedido({ commit }, nombre, grupo_de_compra_id) { const response = await axios.post("/api/subpedidos", { nombre: nombre, grupo_de_compra_id: grupo_de_compra_id }); commit('setState', response.data); }, async getPedido({ commit }, pedido_id) { const response = await axios.get(`/api/subpedidos/${pedido_id}`); commit('setState', response.data.data); }, async modificarChismosa({ commit }, producto_id, cantidad, notas) {}, async modificarDevoluciones({ commit }, monto, notas) {} }; const getters = { pedidoDefinido() { return state.lastFetch !== null; }, } export default { namespaced: true, state, mutations, actions, getters, };