Android_Retail/src/Pages/BookingScreen/Template/DynamicComponentProps.js

47 lines
1.3 KiB
JavaScript

function dynamicComponentProps(sessionName, data, componentName) {
let defaultOptions =
sessionName == 'Category'
? {
Image: false,
Background: false,
TextCapitalize: false,
ImageRight: false,
EdgeCurve: componentName == 'Category2' ? true : false,
BigCard: componentName == 'Category4' ? true : false,
}
: sessionName == 'SubCategory'
? {
Background: false,
TextCapitalize: false,
EdgeCurve: componentName == 'SubCategory2' ? true : false,
}
: {
TextCapitalize: false,
Background: false,
StockCount: false,
Price: false,
EdgeCurve: false,
SmallImage: false,
ImageLeft: false,
ImageRight: false,
ImageUp: false,
ImageDown: false,
BigImage: false,
};
let output = {};
data?.forEach((option) => {
let optionName = option.OptionName;
if (defaultOptions.hasOwnProperty(optionName)) {
output[optionName] = true;
}
});
// Merge with the default options to set the missing ones to false
let finalOutput = { ...defaultOptions, ...output };
return finalOutput;
}
export { dynamicComponentProps };