pedi2/resources/js/store/comunes.ts

53 lines
1.3 KiB
TypeScript

export interface ProductoResponse {
id: number,
fila: number,
nombre: string,
precio: number,
categoria: string,
bono: boolean,
created_at: Date,
updated_at: Date,
requiere_notas: boolean,
es_solidario: boolean,
pivot: {
subpedido_id: number,
producto_id: number,
notas: string,
cantidad: number,
total: number,
}
}
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,
notas: string,
cantidad: number,
total: number,
}
export function aplanarProducto(producto: ProductoResponse): Producto {
return {
id: producto.id,
fila: producto.fila,
nombre: producto.nombre,
precio: producto.precio,
categoria: producto.categoria,
bono: producto.bono,
created_at: producto.created_at,
updated_at: producto.updated_at,
requiere_notas: producto.requiere_notas,
es_solidario: producto.es_solidario,
notas: producto.pivot.notas,
cantidad: producto.pivot.cantidad,
total: producto.pivot.total,
};
}