"use strict";(globalThis.webpackChunkadmin=globalThis.webpackChunkadmin||[]).push([[4822],{4822(e,t,s){s.d(t,{MailPoetSettings:()=>d});var i=s(7723),a=s(1455),r=s.n(a),o=s(6087),l=s(6427),n=s(7143),c=s(692),p=s(3084),v=s(790);const d=()=>{const[e,t]=(0,o.useState)(null),[s,a]=(0,o.useState)(""),[d,u]=(0,o.useState)(""),[m,h]=(0,o.useState)(!1),{createSuccessNotice:_,createErrorNotice:k,removeAllNotices:g}=(0,n.useDispatch)(c.store);if((0,o.useEffect)(()=>{r()({path:"/rsvpmaker/v1/rsvp_options"}).then(e=>{const s=e.mailpoet||{};t(s),u(s.selected_list?String(s.selected_list):""),a("")}).catch(e=>{a(e?.message||(0,i.__)("Could not load MailPoet settings.","rsvpmaker"))})},[]),!e)return s?(0,v.jsx)("p",{children:(0,i.__)("Could not load MailPoet settings. Check your permissions and REST API response.","rsvpmaker")}):(0,v.jsx)("p",{children:(0,i.__)("Loading...","rsvpmaker")});if(!e.enabled)return(0,v.jsx)("div",{children:(0,v.jsx)("p",{children:(0,i.__)("MailPoet is not active. Activate MailPoet to enable this integration.","rsvpmaker")})});const S=[{label:(0,i.__)("Choose List","rsvpmaker"),value:""}];return(e.lists||[]).forEach(e=>{S.push({label:e.label,value:String(e.value)})}),(0,v.jsxs)("div",{children:[(0,v.jsx)("p",{children:(0,i.__)('This is optional functionality for using MailPoet with RSVPMaker (Postmark integration is generally recommended instead, and compatibility with current releases of MailPoet is not guaranteed). Select the MailPoet list used for "Add me to your email list" opt-ins.',"rsvpmaker")}),(0,v.jsx)(p.q,{}),(0,v.jsx)(l.SelectControl,{label:(0,i.__)("MailPoet List","rsvpmaker"),value:d,options:S,onChange:u}),(0,v.jsx)(l.Button,{variant:"primary",onClick:async()=>{h(!0),g?.();try{await r()({path:"/rsvpmaker/v1/rsvp_options",method:"POST",data:[{type:"option_raw",key:"rsvpmaker_mailpoet_list",value:parseInt(d,10)||0}]}),_((0,i.__)("MailPoet settings saved.","rsvpmaker"),{isDismissible:!0})}catch(e){k((0,i.__)("Error saving MailPoet settings.","rsvpmaker"),{isDismissible:!0})}finally{h(!1)}},disabled:m,children:m?(0,i.__)("Saving...","rsvpmaker"):(0,i.__)("Save","rsvpmaker")})]})}},3084(e,t,s){s.d(t,{q:()=>l});var i=s(7143),a=s(692),r=s(6427),o=s(790);const l=()=>{const{removeNotice:e}=(0,i.useDispatch)(a.store),t=(0,i.useSelect)(e=>e(a.store).getNotices());return 0===t.length?null:(0,o.jsx)(r.NoticeList,{notices:t,onRemove:e})}}}]);