feat: add advisor/contact flow tables and make Blog.authorId required
Deploy Canina / deploy (push) Successful in 25m44s
Deploy Canina / deploy (push) Successful in 25m44s
This commit is contained in:
1 parent
bb81f2c944
commit
d881dc491e
86 files changed
+507
-4111
No files matched your search
@@ -126,17 +126,11 @@ function isVideoUrl(url?: string): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
export default function ProductPage({
|
||||
productSlug,
|
||||
initialProduct,
|
||||
}: {
|
||||
productSlug: string;
|
||||
initialProduct?: Product | null;
|
||||
}) {
|
||||
export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
const router = useRouter();
|
||||
const [product, setProduct] = useState<Product | null>(initialProduct ?? null);
|
||||
const [product, setProduct] = useState<Product | null>(null);
|
||||
const [allProducts, setAllProducts] = useState<Product[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(!initialProduct);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [itemQuantity, setItemQuantity] = useState(1);
|
||||
const [showRefillModal, setShowRefillModal] = useState(false);
|
||||
const [isMounted, setIsMounted] = useState(false);
|
||||
@@ -173,28 +167,18 @@ export default function ProductPage({
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const loadRelatedProducts = () => productService.getProducts({ limit: 50 })
|
||||
.then(res => {
|
||||
if (res && res.data) setAllProducts(res.data);
|
||||
});
|
||||
|
||||
if (initialProduct) {
|
||||
if (initialProduct.image) setActiveImage(initialProduct.image);
|
||||
loadRelatedProducts()
|
||||
.catch(err => console.error("Error fetching related products in ProductPage:", err))
|
||||
.finally(() => setIsLoading(false));
|
||||
return;
|
||||
}
|
||||
|
||||
productService.getProductBySlug(productSlug)
|
||||
.then(p => {
|
||||
setProduct(p);
|
||||
if (p?.image) setActiveImage(p.image);
|
||||
return loadRelatedProducts();
|
||||
return productService.getProducts({ limit: 50 });
|
||||
})
|
||||
.then(res => {
|
||||
if (res && res.data) setAllProducts(res.data);
|
||||
})
|
||||
.catch(err => console.error("Error fetching products in ProductPage:", err))
|
||||
.finally(() => setIsLoading(false));
|
||||
}, [productSlug, initialProduct]);
|
||||
}, [productSlug]);
|
||||
|
||||
useEffect(() => {
|
||||
if (product && product.id) {
|
||||
|
||||
Reference in new issue
Block a user