This commit is contained in:
Your Name committed 2026-06-24 19:44:52 -04:00
1 parent 4536db6741
commit c23a4723ed
2 files changed
+48 -36

No files matched your search

+8 -8
View File
@@ -200,7 +200,7 @@ export const pagesRoute = new Elysia({ prefix: "/pages" })
category: {
include: { translations: true },
},
scent: true,
brand: true,
translations: true,
variants: {
include: {
@@ -219,9 +219,9 @@ export const pagesRoute = new Elysia({ prefix: "/pages" })
include: productInclude,
take: limit
});
} else if (payload.type === 'scent' && payload.scentId) {
} else if ((payload.type === 'scent' || payload.type === 'brand') && (payload.scentId || payload.brandId)) {
products = await prisma.product.findMany({
where: { scentId: Number(payload.scentId) },
where: { brandId: Number(payload.brandId || payload.scentId) },
include: productInclude,
take: limit
});
@@ -247,7 +247,7 @@ export const pagesRoute = new Elysia({ prefix: "/pages" })
return { ...p, name: nameObj, description: descObj, details: detailsObj };
} else {
const trans = p.translations?.find((t: any) => t.langCode === lang) || p.translations?.find((t: any) => t.langCode === 'th') || p.translations?.[0];
return { ...p, name: trans?.name || p.scent?.name || '', description: trans?.description, details: trans?.details };
return { ...p, name: trans?.name || p.brand?.name || '', description: trans?.description, details: trans?.details };
}
});
} else if (section.type === 'PRODUCT_CAROUSEL' && !Array.isArray(populatedPayload.products)) {
@@ -258,7 +258,7 @@ export const pagesRoute = new Elysia({ prefix: "/pages" })
category: {
include: { translations: true },
},
scent: true,
brand: true,
translations: true,
variants: {
include: {
@@ -277,9 +277,9 @@ export const pagesRoute = new Elysia({ prefix: "/pages" })
include: productInclude,
take: limit
});
} else if (payload.type === 'scent' && payload.scentId) {
} else if ((payload.type === 'scent' || payload.type === 'brand') && (payload.scentId || payload.brandId)) {
products = await prisma.product.findMany({
where: { scentId: Number(payload.scentId) },
where: { brandId: Number(payload.brandId || payload.scentId) },
include: productInclude,
take: limit
});
@@ -310,7 +310,7 @@ export const pagesRoute = new Elysia({ prefix: "/pages" })
return { ...p, name: nameObj, description: descObj, details: detailsObj };
}
const trans = p.translations?.find((t: any) => t.langCode === lang) || p.translations?.find((t: any) => t.langCode === 'th') || p.translations?.[0];
return { ...p, name: trans?.name || p.scent?.name || '', description: trans?.description, details: trans?.details };
return { ...p, name: trans?.name || p.brand?.name || '', description: trans?.description, details: trans?.details };
});
} else if (section.type === 'CATEGORIES') {
let categories: any[] = [];