parametro para tipo de sesion en guardar_sesion
This commit is contained in:
parent
07a71098f4
commit
eddf2776d0
1 changed files with 18 additions and 15 deletions
33
resources/js/store/modules/pedido.js
vendored
33
resources/js/store/modules/pedido.js
vendored
|
@ -52,26 +52,31 @@ const actions = {
|
||||||
const response = await axios.get('/user/grupo_de_compra');
|
const response = await axios.get('/user/grupo_de_compra');
|
||||||
commit('setGrupoDeCompra', response.data.grupo_de_compra);
|
commit('setGrupoDeCompra', response.data.grupo_de_compra);
|
||||||
},
|
},
|
||||||
async guardarSesion(_, { pedido_id }) {
|
async guardarSesion(_, { pedido_id, tipo_sesion }) {
|
||||||
await axios.post("/pedido/sesion", { id: pedido_id });
|
const body = { id: pedido_id };
|
||||||
|
await axios.post(`/${tipo_sesion}/sesion`, body);
|
||||||
},
|
},
|
||||||
async crearPedido({ commit, dispatch }, req) {
|
async crearPedido({ commit, dispatch }, { nombre, grupo_de_compra_id, tipo_id }) {
|
||||||
const response = await axios.post("/api/subpedidos", req);
|
const body = { nombre, grupo_de_compra_id, tipo_id };
|
||||||
dispatch("guardarSesion", { pedido_id: response.data.data.id});
|
const response = await axios.post("/api/subpedidos", body);
|
||||||
|
|
||||||
|
let tipo_sesion = 'pedido';
|
||||||
|
if (tipo_id !== 1)
|
||||||
|
tipo_sesion = 'ollas';
|
||||||
|
|
||||||
|
dispatch("guardarSesion", { pedido_id: response.data.data.id, tipo_sesion: tipo_sesion });
|
||||||
commit('setPedido', response.data.data);
|
commit('setPedido', response.data.data);
|
||||||
},
|
},
|
||||||
async elegirPedido({ commit, dispatch }, { pedido_id }) {
|
async elegirPedido({ commit, dispatch }, { pedido_id }) {
|
||||||
const response = await axios.get(`/api/subpedidos/${pedido_id}`);
|
const response = await axios.get(`/api/subpedidos/${pedido_id}`);
|
||||||
dispatch("guardarSesion", { pedido_id: pedido_id})
|
const body = { pedido_id: pedido_id, tipo_sesion: 'pedido' };
|
||||||
|
dispatch("guardarSesion", body)
|
||||||
commit('setPedido', response.data.data);
|
commit('setPedido', response.data.data);
|
||||||
},
|
},
|
||||||
async modificarChismosa({ commit, dispatch }, { producto_id, cantidad, notas }) {
|
async modificarChismosa({ commit, dispatch }, { producto_id, cantidad, notas }) {
|
||||||
|
const body = { cantidad: cantidad, producto_id: producto_id, notas: notas };
|
||||||
try {
|
try {
|
||||||
const response = await axios.post("/api/subpedidos/" + state.pedido_id + "/sync", {
|
const response = await axios.post("/api/subpedidos/" + state.pedido_id + "/sync", body);
|
||||||
cantidad: cantidad,
|
|
||||||
producto_id: producto_id,
|
|
||||||
notas: notas,
|
|
||||||
});
|
|
||||||
commit('setPedido', response.data.data);
|
commit('setPedido', response.data.data);
|
||||||
dispatch("ui/toast", { mensaje: 'Pedido modificado con éxito' }, { root: true });
|
dispatch("ui/toast", { mensaje: 'Pedido modificado con éxito' }, { root: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -79,11 +84,9 @@ const actions = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async modificarDevoluciones({ commit, dispatch }, { monto, notas }) {
|
async modificarDevoluciones({ commit, dispatch }, { monto, notas }) {
|
||||||
|
const body = { total: monto, notas: notas };
|
||||||
try {
|
try {
|
||||||
const response = await axios.post("api/subpedidos/" + state.pedido_id + "/sync_devoluciones", {
|
const response = await axios.post("api/subpedidos/" + state.pedido_id + "/sync_devoluciones", body);
|
||||||
total: monto,
|
|
||||||
notas: notas,
|
|
||||||
});
|
|
||||||
commit('setPedido', response.data.data);
|
commit('setPedido', response.data.data);
|
||||||
dispatch("ui/toast", { mensaje: 'Devoluciones modificadas con éxito' }, { root: true });
|
dispatch("ui/toast", { mensaje: 'Devoluciones modificadas con éxito' }, { root: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue