#44 feat: ocultar carrito y deshabilitar controles para usuarios no autenticados en catálogo
This commit is contained in:
@@ -71,7 +71,7 @@
|
|||||||
color="error"
|
color="error"
|
||||||
class="qty-btn"
|
class="qty-btn"
|
||||||
@click="decrease(product)"
|
@click="decrease(product)"
|
||||||
:disabled="product.quantity === 0"
|
:disabled="disabled || product.quantity === 0"
|
||||||
>
|
>
|
||||||
<v-icon size="20">mdi-minus</v-icon>
|
<v-icon size="20">mdi-minus</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
@@ -87,6 +87,7 @@
|
|||||||
single-line
|
single-line
|
||||||
flat
|
flat
|
||||||
aria-label="Cantidad"
|
aria-label="Cantidad"
|
||||||
|
:disabled="disabled"
|
||||||
@input="handleQuantityChange"
|
@input="handleQuantityChange"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -97,6 +98,7 @@
|
|||||||
color="success"
|
color="success"
|
||||||
class="qty-btn"
|
class="qty-btn"
|
||||||
@click="handleIncrease"
|
@click="handleIncrease"
|
||||||
|
:disabled="disabled"
|
||||||
>
|
>
|
||||||
<v-icon size="20">mdi-plus</v-icon>
|
<v-icon size="20">mdi-plus</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
@@ -128,6 +130,10 @@ export default {
|
|||||||
type: Function,
|
type: Function,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
disabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleIncrease() {
|
handleIncrease() {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<v-container fluid>
|
<v-container fluid>
|
||||||
<!-- Backdrop para mobile cuando el carrito está expandido -->
|
<!-- Backdrop para mobile cuando el carrito está expandido -->
|
||||||
<div
|
<div
|
||||||
v-if="isMobile && !cartCollapsed"
|
v-if="isMobile && !cartCollapsed && isAuthenticated"
|
||||||
class="cart-backdrop"
|
class="cart-backdrop"
|
||||||
@click="cartCollapsed = true"
|
@click="cartCollapsed = true"
|
||||||
></div>
|
></div>
|
||||||
@@ -80,6 +80,7 @@
|
|||||||
:decrease="decrease"
|
:decrease="decrease"
|
||||||
:currency="currency"
|
:currency="currency"
|
||||||
:updateQuantity="updateQuantity"
|
:updateQuantity="updateQuantity"
|
||||||
|
:disabled="!isAuthenticated"
|
||||||
@add-to-cart="addToCart"
|
@add-to-cart="addToCart"
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -124,6 +125,7 @@
|
|||||||
:class="{ 'cart-is-collapsed': cartCollapsed && isMobile }"
|
:class="{ 'cart-is-collapsed': cartCollapsed && isMobile }"
|
||||||
>
|
>
|
||||||
<Cart
|
<Cart
|
||||||
|
v-if="isAuthenticated"
|
||||||
:cart-items="cartItems"
|
:cart-items="cartItems"
|
||||||
:currency="currency"
|
:currency="currency"
|
||||||
:is-collapsed="cartCollapsed"
|
:is-collapsed="cartCollapsed"
|
||||||
@@ -134,6 +136,20 @@
|
|||||||
@update-quantity="updateCartQuantity"
|
@update-quantity="updateCartQuantity"
|
||||||
@toggle-collapse="toggleCart"
|
@toggle-collapse="toggleCart"
|
||||||
/>
|
/>
|
||||||
|
<v-card v-else class="login-prompt-card pa-4 text-center">
|
||||||
|
<v-icon size="48" color="primary" class="mb-2">mdi-cart-lock</v-icon>
|
||||||
|
<p class="text-body-2 text-medium-emphasis mb-3">
|
||||||
|
Inicia sesión para agregar productos al carrito y finalizar tu compra
|
||||||
|
</p>
|
||||||
|
<v-btn
|
||||||
|
color="primary"
|
||||||
|
variant="tonal"
|
||||||
|
prepend-icon="mdi-login"
|
||||||
|
@click="openLoginDialog"
|
||||||
|
>
|
||||||
|
Iniciar Sesión
|
||||||
|
</v-btn>
|
||||||
|
</v-card>
|
||||||
</div>
|
</div>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -229,6 +245,12 @@
|
|||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
|
<!-- Login Dialog -->
|
||||||
|
<LoginDialog
|
||||||
|
ref="loginDialogRef"
|
||||||
|
@login-success="onLoginSuccess"
|
||||||
|
/>
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -236,7 +258,9 @@
|
|||||||
import Card from "@/components/catalog/Card.vue";
|
import Card from "@/components/catalog/Card.vue";
|
||||||
import Cart from "@/components/catalog/Cart.vue";
|
import Cart from "@/components/catalog/Cart.vue";
|
||||||
import PaginationControls from "@/components/catalog/PaginationControls.vue";
|
import PaginationControls from "@/components/catalog/PaginationControls.vue";
|
||||||
|
import LoginDialog from "@/components/LoginDialog.vue";
|
||||||
import { useCartStore } from "@/stores/cart";
|
import { useCartStore } from "@/stores/cart";
|
||||||
|
import { useAuthStore } from "@/stores/auth";
|
||||||
import { inject, ref, computed, onMounted, onUnmounted } from "vue";
|
import { inject, ref, computed, onMounted, onUnmounted } from "vue";
|
||||||
import not_image_product from "@/assets/not_image_for_product.jpeg";
|
import not_image_product from "@/assets/not_image_for_product.jpeg";
|
||||||
|
|
||||||
@@ -245,9 +269,11 @@ export default {
|
|||||||
Card,
|
Card,
|
||||||
Cart,
|
Cart,
|
||||||
PaginationControls,
|
PaginationControls,
|
||||||
|
LoginDialog,
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const cartStore = useCartStore();
|
const cartStore = useCartStore();
|
||||||
|
const authStore = useAuthStore();
|
||||||
const cartCollapsed = ref(false); // Cambiado a false para que inicie expandido en desktop
|
const cartCollapsed = ref(false); // Cambiado a false para que inicie expandido en desktop
|
||||||
const windowWidth = ref(window.innerWidth);
|
const windowWidth = ref(window.innerWidth);
|
||||||
|
|
||||||
@@ -267,6 +293,7 @@ export default {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
cartStore,
|
cartStore,
|
||||||
|
authStore,
|
||||||
cartCollapsed,
|
cartCollapsed,
|
||||||
isMobile,
|
isMobile,
|
||||||
windowWidth,
|
windowWidth,
|
||||||
@@ -309,6 +336,9 @@ export default {
|
|||||||
cartCount() {
|
cartCount() {
|
||||||
return this.cartStore.cartCount;
|
return this.cartStore.cartCount;
|
||||||
},
|
},
|
||||||
|
isAuthenticated() {
|
||||||
|
return this.authStore.isAuthenticated;
|
||||||
|
},
|
||||||
// Búsqueda
|
// Búsqueda
|
||||||
filteredItems() {
|
filteredItems() {
|
||||||
if (!this.searchQuery) return this.items;
|
if (!this.searchQuery) return this.items;
|
||||||
@@ -521,6 +551,14 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
openLoginDialog() {
|
||||||
|
this.$refs.loginDialogRef.open();
|
||||||
|
},
|
||||||
|
onLoginSuccess() {
|
||||||
|
this.api.getCurrentUser().then((user) => {
|
||||||
|
this.authStore.setUser(user);
|
||||||
|
});
|
||||||
|
},
|
||||||
currency(val) {
|
currency(val) {
|
||||||
if (val == null) return "-";
|
if (val == null) return "-";
|
||||||
return new Intl.NumberFormat("es-CO", {
|
return new Intl.NumberFormat("es-CO", {
|
||||||
@@ -726,6 +764,14 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ============================================
|
||||||
|
LOGIN PROMPT CARD
|
||||||
|
============================================ */
|
||||||
|
.login-prompt-card {
|
||||||
|
border: 2px dashed rgba(0, 0, 0, 0.12);
|
||||||
|
background: #fafafa !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* ============================================
|
/* ============================================
|
||||||
MODALES
|
MODALES
|
||||||
============================================ */
|
============================================ */
|
||||||
|
|||||||
Reference in New Issue
Block a user