aggio gasordine

This commit is contained in:
Surya Paolo
2024-01-16 16:56:57 +01:00
parent 2005b8cb56
commit 62267ef618
21 changed files with 57 additions and 115 deletions

View File

@@ -65,12 +65,12 @@ function getRecordProductEmpty(): IProduct {
active: false,
idProducer: '',
idStorehouses: [],
idGasordines: [],
idGasordine: '',
idScontisticas: [],
scontisticas: [],
gasordines: [],
idProvider: '',
producer: {},
gasordine: null,
storehouses: [],
provider: {},
price: 0.0,
@@ -121,10 +121,10 @@ export const useProducts = defineStore('Products', {
getProducts: (state: IProductsState) => (cosa?: number): IProduct[] => {
if (!!cosa) {
return state.products.filter((rec: IProduct) => {
const hasGasOrdines = rec.idGasordines && rec.idGasordines.length > 0;
const hasGasOrdines = rec.idGasordine
if ((cosa === shared_consts.PROD.GAS && hasGasOrdines) ||
(cosa === shared_consts.PROD.BOTTEGA && ((!hasGasOrdines || (hasGasOrdines && rec.idGasordines?.length === 0))))) {
(cosa === shared_consts.PROD.BOTTEGA && ((!hasGasOrdines || (hasGasOrdines && rec.idGasordine))))) {
return true;
}
@@ -571,7 +571,7 @@ export const useProducts = defineStore('Products', {
ris = await Api.SendReq('/cart/' + userStore.my._id, 'GET', null)
.then((res) => {
if (res.data.cart) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
if (res.data && res.data.cart) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
this.cart = res.data.cart
} else {
this.cart = { items: [], totalPrice: 0, totalQty: 0, userId: '' }
@@ -665,8 +665,8 @@ export const useProducts = defineStore('Products', {
}
}
if (!order.idGasordine && order.quantitypreordered > 0) {
if (product.gasordines.length === 1) {
order.idGasordine = product.gasordines[0]._id
if (product.gasordine && product.gasordine._id) {
order.idGasordine = product.gasordine._id
} else {
order.idGasordine = globalStore.gasordines ? globalStore.gasordines[0]._id : ''
}