woocommerce/packages/woocommerce-admin/dist/chunks/payment-recommendations.js

1 line
5.8 KiB
JavaScript
Raw Normal View History

2021-12-10 12:03:04 +00:00
(window.__wcAdmin_webpackJsonp=window.__wcAdmin_webpackJsonp||[]).push([[45],{537:function(e,t,n){"use strict";var c=Object.assign||function(e){for(var t,n=1;n<arguments.length;n++)for(var c in t=arguments[n])Object.prototype.hasOwnProperty.call(t,c)&&(e[c]=t[c]);return e};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t,n=e.size,o=void 0===n?24:n,a=e.onClick,i=(e.icon,e.className),s=function(e,t){var n={};for(var c in e)0<=t.indexOf(c)||Object.prototype.hasOwnProperty.call(e,c)&&(n[c]=e[c]);return n}(e,["size","onClick","icon","className"]),l=["gridicon","gridicons-external",i,(t=o,!(0!=t%18)&&"needs-offset"),!1,!1].filter(Boolean).join(" ");return r.default.createElement("svg",c({className:l,height:o,width:o,onClick:a},s,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"}),r.default.createElement("g",null,r.default.createElement("path",{d:"M19 13v6c0 1.105-.895 2-2 2H5c-1.105 0-2-.895-2-2V7c0-1.105.895-2 2-2h6v2H5v12h12v-6h2zM13 3v2h4.586l-7.793 7.793 1.414 1.414L19 6.414V11h2V3h-8z"})))};var o,a=n(5),r=(o=a)&&o.__esModule?o:{default:o};e.exports=t.default},586:function(e,t,n){},609:function(e,t,n){"use strict";n.r(t),n.d(t,"getPaymentRecommendationData",(function(){return g}));var c=n(0),o=n(2),a=n(7),r=n(28),i=n(3),s=n(21),l=n(20),m=n(11),d=n(16),u=n(537),_=n.n(u),p=n(13),O=(n(586),n(60)),b=n(507),f=n(539);const w="woocommerce_setting_payments_recommendations_hidden";function g(e){const{getOption:t,isResolving:n}=e(m.OPTIONS_STORE_NAME),{getSettings:c}=e(m.SETTINGS_STORE_NAME),{getRecommendedPlugins:o}=e(m.PLUGINS_STORE_NAME),{general:a}=c("general"),r=t(w),i=a&&a.woocommerce_default_country?Object(O.b)(a.woocommerce_default_country):null,s=!!i&&Object(f.c)(i),l=n("getOption",[w]),d=!l&&"yes"!==r&&s;let u=null;d&&(u=o("payments"));return{displayable:d,recommendedPlugins:u,isLoading:l||void 0===r||void 0===a||void 0===u}}const v=document.querySelector('[data-gateway_id="pre_install_woocommerce_payments_promotion"]');t.default=()=>{const[e,t]=Object(c.useState)(null),{updateOptions:n}=Object(a.useDispatch)(m.OPTIONS_STORE_NAME),{installAndActivatePlugins:u}=Object(a.useDispatch)(m.PLUGINS_STORE_NAME),{displayable:O,recommendedPlugins:f,isLoading:j}=Object(a.useSelect)(g),h=Object(c.useRef)(!1),y=O&&f&&f.length>0;if(Object(c.useEffect)(()=>{if((y||v&&!j)&&!h.current){h.current=!0;const e=(f||[]).reduce((e,t)=>t.product?{...e,[t.product.replace(/\-/g,"_")+"_displayed"]:!0}:e,{woocommerce_payments_displayed:!!v});Object(d.recordEvent)("settings_payments_recommendations_pageview",e)}},[y,v,j]),!y)return null;const E=()=>{Object(d.recordEvent)("settings_payments_recommendations_dismiss",{}),n({[w]:"yes"})},N=(f||[]).map(n=>({key:n.slug,title:Object(c.createElement)(c.Fragment,null,n.title,n.recommended&&Object(c.createElement)(s.Pill,null,Object(o.__)("Recommended",'woocommerce'))),content:Object(r.decodeEntities)(n.copy),after:Object(c.createElement)(i.Button,{isSecondary:!0,onClick:()=>(n=>{e||(t(n.product),Object(d.recordEvent)("settings_payments_recommendations_setup",{extension_selected:n.product}),u([n.product]).then(()=>{window.location.href=Object(p.e)(n["setup-link"].replace("/wp-admin/",""))}).catch(e=>{Object(b.a)(e),t(null)}))})(n),isBusy:e===n.product,disabled:!!e},n["button-text"]),before:Object(c.createElement)("img",{src:n.icon,alt:""})}));return Object(c.createElement)(i.Card,{size:"medium",className:"woocommerce-recommended-payments-card"},Object(c.createElement)(i.CardHeader,null,Object(c.createElement)("div",{className:"woocommerce-recommended-payments-card__header"},Object(c.createElement)(l.Text,{variant:"title.small",as:"p",size:"20",lineHeight:"28px"},Object(o.__)("Recommended ways to get paid",'woocommerce')),Object(c.createElement)(l.Text,{className:"woocommerce-recommended-payments__header-heading",variant:"caption",as:"p",size:"12",lineHeight:"16px"},Object(o.__)('We recommend adding one of the following payment extensions to your store. The extension will be installed and activated for you when you click "Get started".','woocommerce'))),Object(c.createElement)("