Skip to content

Commit

Permalink
fix schema enhancer
Browse files Browse the repository at this point in the history
  • Loading branch information
ionlizarazu committed Oct 12, 2022
1 parent 5b535e7 commit 691554e
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/advancedSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,35 @@ import messages from './messages';

export const advancedSchema = (props) => {
const { intl, schema, formData } = props;
const imageWidth = ['right', 'left'].includes(formData.imageSide)
const imageWidth = ['right', 'left'].includes(formData?.imageSide)
? ['imageWidth']
: [];
const headingChoices = [
['h2', 'H2'],
['h3', 'H3'],
['h4', 'H4'],
];
let heading =
formData && formData['@type'] === 'listing'
? [
{
id: 'header',
title: intl.formatMessage(messages.headerConfiguration),
fields: ['header', 'headerUrl', 'headerTag'],
},
]
: [];

return {
...schema,
fieldsets: [
{
id: 'default',
title: 'Default',
fields: ['variation'],
},
{
id: 'querystring',
title: intl.formatMessage(messages.querystring),
fields: ['querystring'],
},
{
id: 'header',
title: intl.formatMessage(messages.headerConfiguration),
fields: ['header', 'headerUrl', 'headerTag'],
},
...(schema.fieldsets &&
schema.fieldsets.length > 0 &&
schema.fieldsets.filter((fieldset) => fieldset.id === 'default')),
...(schema.fieldsets &&
schema.fieldsets.length > 0 &&
schema.fieldsets.filter((fieldset) => fieldset.id === 'searchquery')),
...heading,
{
id: 'columns',
title: intl.formatMessage(messages.columnsConfiguration),
Expand Down

0 comments on commit 691554e

Please sign in to comment.