UNPKG

@shopgate/engage

Version:
4 lines 1.51 kB
function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React from'react';import PropTypes from'prop-types';import classNames from'classnames';import{css}from'glamor';import{errorBehavior}from'@shopgate/engage/core';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var variables=themeConfig.variables;var styles={wrapper:css({paddingTop:variables.gap.xsmall}).toString(),message:css({fontSize:' 0.75rem'}).toString(),error:css({color:'var(--color-state-alert)'}).toString(),warning:css({color:'var(--color-state-warning)'}).toString(),info:css({color:'var(--color-state-ok)'}).toString()};/** * @param {Object} props The component props * @returns {JSX} */var CheckoutSectionMessages=function CheckoutSectionMessages(_ref){var messages=_ref.messages;if(!Array.isArray(messages)||messages.length===0){return null;}return React.createElement("ul",{className:styles.wrapper},messages.map(function(_ref2){var message=_ref2.message,additionalParams=_ref2.additionalParams,type=_ref2.type;return React.createElement("li",{key:message,className:classNames(styles.message,_defineProperty(_defineProperty(_defineProperty({},styles.error,type==='error'),styles.warning,type==='warning'),styles.info,type==='info'))},errorBehavior.getErrorMessage(message,additionalParams));}));};CheckoutSectionMessages.defaultProps={messages:null};export default CheckoutSectionMessages;