- edit campi prodotti
- edit ordini
This commit is contained in:
@@ -303,8 +303,8 @@ export const useProducts = defineStore('Products', {
|
||||
getOrdersCartByIdProduct: (state: IProductsState) => (idproduct: string): IOrderCart[] | [] => {
|
||||
try {
|
||||
if (state.orders) {
|
||||
const ris = state.orders.filter((ordercart: IOrderCart) => {
|
||||
return ordercart.items!.some(item => {
|
||||
const ris = state.orders.filter((orderscart: IOrderCart) => {
|
||||
return orderscart.items!.some(item => {
|
||||
if (item.order)
|
||||
return (item.order.idProduct === idproduct)
|
||||
&& (item.order.status! < shared_consts.OrderStatus.CHECKOUT_SENT)
|
||||
@@ -322,8 +322,8 @@ export const useProducts = defineStore('Products', {
|
||||
getOrdersCartInAttesaByIdProduct: (state: IProductsState) => (idproduct: string): IOrderCart[] | [] => {
|
||||
try {
|
||||
if (state.orders) {
|
||||
const ris = state.orders.filter((ordercart: IOrderCart) => {
|
||||
return ordercart.items!.some(item => {
|
||||
const ris = state.orders.filter((orderscart: IOrderCart) => {
|
||||
return orderscart.items!.some(item => {
|
||||
if (item.order)
|
||||
return (item.order.idProduct === idproduct)
|
||||
&& (item.order.status! <= shared_consts.OrderStatus.CHECKOUT_SENT)
|
||||
@@ -435,24 +435,100 @@ export const useProducts = defineStore('Products', {
|
||||
return ris
|
||||
},
|
||||
|
||||
async loadProduct({ code }: { code: any }) {
|
||||
async updateOrderByOrder(idOrdersCart: string, idOrder: string, paramstoupdate: any) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
// console.log('loadProducts')
|
||||
|
||||
if (!globalStore.site.confpages.enableEcommerce)
|
||||
return null
|
||||
|
||||
console.log('updateOrderByOrder', 'userid=', userStore.my._id)
|
||||
|
||||
let ris = null
|
||||
|
||||
ris = await Api.SendReq('/orders/updateord', 'POST', { idOrdersCart, idOrder, paramstoupdate })
|
||||
.then((res) => {
|
||||
let myorderscart = res.data.orderscart
|
||||
if (res) {
|
||||
myorderscart = res.data && res.data.orderscart ? res.data.orderscart : null
|
||||
if (myorderscart) {
|
||||
const idord = this.orders.findIndex((ord: IOrderCart) => ord._id === myorderscart._id)
|
||||
if (idord >= 0) {
|
||||
console.log('aggiorna ordine')
|
||||
this.orders[idord] = {...myorderscart}
|
||||
}
|
||||
}
|
||||
}
|
||||
return myorderscart
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error updateOrderByOrder', error)
|
||||
userStore.setErrorCatch(error)
|
||||
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, error)
|
||||
})
|
||||
|
||||
// ApiTables.aftercalling(ris, checkPending, 'categories')
|
||||
|
||||
return ris
|
||||
},
|
||||
|
||||
async updateOrdersCartById(idOrdersCart: string, paramstoupdate: any) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
// console.log('loadProducts')
|
||||
|
||||
if (!globalStore.site.confpages.enableEcommerce)
|
||||
return null
|
||||
|
||||
console.log('updateOrdersCartById', 'userid=', userStore.my._id)
|
||||
|
||||
let ris = null
|
||||
|
||||
ris = await Api.SendReq('/orders/update', 'POST', { idOrdersCart, paramstoupdate })
|
||||
.then((res) => {
|
||||
let myorderscart = res.data.orderscart
|
||||
if (res) {
|
||||
if (myorderscart) {
|
||||
const idord = this.orders.findIndex((ord: IOrderCart) => ord._id === myorderscart._id)
|
||||
if (idord >= 0) {
|
||||
console.log('aggiorna orderscart')
|
||||
this.orders[idord] = myorderscart
|
||||
}
|
||||
}
|
||||
}
|
||||
return myorderscart
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error updateOrderByOrder', error)
|
||||
userStore.setErrorCatch(error)
|
||||
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, error)
|
||||
})
|
||||
|
||||
// ApiTables.aftercalling(ris, checkPending, 'categories')
|
||||
|
||||
return ris
|
||||
},
|
||||
|
||||
async loadProductById(id: string) {
|
||||
|
||||
console.log('loadProduct', code)
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
if (!globalStore.site.confpages.enableEcommerce)
|
||||
return null
|
||||
|
||||
console.log('getProduct', 'code', code)
|
||||
|
||||
// if (userStore.my._id === '') {
|
||||
// return new Types.AxiosError(0, null, 0, '')
|
||||
// }
|
||||
|
||||
let ris = null
|
||||
|
||||
ris = await Api.SendReq('/products/' + code, 'POST', { code })
|
||||
ris = await Api.SendReq('/products/id/' + id, 'GET', null)
|
||||
.then((res) => {
|
||||
console.log('product', res.data.product)
|
||||
if (res.data.product) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
|
||||
|
||||
Reference in New Issue
Block a user