canina/frontend/application/app/catalog/CatalogClient.tsx
parsa aghaei 7e403bd53e
All checks were successful
Deploy Canina / deploy (push) Successful in 1m35s
feat(catalog): implement luxury 3D RTL flipbook catalog with complete A4 PDF export and responsive height
2026-08-16 12:51:06 +03:30

41 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
import React, { useState, useEffect } from "react";
import FlipbookCatalog from "../../components/catalog/FlipbookCatalog";
import { productService } from "../../lib/services/productService";
import { Product, PRODUCTS } from "../../lib/data/products";
export default function CatalogClient() {
const [products, setProducts] = useState<Product[]>([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
productService.getProducts({ limit: 999 })
.then(res => {
if (res.data && res.data.length > 0) {
setProducts(res.data);
} else {
setProducts(PRODUCTS);
}
})
.catch(err => {
console.error("Catalog fetch error, fallback to static products:", err);
setProducts(PRODUCTS);
})
.finally(() => setLoading(false));
}, []);
if (loading) {
return (
<div className="min-h-screen bg-slate-900 text-slate-100 flex items-center justify-center font-vazir">
<div className="text-center space-y-4">
<div className="w-12 h-12 border-4 border-amber-400 border-t-transparent rounded-full animate-spin mx-auto" />
<p className="text-sm font-bold text-slate-300">در حال بارگذاری کاتالوگ دیجیتال Canina Pharma...</p>
</div>
</div>
);
}
return <FlipbookCatalog products={products} />;
}