refactor: optimize ArchivePage performance and imports

Remove lazy loading for ArchivePage and update cart toast notifications to use direct imports. Refactor pet state selection in product cards for better reactivity.
This commit is contained in:
parsa committed 2026-05-26 11:44:14 +03:30
1 parent 29ba592366
commit 03d100905f
2 files changed
+5 -7

No files matched your search

+3 -6
View File
@@ -4,6 +4,7 @@ import { usePetStore } from "../store/usePetStore";
import { productService } from "../services/productService";
import { motion, AnimatePresence } from "motion/react";
import { ProductCardSkeleton } from "./Skeleton";
import { toast } from "sonner";
import {
Search,
Filter,
@@ -68,19 +69,15 @@ const SYMPTOMS = [
];
const ArchiveProductCard: React.FC<{ product: Product, onClick: (p: Product) => void }> = ({ product, onClick }) => {
const { getActivePet } = usePetStore();
const { addItem } = useCartStore();
const [isAdding, setIsAdding] = useState(false);
const activePet = getActivePet();
const activePet = usePetStore(state => state.pets.find(p => p.id === state.activePetId) || null);
const handleAddToCart = (e: React.MouseEvent) => {
e.stopPropagation();
setIsAdding(true);
addItem(product, 1);
// @ts-ignore
import("sonner").then(({ toast }) => {
toast.success(`${product.name} به سبد خرید اضافه شد`);
});
toast.success(`${product.name} به سبد خرید اضافه شد`);
setTimeout(() => setIsAdding(false), 800);
};