STEP-8 Query Field and FieldList
In this step, we going to modify our query to fetch all config data to the frontend
Last updated
Was this helpful?
In this step, we going to modify our query to fetch all config data to the frontend
Last updated
Was this helpful?
Modify SocialShare.query.js add 2 new field and fieldList to them
import { Field } from 'Util/Query';
/** @namespace ScandipwaSocialshare/Query/SocialShare/Query/SocialShareQuery */
export class SocialShareQuery {
getQuery() {
return new Field('socialShare')
.addField(this.getConfigField())
.addField(this.getProviderField());
}
getConfigField() {
return new Field('socialShareConfig')
.addFieldList(this.getConfigFields());
}
getConfigFields() {
return [
'enabled',
'rounded',
'size',
'categoryPage',
'productPage',
'homePage'
];
}
getProviderField() {
return new Field('providers')
.addFieldList(this.getProviderFields());
}
getProviderFields() {
return [
'id',
'counter',
'additional'
];
}
}
export default new SocialShareQuery();
2. now we need to modify the reducer initial state with minimal required data
export const getInitialState = () => ({
socialShare: {
socialShareConfig: {
enabled: false,
categoryPage: false,
productPage: false,
homePage: false
},
providers: []
}
});
3. let’s check using Redux DevTools if data is fetched