Gestione Ordini: evaso...
This commit is contained in:
@@ -34,15 +34,21 @@ export const useProducts = defineStore('Products', {
|
||||
|
||||
getOrdersCart: (state: IProductsState) => (tipoord: number): IOrderCart[] | undefined => {
|
||||
console.log('state.orders', state.orders)
|
||||
if (tipoord === shared_consts.OrderStatStr.IN_CORSO)
|
||||
if (tipoord === shared_consts.OrderStat.IN_CORSO.value)
|
||||
return state.orders.filter((rec: IOrderCart) => (rec.status ? rec.status : 0) <= shared_consts.OrderStatus.CHECKOUT_SENT)
|
||||
else if (tipoord === shared_consts.OrderStatStr.CONFERMATI)
|
||||
else if (tipoord === shared_consts.OrderStat.CONFERMATI.value)
|
||||
return state.orders.filter((rec: IOrderCart) => rec.status === shared_consts.OrderStatus.ORDER_CONFIRMED)
|
||||
else if (tipoord === shared_consts.OrderStatStr.PAGATI)
|
||||
else if (tipoord === shared_consts.OrderStat.PAGATI.value)
|
||||
return state.orders.filter((rec: IOrderCart) => rec.status === shared_consts.OrderStatus.PAYED)
|
||||
else if (tipoord === shared_consts.OrderStatStr.COMPLETATI)
|
||||
else if (tipoord === shared_consts.OrderStat.DELIVERED.value)
|
||||
return state.orders.filter((rec: IOrderCart) => rec.status === shared_consts.OrderStatus.DELIVERED)
|
||||
else if (tipoord === shared_consts.OrderStat.SHIPPED.value)
|
||||
return state.orders.filter((rec: IOrderCart) => rec.status === shared_consts.OrderStatus.SHIPPED)
|
||||
else if (tipoord === shared_consts.OrderStat.RECEIVED.value)
|
||||
return state.orders.filter((rec: IOrderCart) => rec.status === shared_consts.OrderStatus.RECEIVED)
|
||||
else if (tipoord === shared_consts.OrderStatStr.CANCELLATI)
|
||||
else if (tipoord === shared_consts.OrderStat.COMPLETATI.value)
|
||||
return state.orders.filter((rec: IOrderCart) => rec.status === shared_consts.OrderStatus.COMPLETED)
|
||||
else if (tipoord === shared_consts.OrderStat.CANCELLATI.value)
|
||||
return state.orders.filter((rec: IOrderCart) => rec.status === shared_consts.OrderStatus.CANCELED)
|
||||
},
|
||||
|
||||
@@ -86,6 +92,7 @@ export const useProducts = defineStore('Products', {
|
||||
quantityAvailable: 0,
|
||||
stockQty: 0,
|
||||
canBeShipped: false,
|
||||
tempTotalQty: 0,
|
||||
canBeBuyOnline: false,
|
||||
weight: 0,
|
||||
unit: 0,
|
||||
@@ -371,7 +378,7 @@ export const useProducts = defineStore('Products', {
|
||||
return ris
|
||||
},
|
||||
|
||||
async UpdateStatusCart({ cart_id, status }: { cart_id: string, status: number }) {
|
||||
async CreateOrdersCart({ cart_id, status }: { cart_id: string, status: number }) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
@@ -381,7 +388,38 @@ export const useProducts = defineStore('Products', {
|
||||
|
||||
let ris = null
|
||||
|
||||
ris = await Api.SendReq('/cart/' + userStore.my._id + '/cartstatus', 'POST', { cart_id, status })
|
||||
ris = await Api.SendReq('/cart/' + userStore.my._id + '/createorderscart', 'POST', { cart_id, status })
|
||||
.then((res) => {
|
||||
|
||||
if (res.data.status === shared_consts.OrderStatus.CHECKOUT_SENT) {
|
||||
// Cancella il Carrello, ho creato l'ordine !
|
||||
this.cart = {}
|
||||
}
|
||||
if (res.data.orders)
|
||||
this.orders = res.data.orders
|
||||
|
||||
return res.data.recOrderCart
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error UpdateStatusCart', error)
|
||||
userStore.setErrorCatch(error)
|
||||
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, error)
|
||||
})
|
||||
|
||||
return ris
|
||||
},
|
||||
|
||||
async UpdateStatusCart({ ordercart_id, status }: { ordercart_id: string, status: number }) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
if (!globalStore.site.confpages.enableEcommerce)
|
||||
return null
|
||||
|
||||
let ris = null
|
||||
|
||||
ris = await Api.SendReq('/cart/updatestatuscart', 'POST', { ordercart_id, status })
|
||||
.then((res) => {
|
||||
|
||||
if (res.data.status === shared_consts.OrderStatus.CHECKOUT_SENT) {
|
||||
@@ -400,7 +438,7 @@ export const useProducts = defineStore('Products', {
|
||||
return ris
|
||||
},
|
||||
|
||||
async UpdateOrderStatus({ order_id, status }: { order_id: string, status: number }) {
|
||||
async UpdateOrderCartStatus({ order_id, status }: { order_id: string, status: number }) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
@@ -410,12 +448,12 @@ export const useProducts = defineStore('Products', {
|
||||
|
||||
let ris = null
|
||||
|
||||
ris = await Api.SendReq('/cart/' + userStore.my._id + '/orderstatus', 'POST', { order_id, status })
|
||||
ris = await Api.SendReq('/cart/' + userStore.my._id + '/ordercartstatus', 'POST', { order_id, status })
|
||||
.then((res) => {
|
||||
return res.data.status
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error UpdateOrderStatus', error)
|
||||
console.log('error UpdateOrderCartStatus', error)
|
||||
userStore.setErrorCatch(error)
|
||||
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, error)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user