diff --git a/frontend/application/components/ArchivePage.tsx b/frontend/application/components/ArchivePage.tsx index 2bd51ded..18d85433 100644 --- a/frontend/application/components/ArchivePage.tsx +++ b/frontend/application/components/ArchivePage.tsx @@ -1,3 +1,4 @@ +import { useUserStore } from "../lib/store/userStore"; "use client"; import React, { useState, useMemo, useEffect, useCallback } from "react"; import { createPortal } from "react-dom"; @@ -87,7 +88,8 @@ export const ArchiveProductCard: React.FC<{ product: Product }> = ({ product }) const { addItem } = useCartStore(); const cartItem = useCartStore((s) => s.items.find(i => i.product.id === product.id)); const [isAdding, setIsAdding] = useState(false); - const activePet = usePetStore(state => state.pets.find(p => p.id === state.activePetId) || null); + const isLoggedIn = useUserStore(s => s.isLoggedIn); + const activePet = usePetStore(state => (isLoggedIn ? (state.pets.find(p => p.id === state.activePetId) || null) : null)); const { showPrices, allowCart, showPreorderBtn } = useCatalogMode(); const productUrl = `/shop/${product.slug || product.id}`; @@ -132,8 +134,8 @@ export const ArchiveProductCard: React.FC<{ product: Product }> = ({ product }) {/* SpecialBadge moved below image to avoid covering product photo */} {compatibility && ( -
{compatibility.type === 'alert' ? ( forBoth ? ( @@ -276,7 +278,8 @@ const ArchiveProductListItem: React.FC<{ product: Product }> = ({ product }) => const { addItem } = useCartStore(); const cartItem = useCartStore((s) => s.items.find(i => i.product.id === product.id)); const [isAdding, setIsAdding] = useState(false); - const activePet = usePetStore(state => state.pets.find(p => p.id === state.activePetId) || null); + const isLoggedIn = useUserStore(s => s.isLoggedIn); + const activePet = usePetStore(state => (isLoggedIn ? (state.pets.find(p => p.id === state.activePetId) || null) : null)); const productUrl = `/shop/${product.slug || product.id}`; const handleAddToCart = (e: React.MouseEvent) => { diff --git a/frontend/application/components/Header.tsx b/frontend/application/components/Header.tsx index 7f84bccf..38a9bbb5 100644 --- a/frontend/application/components/Header.tsx +++ b/frontend/application/components/Header.tsx @@ -249,11 +249,12 @@ export default function Header({ {/* Left Action Buttons */}
- {/* Prescription Upload Button (Desktop & Mobile) */} + {/* Prescription Upload Button (Desktop & Mobile) - Opens Prescription Modal */} {isPrescriptionEnabled && (