UNPKG

@shopgate/engage

Version:
4 lines 2.84 kB
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 React,{useMemo,useCallback}from'react';import{css}from'glamor';import{themeConfig}from'@shopgate/engage';import{FormBuilder}from'@shopgate/engage/components';import{StylePresets}from'@shopgate/engage/components/Form';import{ELEMENT_ID_PICKUP_CONTACT}from"../../constants";import generateFormConfig from"./GuestRegistrationFormPickup.config";import Section from"../../../checkout/components/Checkout/CheckoutSection";import{useRegistration}from"../../hooks";var variables=themeConfig.variables;var styles={root:css({display:'flex',flex:'0 0 auto',flexDirection:'column'}).toString(),form:css(_extends({' .guestFormPickupPerson':{marginTop:variables.gap.small},' .guestFormPickupPerson .me':{marginRight:variables.gap.big},' .guestFormPickupPerson .label span':{color:'var(--color-text-high-emphasis)',fontWeight:'bold'},' .guestFormPickupPerson .radioGroup':{marginTop:variables.gap.small,flexDirection:'row',' .uncheckedIcon':{color:'var(--color-text-medium-emphasis)'}}},StylePresets.OUTLINED_FORM_FIELDS)).toString()};/** * PickupContactForm * @returns {JSX} */var GuestRegistrationFormPickup=function GuestRegistrationFormPickup(){var _useRegistration=useRegistration(true),supportedCountries=_useRegistration.supportedCountries,countrySortOrder=_useRegistration.countrySortOrder,userLocation=_useRegistration.userLocation,defaultPickupFormState=_useRegistration.defaultPickupFormState,pickupFormValidationErrors=_useRegistration.pickupFormValidationErrors,updatePickupForm=_useRegistration.updatePickupForm,orderReserveOnly=_useRegistration.orderReserveOnly,isPickupContactSelectionEnabled=_useRegistration.isPickupContactSelectionEnabled;var formConfig=React.useMemo(function(){return generateFormConfig({supportedCountries:supportedCountries,countrySortOrder:countrySortOrder,userLocation:userLocation});},[countrySortOrder,supportedCountries,userLocation]);var handleUpdate=useCallback(function(values){updatePickupForm(values);},[updatePickupForm]);var headline=useMemo(function(){return orderReserveOnly?'checkout.pickup_contact.headline_reserve':'checkout.pickup_contact.headline';},[orderReserveOnly]);if(!isPickupContactSelectionEnabled){return null;}return React.createElement("div",{className:styles.root},React.createElement(Section,{title:headline,hasForm:true,id:ELEMENT_ID_PICKUP_CONTACT},React.createElement(FormBuilder,{className:styles.form,name:"GuestForm",config:formConfig,defaults:defaultPickupFormState,validationErrors:pickupFormValidationErrors,handleUpdate:handleUpdate})));};export default GuestRegistrationFormPickup;