Add types to Spree taxons mapping

This commit is contained in:
tniezg 2021-08-20 13:19:27 +02:00
parent 3d2ee58c4d
commit eba8c28cc5

View File

@ -111,25 +111,29 @@ export default function getSiteInfoOperation({
}) })
const normalizedCategories: GetSiteInfoOperation['data']['categories'] = const normalizedCategories: GetSiteInfoOperation['data']['categories'] =
spreeCategoriesSuccessResponse.data.sort(taxonsSort).map((spreeTaxon) => { spreeCategoriesSuccessResponse.data
return { .sort(taxonsSort)
id: spreeTaxon.id, .map((spreeTaxon: TaxonAttr) => {
name: spreeTaxon.attributes.name, return {
slug: spreeTaxon.id, id: spreeTaxon.id,
path: spreeTaxon.id, name: spreeTaxon.attributes.name,
} slug: spreeTaxon.id,
}) path: spreeTaxon.id,
}
})
const normalizedBrands: GetSiteInfoOperation['data']['brands'] = const normalizedBrands: GetSiteInfoOperation['data']['brands'] =
spreeBrandsSuccessResponse.data.sort(taxonsSort).map((spreeTaxon) => { spreeBrandsSuccessResponse.data
return { .sort(taxonsSort)
node: { .map((spreeTaxon: TaxonAttr) => {
entityId: spreeTaxon.id, return {
path: `brands/${spreeTaxon.id}`, node: {
name: spreeTaxon.attributes.name, entityId: spreeTaxon.id,
}, path: `brands/${spreeTaxon.id}`,
} name: spreeTaxon.attributes.name,
}) },
}
})
return { return {
categories: normalizedCategories, categories: normalizedCategories,