"use strict";(globalThis.webpackChunkadmin=globalThis.webpackChunkadmin||[]).push([[729],{729(e,s,a){a.d(s,{EditingRightsSettings:()=>v});var t=a(7723),r=a(1455),i=a.n(r),n=a(6087),l=a(6427),o=a(7143),c=a(692),d=a(3084),p=a(790);const v=()=>{const[e,s]=(0,n.useState)([]),[a,r]=(0,n.useState)(!0),[v,u]=(0,n.useState)(""),[h,m]=(0,n.useState)(!1),{createSuccessNotice:g,createErrorNotice:_,removeAllNotices:k}=(0,o.useDispatch)(c.store);return(0,n.useEffect)(()=>{i()({path:"/rsvpmaker/v1/rsvp_options"}).then(e=>{s(e.email_role_caps||[]),u("")}).catch(e=>{u(e?.message||(0,t.__)("Could not load editing/sending rights.","rsvpmaker"))}).finally(()=>{r(!1)})},[]),a?(0,p.jsx)("p",{children:(0,t.__)("Loading...","rsvpmaker")}):v?(0,p.jsx)("p",{children:(0,t.__)("Could not load editing/sending rights. Check your permissions and REST API response.","rsvpmaker")}):(0,p.jsxs)("div",{children:[(0,p.jsx)("p",{children:(0,t.__)("Control which roles can edit drafts or publish/send RSVP Email broadcasts.","rsvpmaker")}),(0,p.jsx)(d.q,{}),e.map(e=>(0,p.jsx)(l.SelectControl,{label:e.name,value:e.level||"none",onChange:a=>{return t=e.slug,r=a,void s(e=>e.map(e=>e.slug===t?{...e,level:r}:e));var t,r},options:[{label:(0,t.__)("No Broadcast Rights","rsvpmaker"),value:"none"},{label:(0,t.__)("Edit Draft Emails","rsvpmaker"),value:"edit"},{label:(0,t.__)("Publish and Send Broadcasts","rsvpmaker"),value:"publish"}]},e.slug)),(0,p.jsx)(l.Button,{variant:"primary",onClick:async()=>{m(!0),k?.();const s={};e.forEach(e=>{s[e.slug]=e.level||"none"});try{await i()({path:"/rsvpmaker/v1/rsvp_options",method:"POST",data:[{type:"email_cap_update",value:s}]}),g((0,t.__)("Editing/Sending rights saved.","rsvpmaker"),{isDismissible:!0})}catch(e){_((0,t.__)("Error saving editing/sending rights.","rsvpmaker"),{isDismissible:!0})}finally{m(!1)}},disabled:h,children:h?(0,t.__)("Saving...","rsvpmaker"):(0,t.__)("Save","rsvpmaker")})]})}},3084(e,s,a){a.d(s,{q:()=>l});var t=a(7143),r=a(692),i=a(6427),n=a(790);const l=()=>{const{removeNotice:e}=(0,t.useDispatch)(r.store),s=(0,t.useSelect)(e=>e(r.store).getNotices());return 0===s.length?null:(0,n.jsx)(i.NoticeList,{notices:s,onRemove:e})}}}]);