JezK
Edit File: settings-payments-cheque.js
"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[6620],{15322:(e,t,s)=>{s.d(t,{W:()=>n});var i=s(56427),o=s(39793);const n=({size:e="medium"})=>(0,o.jsx)("div",{className:`woocommerce-field-placeholder woocommerce-field-placeholder--${e}`,children:(0,o.jsx)(i.Placeholder,{})})},19796:(e,t,s)=>{s.d(t,{w:()=>a});var i=s(56427),o=s(51609),n=s(39793);const a=({children:e})=>(0,n.jsx)(n.Fragment,{children:e});a.Layout=({children:e})=>((0,o.useEffect)(()=>{const e=document.getElementById("wpbody");e&&e.querySelector(".settings-layout")&&e.classList.add("has-settings-layout")},[]),(0,n.jsx)("div",{className:"settings-layout",children:e})),a.Section=({title:e,description:t,children:s,id:i})=>(0,n.jsxs)("div",{className:"settings-section",id:i,children:[(0,n.jsxs)("div",{className:"settings-section__details",children:[(0,n.jsx)("h2",{children:e}),(0,n.jsx)("p",{children:t})]}),(0,n.jsx)("div",{className:"settings-section__controls",children:s})]}),a.Actions=({children:e})=>(0,n.jsx)(i.Card,{className:"settings-card__wrapper ",children:(0,n.jsx)(i.CardBody,{className:"form__actions",children:e})}),a.Form=({children:e,onSubmit:t})=>(0,n.jsx)("form",{onSubmit:t,className:"settings-form",children:e})},50332:(e,t,s)=>{s.d(t,{C0:()=>n,lV:()=>c,mF:()=>a});var i=s(56427),o=s(39793);const n=({data:e,field:t,onChange:s})=>(0,o.jsx)(i.CheckboxControl,{label:t.label,help:t.description,checked:Boolean(t.getValue({item:e})),onChange:e=>s({[t.id]:e})}),a=({data:e,field:t,onChange:s})=>(0,o.jsx)(i.TextControl,{label:t.label,help:t.description,placeholder:t.placeholder,value:String(t.getValue({item:e})??""),onChange:e=>s({[t.id]:e})}),c=({data:e,field:t,onChange:s})=>(0,o.jsx)(i.TextareaControl,{label:t.label,help:t.description,value:String(t.getValue({item:e})??""),onChange:e=>s({[t.id]:e})})},78014:(e,t,s)=>{s.r(t),s.d(t,{SettingsPaymentsCheque:()=>u,default:()=>p});var i=s(56427),o=s(27723),n=s(47143),a=s(40314),c=s(86087),l=s(50860),r=s(19796),d=s(15322),m=s(50332),h=s(39793);const u=()=>{const{createSuccessNotice:e,createErrorNotice:t}=(0,n.useDispatch)("core/notices"),{chequeSettings:s,isLoading:u}=(0,n.useSelect)(e=>({chequeSettings:e(a.paymentGatewaysStore).getPaymentGateway("cheque"),isLoading:!e(a.paymentGatewaysStore).hasFinishedResolution("getPaymentGateway",["cheque"])}),[]),{updatePaymentGateway:p,invalidateResolutionForStoreSelector:g}=(0,n.useDispatch)(a.paymentGatewaysStore),{invalidateResolution:y,invalidateResolutionForStoreSelector:w}=(0,n.useDispatch)(a.paymentSettingsStore),[_,b]=(0,c.useState)({}),[x,S]=(0,c.useState)(!1),[j,f]=(0,c.useState)(!1);(0,c.useEffect)(()=>{s&&b({enabled:s.enabled,title:s.settings.title.value,description:s.description,instructions:s.settings.instructions.value})},[s]);const v=(0,c.useMemo)(()=>[{id:"enabled",label:(0,o.__)("Enable check payments","woocommerce"),Edit:m.C0},{id:"title",label:(0,o.__)("Title","woocommerce"),description:(0,o.__)("Payment method name that the customer will see during checkout.","woocommerce"),placeholder:(0,o.__)("Check payments","woocommerce"),Edit:m.mF},{id:"description",label:(0,o.__)("Description","woocommerce"),description:(0,o.__)("Payment method description that the customer will see during checkout.","woocommerce"),Edit:m.lV},{id:"instructions",label:(0,o.__)("Instructions","woocommerce"),description:(0,o.__)("Instructions that will be added to the thank you page and emails.","woocommerce"),Edit:m.lV}],[]);return(0,h.jsx)(r.w,{children:(0,h.jsx)(r.w.Layout,{children:(0,h.jsxs)(r.w.Form,{onSubmit:i=>{i.preventDefault(),(()=>{if(!s)return;S(!0);const i={title:String(_.title),instructions:String(_.instructions)};p("cheque",{enabled:Boolean(_.enabled),description:String(_.description),settings:i}).then(()=>{f(!1),g("getPaymentGateway"),e((0,o.__)("Settings updated successfully","woocommerce"))}).catch(()=>{t((0,o.__)("Failed to update settings","woocommerce"))}).finally(()=>{S(!1),y("getPaymentProviders",[]),w("getOfflinePaymentGateways")})})()},children:[(0,h.jsx)(r.w.Section,{title:(0,o.__)("Enable and customise","woocommerce"),description:(0,o.__)("Choose how you want to present check payments to your customers during checkout.","woocommerce"),children:u?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(d.W,{size:"small"}),(0,h.jsx)(d.W,{size:"medium"}),(0,h.jsx)(d.W,{size:"large"}),(0,h.jsx)(d.W,{size:"large"})]}):(0,h.jsx)(l.A,{data:_,fields:v,form:{layout:{type:"regular"},fields:["enabled","title","description","instructions"]},onChange:e=>{b(t=>({...t,...e})),f(!0)}})}),(0,h.jsx)(r.w.Actions,{children:(0,h.jsx)(i.Button,{variant:"primary",type:"submit",isBusy:x,disabled:x||!j,children:(0,o.__)("Save changes","woocommerce")})})]})})})},p=u}}]);