cambios para que se pueda añadir al carrito
This commit is contained in:
parent
0bb2c6dbcc
commit
7fea3f9aaf
|
@ -1,5 +1,5 @@
|
|||
import { defineStore, storeToRefs } from "pinia";
|
||||
import { computed, ref } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
import { apiBack } from "src/boot/axios";
|
||||
|
@ -194,13 +194,16 @@ export const useCartStore = defineStore("cart", () => {
|
|||
const params = transformOptionsToParams(
|
||||
availabilityForm.value || availability.value
|
||||
);
|
||||
const correctProduct = await apiBack.get(`products/${product.itemFk}`, { params });
|
||||
console.log(hasCurrentProduct)
|
||||
await getProducts(params);
|
||||
|
||||
const hasCurrentProduct = computed(() => {
|
||||
return cart.value.find((p) => p.id === product.id);
|
||||
});
|
||||
|
||||
if (isEmpty.value) {
|
||||
//if (isEmpty.value) {
|
||||
if (correctProduct.length === 0) {
|
||||
push("/");
|
||||
return quasarNotify({
|
||||
message:
|
||||
|
@ -209,14 +212,14 @@ export const useCartStore = defineStore("cart", () => {
|
|||
});
|
||||
}
|
||||
|
||||
if (!products.value.data.some((item) => item.id === product.id)) {
|
||||
push("/");
|
||||
return quasarNotify({
|
||||
message:
|
||||
"Este producto no está disponible en su zona, intente añadir un nuevo código postal",
|
||||
type: "erro",
|
||||
});
|
||||
}
|
||||
// if (!products.value.data.some((item) => item.id === product.id)) {
|
||||
// push("/");
|
||||
// return quasarNotify({
|
||||
// message:
|
||||
// "Este producto no está disponible en su zona, intente añadir un nuevo código postal",
|
||||
// type: "erro",
|
||||
// });
|
||||
// }
|
||||
|
||||
if (hasCurrentProduct.value) {
|
||||
return quasarNotify({
|
||||
|
|
Loading…
Reference in New Issue