UNPKG

@shopgate/pwa-common-commerce

Version:

Commerce library for the Shopgate Connect PWA.

5 lines 851 B
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{OPTION_TYPE_TEXT}from"../../constants";/** * Formats the options from the API to a format our frontend needs. * @param {Object} options Product options * @return {Array} The formatted options */var formatOptions=function formatOptions(options){return options.map(function(option){return _extends({},option,{},option.values&&{values:option.values.map(function(value){return _extends({},value,{unitPriceModifier:value.unitPriceModifier||0});})},{},option.type===OPTION_TYPE_TEXT&&{unitPriceModifier:option.unitPriceModifier||0});});};export default formatOptions;