Fix Admin panel categories modal, add error handling, enforce cursor-pointer globally
This commit is contained in:
1 parent
69502fc380
commit
82ab454647
47 files changed
+2968
-653
No files matched your search
@@ -240,6 +240,9 @@ export default function ArchivePage({
|
||||
}
|
||||
|
||||
setFilteredProducts(result);
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch products:", error);
|
||||
toast.error("خطا در دریافت لیست محصولات از سرور. لطفاً صفحه را رفرش کنید.");
|
||||
} finally {
|
||||
setIsUpdating(false);
|
||||
}
|
||||
@@ -383,7 +386,7 @@ export default function ArchivePage({
|
||||
<div key="grid" className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6">
|
||||
<AnimatePresence mode="popLayout">
|
||||
{filteredProducts.map((p: Product) => (
|
||||
<ArchiveProductCard key={p.id} product={p} onClick={(p) => router.push(`/shop/${p.id}`)} />
|
||||
<ArchiveProductCard key={p.id} product={p} onClick={(p) => router.push(`/shop/${p.slug || p.id}`)} />
|
||||
))}
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { motion, AnimatePresence } from "motion/react";
|
||||
import { Eye, ShoppingCart, ShieldCheck, Heart, AlertCircle, Sparkles } from "lucide-react";
|
||||
import SafeImage from "./SafeImage";
|
||||
import { ProductCardSkeleton } from "./Skeleton";
|
||||
import Link from 'next/link';
|
||||
|
||||
function ProductCard({ product, onClick }: { product: Product; key?: string | number; onClick: (p: Product) => void }) {
|
||||
const { getActivePet } = usePetStore();
|
||||
@@ -51,6 +52,7 @@ function ProductCard({ product, onClick }: { product: Product; key?: string | nu
|
||||
</div>
|
||||
|
||||
{/* Hover Actions */}
|
||||
<Link href={`/shop/${product.slug || product.id}`} className="absolute inset-0 z-10" />
|
||||
<div className="absolute inset-0 bg-canina-blue/60 opacity-0 group-hover:opacity-100 backdrop-blur-sm transition-all duration-300 flex items-center justify-center gap-4">
|
||||
<div className="w-12 h-12 rounded-full bg-white text-canina-blue flex items-center justify-center hover:scale-110 transition-transform shadow-lg">
|
||||
<Eye className="w-5 h-5" />
|
||||
@@ -93,6 +95,7 @@ function ProductCard({ product, onClick }: { product: Product; key?: string | nu
|
||||
}
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
export default function FeaturedProducts() {
|
||||
const router = useRouter();
|
||||
@@ -104,6 +107,9 @@ export default function FeaturedProducts() {
|
||||
try {
|
||||
const data = await productService.getFeaturedProducts();
|
||||
setProducts(data);
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch featured products:", error);
|
||||
toast.error("خطا در دریافت لیست محصولات از سرور. لطفاً صفحه را رفرش کنید.");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -141,7 +147,7 @@ export default function FeaturedProducts() {
|
||||
Array.from({ length: 3 }).map((_, i) => <ProductCardSkeleton key={i} />)
|
||||
) : (
|
||||
products.map((p) => (
|
||||
<ProductCard key={p.id} onClick={(p) => router.push(`/shop/${p.id}`)} product={p} />
|
||||
<ProductCard key={p.id} onClick={(p) => router.push(`/shop/${p.slug || p.id}`)} product={p} />
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -69,7 +69,7 @@ import SafeImage from "./SafeImage";
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
export default function ProductPage({ productId }: { productId: string }) {
|
||||
export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
const router = useRouter();
|
||||
const [product, setProduct] = useState<Product | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
@@ -82,12 +82,12 @@ export default function ProductPage({ productId }: { productId: string }) {
|
||||
productService.getProducts()
|
||||
.then((products) => {
|
||||
setAllProducts(products);
|
||||
const found = products.find(p => p.id === productId);
|
||||
const found = products.find(p => p.slug === productSlug || p.id === productSlug);
|
||||
setProduct(found || null);
|
||||
})
|
||||
.catch(err => console.error("Error fetching products in ProductPage:", err))
|
||||
.finally(() => setIsLoading(false));
|
||||
}, [productId]);
|
||||
}, [productSlug]);
|
||||
const { pets, getActivePet } = usePetStore();
|
||||
const activePet = getActivePet();
|
||||
const { petType, weight, setPetType, setWeight } = useCalculatorStore();
|
||||
@@ -102,7 +102,9 @@ export default function ProductPage({ productId }: { productId: string }) {
|
||||
|
||||
// Re-hydrate product to ensure methods like calculateDosage exist
|
||||
const fullProduct = useMemo(() => {
|
||||
if (!product) return null;
|
||||
const apiProduct = allProducts.find(p => p.id === product.id) || product;
|
||||
if (!apiProduct) return null;
|
||||
const staticProduct = PRODUCTS.find(p => p.id === apiProduct.id || p.artNo === apiProduct.artNo);
|
||||
if (staticProduct) {
|
||||
return {
|
||||
@@ -133,6 +135,7 @@ export default function ProductPage({ productId }: { productId: string }) {
|
||||
}, [activePet, setWeight, setPetType]);
|
||||
|
||||
const calculation = useMemo(() => {
|
||||
if (!fullProduct || typeof fullProduct.calculateDosage !== 'function') return null;
|
||||
const result = fullProduct.calculateDosage(weight, petType === "young");
|
||||
const duration = Math.floor(fullProduct.packageSize / result.quantity);
|
||||
|
||||
@@ -330,7 +333,8 @@ export default function ProductPage({ productId }: { productId: string }) {
|
||||
|
||||
{/* Specialist Note */}
|
||||
<section className="bg-white rounded-[3rem] p-10 border border-medical-gray-200">
|
||||
<div className="flex flex-col md:flex-row gap-10 items-start">
|
||||
{product.specialist && (
|
||||
<div className="flex flex-col md:flex-row gap-10 items-start">
|
||||
<img
|
||||
src={product.specialist.image}
|
||||
alt={product.specialist.name}
|
||||
@@ -348,6 +352,7 @@ export default function ProductPage({ productId }: { productId: string }) {
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{/* Specialized Landing Banner */}
|
||||
|
||||
@@ -64,7 +64,7 @@ export default function SearchResultsPage({ query }: { query: string }) {
|
||||
<motion.div
|
||||
key={product.id}
|
||||
layoutId={product.id}
|
||||
onClick={() => router.push(`/shop/${product.id}`)}
|
||||
onClick={() => router.push(`/shop/${product.slug || product.id}`)}
|
||||
className="bg-white rounded-[2.5rem] p-8 border border-medical-gray-200 group cursor-pointer hover:shadow-2xl hover:shadow-canina-blue/10 transition-all flex flex-col relative"
|
||||
>
|
||||
<div className="relative aspect-square mb-8 bg-medical-gray-50 rounded-[2rem] overflow-hidden p-6 flex items-center justify-center">
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import React, { useState } from "react";
|
||||
import { Play, PlayCircle, Star, ShieldCheck, X } from "lucide-react";
|
||||
import { motion, AnimatePresence } from "motion/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
const VIDEOS = [
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user