Agregado tipo para productos sin pivot

This commit is contained in:
Alejandro Tasistro 2025-07-08 20:01:18 -03:00
parent fee23f389c
commit 92d6bc2035
2 changed files with 33 additions and 19 deletions

View file

@ -6,7 +6,7 @@ const state: PedidoState = {
grupo_de_compra: undefined,
pedido_id: undefined,
nombre: undefined,
productos: undefined,
productos: [],
aprobado: undefined,
total: undefined,
total_transporte: undefined,
@ -17,10 +17,10 @@ const state: PedidoState = {
};
const mutations = {
setGrupoDeCompra(state, grupo_de_compra) {
setGrupoDeCompra(state: PedidoState, grupo_de_compra) {
state.grupo_de_compra = grupo_de_compra;
},
setPedido(state, pedido) {
setPedido(state: PedidoState, pedido) {
state.lastFetch = new Date();
state.pedido_id = pedido.id;
state.nombre = pedido.nombre;
@ -33,11 +33,11 @@ const mutations = {
state.devoluciones_total = pedido.devoluciones_total;
state.devoluciones_notas = pedido.devoluciones_notas;
},
reset(state) {
reset(state: PedidoState) {
state.lastFetch = undefined;
state.pedido_id = undefined;
state.nombre = undefined;
state.productos = undefined;
state.productos = [];
state.aprobado = undefined;
state.total = undefined;
state.total_transporte = undefined;
@ -110,10 +110,10 @@ const getters = {
return ((producto_id) => state.productos.some(p => p.id === producto_id));
},
cantidad() {
return ((producto_id) => state.productos.find(p => p.id === producto_id)?.pivot.cantidad ?? 0);
return ((producto_id) => state.productos.find(p => p.id === producto_id)?.cantidad ?? 0);
},
notas() {
return ((producto_id) => state.productos.find(p => p.id === producto_id)?.pivot.notas ?? "");
return ((producto_id) => state.productos.find(p => p.id === producto_id)?.notas ?? "");
}
}

View file

@ -1,18 +1,16 @@
import { Producto } from "../admin/types";
export interface PedidoState {
lastFetch?: Date,
grupo_de_compra: Barrio,
pedido_id: number,
nombre: string,
grupo_de_compra?: Barrio,
pedido_id?: number,
nombre?: string,
productos: Producto[],
aprobado: boolean,
total: number,
total_transporte: number,
cantidad_transporte: number,
total_sin_devoluciones: number,
devoluciones_total: number,
devoluciones_notas: string,
aprobado?: boolean,
total?: number,
total_transporte?: number,
cantidad_transporte?: number,
total_sin_devoluciones?: number,
devoluciones_total?: number,
devoluciones_notas?: string,
}
export interface Barrio {
@ -20,3 +18,19 @@ export interface Barrio {
nombre: string,
devoluciones_habilitadas: boolean,
}
export interface Producto {
id: number,
fila: number,
nombre: string,
precio: number,
categoria: string,
bono: boolean,
created_at: Date,
updated_at: Date,
requiere_notas: boolean,
es_solidario: boolean,
cantidad: number,
total: number,
notas: string,
}