Arreglados tipos e imports
This commit is contained in:
parent
b976826bf5
commit
572a8cf3be
6 changed files with 38 additions and 39 deletions
|
@ -42,8 +42,8 @@ const mutations = {
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
async getGrupoDeCompra({ commit }) {
|
async getGrupoDeCompra({ commit }) {
|
||||||
const response = await axios.get('/user/grupo_de_compra');
|
const { data } = await axios.get('/user/grupo_de_compra');
|
||||||
commit('setState', response.data);
|
commit('setState', data);
|
||||||
},
|
},
|
||||||
async setAprobacionPedido({ commit, dispatch }, { pedido_id, aprobacion }){
|
async setAprobacionPedido({ commit, dispatch }, { pedido_id, aprobacion }){
|
||||||
await axios.post("/api/admin/subpedidos/" + pedido_id + "/aprobacion", { aprobacion: aprobacion });
|
await axios.post("/api/admin/subpedidos/" + pedido_id + "/aprobacion", { aprobacion: aprobacion });
|
||||||
|
|
|
@ -7,21 +7,21 @@ const state: ComisionesState = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
setGruposDeCompra(state, { data }) {
|
setGruposDeCompra(state: ComisionesState, { data }) {
|
||||||
state.grupos_de_compra = data;
|
state.grupos_de_compra = data;
|
||||||
state.lastFetch = new Date();
|
state.lastFetch = new Date();
|
||||||
},
|
},
|
||||||
setSaldo(state, { gdc_id, saldo }) {
|
setSaldo(state: ComisionesState, { gdc_id, saldo }) {
|
||||||
const barrio = state.grupos_de_compra.find(gdc => gdc.id === gdc_id);
|
const barrio = state.grupos_de_compra.find(gdc => gdc.id === gdc_id);
|
||||||
const i = state.grupos_de_compra.indexOf(barrio);
|
const i = state.grupos_de_compra.indexOf(barrio!);
|
||||||
state.grupos_de_compra[i].saldo = saldo;
|
state.grupos_de_compra[i].saldo = saldo;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
async getGruposDeCompra({ commit }) {
|
async getGruposDeCompra({ commit }) {
|
||||||
const response = await axios.get('/api/grupos-de-compra/saldos');
|
const { data } = await axios.get('/api/grupos-de-compra/saldos');
|
||||||
commit('setGruposDeCompra', response.data);
|
commit('setGruposDeCompra', data);
|
||||||
},
|
},
|
||||||
async setSaldo({ commit, dispatch }, { gdc_id, saldo }) {
|
async setSaldo({ commit, dispatch }, { gdc_id, saldo }) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { Barrio, Estilos, LoginState, OpcionLogin, Textos } from "./types";
|
import { Estilos, LoginState, OpcionLogin, Textos, UrlRol, UserRol } from "./types";
|
||||||
import { Response, UrlRol, UserRol } from "../comunes";
|
|
||||||
|
|
||||||
const state: LoginState = {
|
const state: LoginState = {
|
||||||
regiones: [],
|
regiones: [],
|
||||||
|
@ -28,16 +27,16 @@ const mutations = {
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
async getRegiones({ commit }): Promise<void> {
|
async getRegiones({ commit }): Promise<void> {
|
||||||
const response: Response<string[]> = await axios.get("/api/regiones");
|
const { data } = await axios.get("/api/regiones");
|
||||||
commit('setRegiones', { regiones: response.data });
|
commit('setRegiones', { regiones: data });
|
||||||
},
|
},
|
||||||
async selectRegion({ commit }, { region }): Promise<void> {
|
async selectRegion({ commit }, { region }): Promise<void> {
|
||||||
const response: Response<Barrio[]> = await axios.get(`/api/regiones/${region}`);
|
const { data } = await axios.get(`/api/regiones/${region}`);
|
||||||
commit('setRegionYBarrios', { region: region, grupos_de_compra: response.data });
|
commit('setRegionYBarrios', { region: region, grupos_de_compra: data });
|
||||||
},
|
},
|
||||||
async getRol({ commit }): Promise<void> {
|
async getRol({ commit }): Promise<void> {
|
||||||
const response: Response<UserRol> = await axios.get("/user/rol");
|
const { data }: UserRol = await axios.get("/user/rol");
|
||||||
commit('setRol', { rol: response.data.rol });
|
commit('setRol', { rol: data.rol });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -47,7 +46,7 @@ const getters = {
|
||||||
.replace('login', '')
|
.replace('login', '')
|
||||||
.split('/')
|
.split('/')
|
||||||
.filter(x => x.length);
|
.filter(x => x.length);
|
||||||
return split[0] ?? 'pedido';
|
return split[0] as UrlRol ?? 'pedido';
|
||||||
},
|
},
|
||||||
textos(): Textos {
|
textos(): Textos {
|
||||||
let rol = getters.urlRol();
|
let rol = getters.urlRol();
|
||||||
|
|
|
@ -50,33 +50,33 @@ const mutations = {
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
async getGrupoDeCompra({ commit }) {
|
async getGrupoDeCompra({ commit }) {
|
||||||
const response = await axios.get('/user/grupo_de_compra');
|
const { data } = await axios.get('/user/grupo_de_compra');
|
||||||
commit('setGrupoDeCompra', response.data.grupo_de_compra);
|
commit('setGrupoDeCompra', data.grupo_de_compra);
|
||||||
},
|
},
|
||||||
async guardarSesion(_, { pedido_id }) {
|
async guardarSesion(_, { pedido_id }) {
|
||||||
await axios.post("/pedido/sesion", { id: pedido_id });
|
await axios.post("/pedido/sesion", { id: pedido_id });
|
||||||
},
|
},
|
||||||
async crearPedido({ commit, dispatch }, { nombre, grupo_de_compra_id }) {
|
async crearPedido({ commit, dispatch }, { nombre, grupo_de_compra_id }) {
|
||||||
const response = await axios.post("/api/subpedidos", {
|
const { data } = await axios.post("/api/subpedidos", {
|
||||||
nombre: nombre,
|
nombre: nombre,
|
||||||
grupo_de_compra_id: grupo_de_compra_id
|
grupo_de_compra_id: grupo_de_compra_id
|
||||||
});
|
});
|
||||||
dispatch("guardarSesion", { pedido_id: response.data.data.id});
|
dispatch("guardarSesion", { pedido_id: data.data.id});
|
||||||
commit('setPedido', response.data.data);
|
commit('setPedido', data.data);
|
||||||
},
|
},
|
||||||
async elegirPedido({ commit, dispatch }, { pedido_id }) {
|
async elegirPedido({ commit, dispatch }, { pedido_id }) {
|
||||||
const response = await axios.get(`/api/subpedidos/${pedido_id}`);
|
const { data } = await axios.get(`/api/subpedidos/${pedido_id}`);
|
||||||
dispatch("guardarSesion", { pedido_id: pedido_id})
|
dispatch("guardarSesion", { pedido_id: pedido_id})
|
||||||
commit('setPedido', response.data.data);
|
commit('setPedido', data.data);
|
||||||
},
|
},
|
||||||
async modificarChismosa({ commit, dispatch }, { producto_id, cantidad, notas }) {
|
async modificarChismosa({ commit, dispatch }, { producto_id, cantidad, notas }) {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post("/api/subpedidos/" + state.pedido_id + "/sync", {
|
const { data } = await axios.post("/api/subpedidos/" + state.pedido_id + "/sync", {
|
||||||
cantidad: cantidad,
|
cantidad: cantidad,
|
||||||
producto_id: producto_id,
|
producto_id: producto_id,
|
||||||
notas: notas,
|
notas: notas,
|
||||||
});
|
});
|
||||||
commit('setPedido', response.data.data);
|
commit('setPedido', 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) {
|
||||||
dispatch("ui/error", { error: error }, { root: true });
|
dispatch("ui/error", { error: error }, { root: true });
|
||||||
|
@ -84,11 +84,11 @@ const actions = {
|
||||||
},
|
},
|
||||||
async modificarDevoluciones({ commit, dispatch }, { monto, notas }) {
|
async modificarDevoluciones({ commit, dispatch }, { monto, notas }) {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post("api/subpedidos/" + state.pedido_id + "/sync_devoluciones", {
|
const { data } = await axios.post("api/subpedidos/" + state.pedido_id + "/sync_devoluciones", {
|
||||||
total: monto,
|
total: monto,
|
||||||
notas: notas,
|
notas: notas,
|
||||||
});
|
});
|
||||||
commit('setPedido', response.data.data);
|
commit('setPedido', 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) {
|
||||||
dispatch("ui/error", { error: error }, { root: true });
|
dispatch("ui/error", { error: error }, { root: true });
|
||||||
|
|
|
@ -9,15 +9,15 @@ const state: ProductosState = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
setCategorias(state, categorias) {
|
setCategorias(state: ProductosState, categorias) {
|
||||||
state.lastFetch = new Date();
|
state.lastFetch = new Date();
|
||||||
state.categorias = categorias;
|
state.categorias = categorias;
|
||||||
},
|
},
|
||||||
setProductos(state, productos) {
|
setProductos(state: ProductosState, productos) {
|
||||||
state.lastFetch = new Date();
|
state.lastFetch = new Date();
|
||||||
state.productos = productos;
|
state.productos = productos;
|
||||||
},
|
},
|
||||||
setFiltro(state, filtro) {
|
setFiltro(state: ProductosState, filtro) {
|
||||||
state.lastFetch = new Date();
|
state.lastFetch = new Date();
|
||||||
state.filtro = filtro;
|
state.filtro = filtro;
|
||||||
},
|
},
|
||||||
|
@ -29,23 +29,23 @@ const actions = {
|
||||||
dispatch('getProductos');
|
dispatch('getProductos');
|
||||||
},
|
},
|
||||||
async getCategorias({ commit }) {
|
async getCategorias({ commit }) {
|
||||||
const response = await axios.get('api/categorias');
|
const { data } = await axios.get('api/categorias');
|
||||||
commit('setCategorias', response.data);
|
commit('setCategorias', data);
|
||||||
},
|
},
|
||||||
async getProductos({ commit }) {
|
async getProductos({ commit }) {
|
||||||
const response = await axios.get("/api/productos");
|
const { data } = await axios.get("/api/productos");
|
||||||
commit('setFiltro', undefined);
|
commit('setFiltro', undefined);
|
||||||
commit('setProductos', response.data.data);
|
commit('setProductos', data.data);
|
||||||
},
|
},
|
||||||
async seleccionarCategoria({ dispatch }, { categoria }) {
|
async seleccionarCategoria({ dispatch }, { categoria }) {
|
||||||
dispatch('filtrarProductos', { filtro: "categoria", valor: categoria });
|
dispatch('filtrarProductos', { filtro: "categoria", valor: categoria });
|
||||||
},
|
},
|
||||||
async filtrarProductos({ commit }, { filtro, valor }) {
|
async filtrarProductos({ commit }, { filtro, valor }) {
|
||||||
const response = await axios.get("/api/productos", {
|
const { data } = await axios.get("/api/productos", {
|
||||||
params: { [filtro]: valor }
|
params: { [filtro]: valor }
|
||||||
});
|
});
|
||||||
commit('setFiltro', { clave: filtro, valor: valor });
|
commit('setFiltro', { clave: filtro, valor: valor });
|
||||||
commit('setProductos', response.data.data);
|
commit('setProductos', data.data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ const mutations = {
|
||||||
state.migas.push(miga);
|
state.migas.push(miga);
|
||||||
},
|
},
|
||||||
popUltimaBusqueda(state) {
|
popUltimaBusqueda(state) {
|
||||||
if (!state.migas.at(-1).action)
|
if (!state.migas.at(-1)?.action)
|
||||||
state.migas.pop();
|
state.migas.pop();
|
||||||
},
|
},
|
||||||
reset(state) {
|
reset(state) {
|
||||||
|
@ -39,8 +39,8 @@ const mutations = {
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
async getCanastaActual({ commit }) {
|
async getCanastaActual({ commit }) {
|
||||||
const response = await axios.get('/api/canasta-actual');
|
const { data } = await axios.get('/api/canasta-actual');
|
||||||
commit("setCanastaActual", { canasta: response.data });
|
commit("setCanastaActual", { canasta: data });
|
||||||
},
|
},
|
||||||
clickMiga({ dispatch }, { miga }) {
|
clickMiga({ dispatch }, { miga }) {
|
||||||
let dropWhile = (array, pred) => {
|
let dropWhile = (array, pred) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue