Refactor Sales page structure
Currently, we are destructuring the Sales data from the API like so via a service function:
const data = items[0].fields.pageContent;
const metadata = items[0].fields.seoMetadata[0].fields;
const sales = { ...metadata };
const [hero, form, supportCard, carousel, ...FAQ] = data;
The Sales page entry has the FAQ accordion sections sort of ‘free floating’ in the page body content. We should put these in a parent block of some kind. The spread operator above assumes anything that is not hero, form, supportCard, and carousel are FAQ accordions. This is easy to break - if anyone adds an additional entry to the page, the code will think that it is an FAQ accordion and the code will break.
Refactor this page so that:
- The FAQ accordion entries are in a block container content entry
- The code handles this Contentful entry structure change
- Move the Sales service business logic to a separate service file which is consistent with the structure of our other pages
Success means that someone can add some kind of additional entry to the page (either on purpose or accident) and the page / CICD pipelines do not break. The entry simply will not render on the page because we do not have code in place to render the data.