Enhance product detail page and header with API-driven navigation.

Add gallery lightbox, tabs, marketplace CTAs, and similar products on product pages; load the business logo and level-2 category dropdown in the header.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-19 20:38:51 +03:30
co-authored by Cursor
parent 4e517fe3b2
commit 184d2f1ea4
11 changed files with 856 additions and 102 deletions
+28
View File
@@ -48,3 +48,31 @@ export function findCategoryById(categories: Category[], id?: string | null) {
if (!id) return null;
return categories.find((item) => item.id === id) ?? null;
}
export function listRootProductCategories(categories: Category[]) {
return buildCategoryTree(categories).filter((category) => category.isActive);
}
export function listLevel2ProductCategories(categories: Category[]) {
return listRootProductCategories(categories).flatMap((root) =>
root.children.filter((category) => category.isActive),
);
}
export async function getRootProductCategories() {
const categories = await listCategories("product");
return listRootProductCategories(categories).map((category) => ({
id: category.id,
label: categoryLabel(category),
href: `/user-products?categoryId=${encodeURIComponent(category.id)}`,
}));
}
export async function getLevel2ProductCategories() {
const categories = await listCategories("product");
return listLevel2ProductCategories(categories).map((category) => ({
id: category.id,
label: categoryLabel(category),
href: `/user-products?categoryId=${encodeURIComponent(category.id)}`,
}));
}
+9
View File
@@ -0,0 +1,9 @@
export function resolveProductGallery(product: {
images?: { url: string }[] | null;
imageUrl?: string | null;
}) {
const fromImages =
product.images?.map((img) => img.url).filter(Boolean) ?? [];
if (fromImages.length > 0) return fromImages;
return product.imageUrl ? [product.imageUrl] : [];
}