UNPKG

@shopgate/engage

Version:
8 lines 1.72 kB
import{i18n}from'@shopgate/engage/core/helpers';var pickupFieldActions=[{type:'setVisibility',rules:[{context:'pickupPerson',type:'oneOf',data:['someoneElse']}]}];/** * Generates form configuration. * @param {Object} options Options for the helper * @param {Array} options.supportedCountries A list of supported countries. * @param {Array} options.countrySortOrder Sort order for supported countries. * @param {Object} options.userLocation User location for better phone picker defaults. * @returns {Object} */var generateFormConfig=function generateFormConfig(_ref){var supportedCountries=_ref.supportedCountries,countrySortOrder=_ref.countrySortOrder,userLocation=_ref.userLocation;return{fields:{instructions:{type:'text',label:i18n.text('checkout.pickup_contact.form.instructions')},pickupPerson:{type:'radio',label:i18n.text('checkout.pickup_contact.form.who_will_pickup'),options:{me:i18n.text('checkout.pickup_contact.form.me'),someoneElse:i18n.text('checkout.pickup_contact.form.someone_else')}},firstName:{type:'text',actions:pickupFieldActions,label:"".concat(i18n.text('checkout.pickup_contact.form.firstName')," *"),required:true},lastName:{type:'text',actions:pickupFieldActions,label:"".concat(i18n.text('checkout.pickup_contact.form.lastName')," *"),required:true},emailAddress:{type:'email',actions:pickupFieldActions,label:"".concat(i18n.text('checkout.pickup_contact.form.emailAddress')," *"),required:true},mobile:{type:'phone_picker',label:"".concat(i18n.text('checkout.pickup_contact.form.mobile')," *"),required:true,actions:pickupFieldActions,config:{supportedCountries:supportedCountries,countrySortOrder:countrySortOrder,userLocation:userLocation}}}};};export default generateFormConfig;