From 762fde2cd0946f36f42efb6665d34256baec04e9 Mon Sep 17 00:00:00 2001 From: aserrador Date: Mon, 22 Jun 2026 11:46:50 -0500 Subject: [PATCH] =?UTF-8?q?#44=20feat:=20ocultar=20carrito=20y=20deshabili?= =?UTF-8?q?tar=20controles=20para=20usuarios=20no=20autenticados=20en=20ca?= =?UTF-8?q?t=C3=A1logo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/catalog/Card.vue | 8 +++++- src/pages/catalog.vue | 48 ++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/components/catalog/Card.vue b/src/components/catalog/Card.vue index babb3f0..ff35426 100644 --- a/src/components/catalog/Card.vue +++ b/src/components/catalog/Card.vue @@ -71,7 +71,7 @@ color="error" class="qty-btn" @click="decrease(product)" - :disabled="product.quantity === 0" + :disabled="disabled || product.quantity === 0" > mdi-minus @@ -87,6 +87,7 @@ single-line flat aria-label="Cantidad" + :disabled="disabled" @input="handleQuantityChange" /> @@ -97,6 +98,7 @@ color="success" class="qty-btn" @click="handleIncrease" + :disabled="disabled" > mdi-plus @@ -128,6 +130,10 @@ export default { type: Function, required: true, }, + disabled: { + type: Boolean, + default: false, + }, }, methods: { handleIncrease() { diff --git a/src/pages/catalog.vue b/src/pages/catalog.vue index 7e68a95..98d8154 100644 --- a/src/pages/catalog.vue +++ b/src/pages/catalog.vue @@ -2,7 +2,7 @@
@@ -80,6 +80,7 @@ :decrease="decrease" :currency="currency" :updateQuantity="updateQuantity" + :disabled="!isAuthenticated" @add-to-cart="addToCart" /> @@ -124,6 +125,7 @@ :class="{ 'cart-is-collapsed': cartCollapsed && isMobile }" > + @@ -229,6 +245,12 @@ + + +
@@ -236,7 +258,9 @@ import Card from "@/components/catalog/Card.vue"; import Cart from "@/components/catalog/Cart.vue"; import PaginationControls from "@/components/catalog/PaginationControls.vue"; +import LoginDialog from "@/components/LoginDialog.vue"; import { useCartStore } from "@/stores/cart"; +import { useAuthStore } from "@/stores/auth"; import { inject, ref, computed, onMounted, onUnmounted } from "vue"; import not_image_product from "@/assets/not_image_for_product.jpeg"; @@ -245,9 +269,11 @@ export default { Card, Cart, PaginationControls, + LoginDialog, }, setup() { const cartStore = useCartStore(); + const authStore = useAuthStore(); const cartCollapsed = ref(false); // Cambiado a false para que inicie expandido en desktop const windowWidth = ref(window.innerWidth); @@ -267,6 +293,7 @@ export default { return { cartStore, + authStore, cartCollapsed, isMobile, windowWidth, @@ -309,6 +336,9 @@ export default { cartCount() { return this.cartStore.cartCount; }, + isAuthenticated() { + return this.authStore.isAuthenticated; + }, // Búsqueda filteredItems() { 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) { if (val == null) return "-"; 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 ============================================ */