aggio gasordine
This commit is contained in:
@@ -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 : ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user