fix(categories): fallback to product name, description and details when translations are missing

This commit is contained in:
Your Name committed 2026-10-19 09:32:09 +07:00
1 parent 5686b3ea9c
commit 296adb849c
1 file changed
+6 -3
+6 -3
View File
@@ -248,6 +248,9 @@ export const categoriesRoute = new Elysia({ prefix: "/categories" })
descObj[t.langCode] = t.description;
detailsObj[t.langCode] = t.details;
});
if (!nameObj.th && p.name) nameObj.th = p.name;
if (!descObj.th && p.description) descObj.th = p.description;
if (!detailsObj.th && p.details) detailsObj.th = p.details;
return {
...p,
name: nameObj,
@@ -259,9 +262,9 @@ export const categoriesRoute = new Elysia({ prefix: "/categories" })
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.brand?.name || '',
description: trans?.description,
details: trans?.details,
name: trans?.name || p.name || p.brand?.name || '',
description: trans?.description || p.description,
details: trans?.details || p.details,
category: { ...p.category, name: resolveCatName(p.category, lang) },
};
}