@shopgate/engage
Version:
Shopgate's ENGAGE library.
5 lines • 2.03 kB
JavaScript
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{i18n}from'@shopgate/engage/core';/**
* Generates form configuration.
* @param {Object} params Additional parameters
* @returns {Object}
*/var generateFormConfig=function generateFormConfig(_ref){var supportedCountries=_ref.supportedCountries,countrySortOrder=_ref.countrySortOrder,userLocation=_ref.userLocation,numberOfAddressLines=_ref.numberOfAddressLines;return{fields:_extends({firstName:{type:'text',label:"".concat(i18n.text('checkout.pickup_contact.form.firstName')," *")},lastName:{type:'text',label:"".concat(i18n.text('checkout.pickup_contact.form.lastName')," *")},mobile:{type:'phone_picker',label:"".concat(i18n.text('checkout.pickup_contact.form.mobile')," *"),config:{supportedCountries:supportedCountries,countrySortOrder:countrySortOrder,userLocation:userLocation}},companyName:{type:'text',label:i18n.text('checkout.pickup_contact.form.company')},address1:{type:'text',label:"".concat(i18n.text('checkout.pickup_contact.form.address1')," *")}},numberOfAddressLines>=2?{address2:{type:'text',label:i18n.text('account.profile.form.address2')}}:{},{},numberOfAddressLines>=3?{address3:{type:'text',label:i18n.text('account.profile.form.address3')}}:{},{},numberOfAddressLines>=4?{address4:{type:'text',label:i18n.text('account.profile.form.address4')}}:{},{postalCode:{type:'text',label:"".concat(i18n.text('checkout.pickup_contact.form.postalCode')," *")},city:{type:'text',label:"".concat(i18n.text('checkout.pickup_contact.form.city')," *")},country:{type:'country',label:"".concat(i18n.text('checkout.pickup_contact.form.country')," *"),countries:supportedCountries},region:{type:'province',label:"".concat(i18n.text('checkout.pickup_contact.form.region')," *"),required:true}})};};export default generateFormConfig;