File "settings-payments-methods.js"

Full Path: /home/amervokv/ecomlive.net/wp-content/plugins/woocommerce/assets/client/admin/chunks/settings-payments-methods.js
File size: 3.66 KB
MIME-type: text/plain
Charset: utf-8

"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[1402],{89543:(e,t,s)=>{s.r(t),s.d(t,{SettingsPaymentsMethods:()=>x,default:()=>g});var i=s(67221),o=s(69307),c=s(9818),l=s(65736),a=s(55609),n=s(44443),m=s(4622),r=s(22629),d=s(9845),_=s(81514);const h=({method:e,paymentMethodsState:t,setPaymentMethodsState:s,isExpanded:i,...o})=>{var c,l,n;return e.enabled||i?(0,_.jsx)("div",{id:e.id,className:"woocommerce-list__item woocommerce-list__item-enter-done",...o,children:(0,_.jsxs)("div",{className:"woocommerce-list__item-inner",children:["apple_google"!==e.id&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"woocommerce-list__item-before",children:(0,_.jsx)("img",{src:e.icon,alt:e.title+" logo"})}),(0,_.jsxs)("div",{className:"woocommerce-list__item-text",children:[(0,_.jsx)("span",{className:"woocommerce-list__item-title",children:e.title}),(0,_.jsx)("span",{className:"woocommerce-list__item-content",dangerouslySetInnerHTML:(0,d.ZP)((0,r.decodeEntities)(e.description))})]})]}),"apple_google"===e.id&&(0,_.jsxs)("div",{className:"woocommerce-list__item-multi",children:[(0,_.jsxs)("div",{className:"woocommerce-list__item-multi-row multi-row-space",children:[(0,_.jsx)("div",{className:"woocommerce-list__item-before",children:(0,_.jsx)("img",{src:e.icon,alt:e.title+" logo"})}),(0,_.jsxs)("div",{className:"woocommerce-list__item-text",children:[(0,_.jsx)("span",{className:"woocommerce-list__item-title",children:e.title}),(0,_.jsx)("span",{className:"woocommerce-list__item-content",dangerouslySetInnerHTML:(0,d.ZP)((0,r.decodeEntities)(e.description))})]})]}),(0,_.jsxs)("div",{className:"woocommerce-list__item-multi-row",children:[(0,_.jsx)("div",{className:"woocommerce-list__item-before",children:(0,_.jsx)("img",{src:e.extraIcon,alt:e.extraTitle+" logo"})}),(0,_.jsxs)("div",{className:"woocommerce-list__item-text",children:[(0,_.jsx)("span",{className:"woocommerce-list__item-title",children:e.extraTitle}),(0,_.jsx)("span",{className:"woocommerce-list__item-content",dangerouslySetInnerHTML:(0,d.ZP)((0,r.decodeEntities)(null!==(c=e.extraDescription)&&void 0!==c?c:""))})]})]})]}),(0,_.jsx)("div",{className:"woocommerce-list__item-after",children:(0,_.jsx)("div",{className:"woocommerce-list__item-after__actions wc-settings-prevent-change-event",children:(0,_.jsx)(a.ToggleControl,{checked:null!==(l=t[e.id])&&void 0!==l&&l,onChange:i=>{s({...t,[e.id]:i})},disabled:null!==(n=e.required)&&void 0!==n&&n,label:""})})})]})}):null},p=e=>{const t=(0,n.ZA)("apple_pay")(e),s=(0,n.ZA)("google_pay")(e);return t&&s?e.map((e=>"apple_pay"===e.id?{...e,id:"apple_google",extraTitle:s.title,extraDescription:s.description,extraIcon:s.icon}:"google_pay"===e.id?null:e)).filter((e=>null!==e)):e},x=({paymentMethodsState:e,setPaymentMethodsState:t})=>{var s;const[r,d]=(0,o.useState)(!1),{paymentMethods:x,isFetching:g}=(0,c.useSelect)((e=>{const t=e(i.PAYMENT_SETTINGS_STORE_NAME),s=t.getPaymentProviders()||[],o=(0,n.V3)(s);return{isFetching:t.isFetching(),paymentMethods:p(o)}}),[]),w=x.reduce(((e,{id:t,enabled:s})=>(e[t]=s,e)),{});return(0,o.useEffect)((()=>{null===w||g||t(w)}),[g]),(0,_.jsx)("div",{className:"settings-payments-methods__container",children:g?(0,_.jsx)(m.a,{rows:3,hasDragIcon:!1}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"woocommerce-list",children:x.map((s=>(0,_.jsx)(h,{method:s,paymentMethodsState:e,setPaymentMethodsState:t,isExpanded:r},s.id)))}),!r&&(0,_.jsx)(a.Button,{className:"settings-payments-methods__show-more",onClick:()=>{d(!r)},tabIndex:0,"aria-expanded":r,children:(0,l.sprintf)((0,l.__)("Show more (%s)","woocommerce"),null!==(s=x.filter((e=>!1===e.enabled)).length)&&void 0!==s?s:0)})]})})},g=x}}]);