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