diff --git a/app/models/mappers/homepageMapper.ts b/app/models/mappers/homepageMapper.ts index 428f526..71fe4dd 100644 --- a/app/models/mappers/homepageMapper.ts +++ b/app/models/mappers/homepageMapper.ts @@ -19,10 +19,15 @@ export function toHomepageView(raw: Homepage): HomepageView { const cover = isObject(item.cover) ? item.cover.id : item.cover; + console.log( + 'Has empty array in product translations:', + item.translations.length === 0 + ); + const trans = item.translations?.[0] ?? { name: '', summary: '' }; return { id: item.id, - name: item.translations?.[0].name, - summary: item.translations?.[0].summary, + name: trans.name, + summary: trans.summary, cover: cover, } satisfies HomepageProductView; }); @@ -33,11 +38,12 @@ export function toHomepageView(raw: Homepage): HomepageView { const cover = isObject(item.cover) ? item.cover.id : item.cover; + const trans = item.translations?.[0] ?? { title: '', summary: '' }; return { id: item.id, - title: item.translations?.[0].title, - summary: item.translations?.[0].summary, + title: trans.title, + summary: trans.summary, cover: cover, } satisfies HomepageSolutionView; });