import{ao as a,bN as v,L as P,az as d,aj as b,b0 as x,bc as D,aI as j,aZ as V,aq as q,ck as y,aR as L}from"./app-k0jcl5PQ.js";import{D as R,a as l,b as c,c as O,A as w}from"./CYEQuXGH.chunk.js";import{A as E,D as I,a as p}from"./C9m3Saer.chunk.js";import{F as C}from"./C3DvQ1wU.chunk.js";import{S as N}from"./EHuWazu9.chunk.js";import{u as B}from"./Xv5EXWiN.chunk.js";import"./CK1wYtr2.chunk.js";import"./kLXBNYk1.chunk.js";import"./DwDhXSrj.chunk.js";import"./CCtuxSlD.chunk.js";import"./CPXlV0fg.chunk.js";import"./ApI7cEru.chunk.js";import"./DXxHdeNz.chunk.js";import"./CpGXOT1_.chunk.js";import"./DkDkjje4.chunk.js";import"./hKqzfsO4.chunk.js";import"./fstW5ZQE.chunk.js";import"./9ls1F1Ve.chunk.js";import"./DRKUY7jf.chunk.js";function J(s){return a.jsx(R,{view:E.AutomaticAccess,options:["none","allowed"],errors:s.errors,appLinks:s.appLinks,classname:s.classname,onSelectValue:t=>s.formikProps.setFieldValue("automaticAccess.selectedOption",t),addDomainField:()=>s.formikProps.setFieldValue("automaticAccess.domains",[...s.formikProps.values.automaticAccess.domains,{domain:""}]),onChangeDomain:(t,e)=>s.formikProps.setFieldValue(`automaticAccess.domains[${e}]`,t),removeDomainField:t=>{const e=s.formikProps.values.automaticAccess.domains;e.length>1?(s.formikProps.setFieldValue("automaticAccess.domains",e.filter((n,o)=>o!==t)),s.formikProps.setFieldError("automaticAccess.domains",void 0)):(s.formikProps.setFieldValue("automaticAccess.domains[0]",{domain:""}),s.formikProps.setFieldError("automaticAccess.domains[0]",void 0))},setFieldError:(t,e)=>s.formikProps.setFieldError(t,e),selectedOption:s.formikProps.values.automaticAccess.selectedOption,domains:s.formikProps.values.automaticAccess.domains})}const A="settings.automaticAccess",r=P.encloseNamespace(A);function os(){B(),v({title:r("pageTitle")});const s=d(b.currentUser()),{customerId:t}=s.data,e=d(s.data.customerId&&l.domains(t)),n=x(),o=D(),[f,g]=j.useState([]);async function h(i,S){var m;const k=c.formatRequestData(e.data,i.automaticAccess,w.AutoJoin);try{await n(l.updateDomains(t,k)),o.success(r("success"))}catch(u){(m=u.responseJSON)!=null&&m.problems&&g(u.responseJSON.problems),o.error(r("error"))}finally{S()}}if(!e.hasCompleted)return a.jsx(a.Fragment,{});const F={requestingAccess:c.getInitialJoinRequests(e.data),teacherInvites:!1,automaticAccess:c.getInitialAccessBehaviour(e.data)};return a.jsxs(N,{heading:r("heading"),breadcrumbs:[r("breadcrumb")],requiredPermissions:V.ManageUsers,children:[a.jsx(I,{active:"automatic-access",appLinks:p}),a.jsx("p",{children:a.jsx(q,{namespace:A,phrase:"description"})}),a.jsx(C,{initialValues:F,onSubmit:h,validate:i=>O({values:i,alerts:o,setShowPopup:()=>{}}),validateOnChange:!1,validateOnBlur:!1,children:i=>a.jsxs(y,{children:[a.jsx(J,{formikProps:i,errors:f,appLinks:p}),a.jsx(L,{variant:"dark",disabled:!i.dirty,onClick:()=>i.submitForm(),children:"Save changes"})]})})]})}export{os as AutomaticAccessView};
//# sourceMappingURL=BqbreFzI.chunk.js.map
