@shopgate/engage
Version:
Shopgate's ENGAGE library.
4 lines • 2.74 kB
JavaScript
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useMemo}from'react';import PropTypes from'prop-types';import startCase from'lodash/startCase';import{i18n}from"../../../core/helpers/i18n";import CheckoutConfirmationSection from"./CheckoutConfirmationSection";/**
* CheckoutConfirmationBilledTo component
* @returns {JSX}
*/var CheckoutConfirmationBilledTo=function CheckoutConfirmationBilledTo(_ref){var order=_ref.order,className=_ref.className;var content=useMemo(function(){var billing=order.addressSequences.find(function(address){return address.type==='billing';});var firstName=billing.firstName,lastName=billing.lastName,address1=billing.address1,city=billing.city,region=billing.region,postalCode=billing.postalCode;var _ref2=order.paymentTransactions||[{}],_ref3=_slicedToArray(_ref2,1),_ref3$=_ref3[0],payment=_ref3$===void 0?{}:_ref3$;var _payment$paymentInfo=payment.paymentInfo,_payment$paymentInfo2=_payment$paymentInfo===void 0?{}:_payment$paymentInfo,_payment$paymentInfo3=_payment$paymentInfo2.card,_payment$paymentInfo4=_payment$paymentInfo3===void 0?{}:_payment$paymentInfo3,type=_payment$paymentInfo4.type,last4=_payment$paymentInfo4.last4,paymentType=_payment$paymentInfo2.type;var hasPayment=order.paymentTransactions&&order.paymentTransactions[0];var address=["".concat(firstName," ").concat(lastName),"".concat(address1||''),"".concat(city?"".concat(city,","):''," ").concat(city&®ion?region:''," ").concat(postalCode||'')].filter(Boolean).join('\n');return[].concat(hasPayment&&paymentType==='cc'?[{label:i18n.text('checkout.success.card_holder'),text:address}]:[{label:i18n.text('checkout.success.address'),text:address}],hasPayment&&paymentType==='cc'?[{label:i18n.text('checkout.success.payment_method'),text:"".concat(startCase(type)," **** **** ").concat(last4)}]:[],hasPayment&&paymentType==='paypal'?[{label:i18n.text('checkout.success.payment_method'),text:'PayPal'}]:[]);},[order]);return React.createElement(CheckoutConfirmationSection,{title:"checkout.success.billed_to",content:content,className:className});};CheckoutConfirmationBilledTo.defaultProps={className:null};export default CheckoutConfirmationBilledTo;