import{ao as s,bN as v,L as x,az as d,aj as R,b0 as b,bc as j,aI as D,aq as p,ba as P,f as E,e as L,ck as y,aR as V}from"./app-k0jcl5PQ.js";import{D as C,a as g,b as o,c as O,A as w}from"./CYEQuXGH.chunk.js";import{A as I,D as N,a as A}from"./C9m3Saer.chunk.js";import{F as U}from"./C3DvQ1wU.chunk.js";import{S as T}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 G(e){return s.jsx(C,{view:I.RequestingAccess,options:["none","allowed","any"],errors:e.errors,appLinks:e.appLinks,classname:e.classname,onSelectValue:t=>e.formikProps.setFieldValue("requestingAccess.selectedOption",t),addDomainField:()=>e.formikProps.setFieldValue("requestingAccess.domains",[...e.formikProps.values.requestingAccess.domains,{domain:""}]),onChangeDomain:(t,a)=>e.formikProps.setFieldValue(`requestingAccess.domains[${a}]`,t),removeDomainField:t=>{const a=e.formikProps.values.requestingAccess.domains;a.length>1?(e.formikProps.setFieldValue("requestingAccess.domains",a.filter((m,r)=>r!==t)),e.formikProps.setFieldError("requestingAccess.domains",void 0)):(e.formikProps.setFieldValue("requestingAccess.domains[0]",{domain:""}),e.formikProps.setFieldError("requestingAccess.domains[0]",void 0))},setFieldError:(t,a)=>e.formikProps.setFieldError(t,a),selectedOption:e.formikProps.values.requestingAccess.selectedOption,domains:e.formikProps.values.requestingAccess.domains})}const c="settings.requestingAccess",n=x.encloseNamespace(c);function oe(){B(),v({title:n("pageTitle")});const e=d(R.currentUser()),{customerId:t}=e.data,a=d(e.data.customerId&&g.domains(t)),m=b(),r=j(),[f,h]=D.useState([]);async function q(i,F){var u;const k=o.formatRequestData(a.data,i.requestingAccess,w.Request);try{await m(g.updateDomains(t,k)),r.success(n("success"))}catch(l){(u=l.responseJSON)!=null&&u.problems&&h(l.responseJSON.problems),r.error(n("error"))}finally{F()}}if(!a.hasCompleted)return s.jsx(s.Fragment,{});const S={requestingAccess:o.getInitialJoinRequests(a.data),teacherInvites:!1,automaticAccess:o.getInitialAccessBehaviour(a.data)};return s.jsxs(T,{heading:n("heading"),breadcrumbs:[n("breadcrumb")],children:[s.jsx(N,{active:"requesting-access",appLinks:A}),s.jsxs("p",{children:[s.jsx(p,{namespace:c,phrase:"description"})," ",s.jsx(P,{appLink:{application:L.USER_MANAGER,action:E.UserManager.ACCESS_REQUESTS},className:"text-info",children:s.jsx(p,{namespace:c,phrase:"manageRequests"})})]}),s.jsx(U,{initialValues:S,onSubmit:q,validate:i=>O({values:i,alerts:r,setShowPopup:()=>{}}),validateOnChange:!1,validateOnBlur:!1,children:i=>s.jsxs(y,{children:[s.jsx(G,{formikProps:i,errors:f,appLinks:A}),s.jsx(V,{variant:"dark",disabled:!i.dirty,onClick:()=>i.submitForm(),children:"Save changes"})]})})]})}export{oe as RequestingAccessView};
//# sourceMappingURL=D5ii5gOa.chunk.js.map
