fix(categories): fallback to product name, description and details when translations are missing
This commit is contained in:
1 parent
5686b3ea9c
commit
296adb849c
1 file changed
+6
-3
@@ -248,6 +248,9 @@ export const categoriesRoute = new Elysia({ prefix: "/categories" })
|
|||||||
descObj[t.langCode] = t.description;
|
descObj[t.langCode] = t.description;
|
||||||
detailsObj[t.langCode] = t.details;
|
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 {
|
return {
|
||||||
...p,
|
...p,
|
||||||
name: nameObj,
|
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];
|
const trans = p.translations?.find((t: any) => t.langCode === lang) || p.translations?.find((t: any) => t.langCode === 'th') || p.translations?.[0];
|
||||||
return {
|
return {
|
||||||
...p,
|
...p,
|
||||||
name: trans?.name || p.brand?.name || '',
|
name: trans?.name || p.name || p.brand?.name || '',
|
||||||
description: trans?.description,
|
description: trans?.description || p.description,
|
||||||
details: trans?.details,
|
details: trans?.details || p.details,
|
||||||
category: { ...p.category, name: resolveCatName(p.category, lang) },
|
category: { ...p.category, name: resolveCatName(p.category, lang) },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user