import{k as f,l as h,R as S,o as D,j as i,G as y}from"./app-BgLa5dit.js";import{D as x,a as O,b as j}from"./C3CE5EQd.chunk.js";import{O as o}from"./DNClpFKN.chunk.js";import{C}from"./BPRDISw7.chunk.js";import{C as v,a as w}from"./8iu0vnCW.chunk.js";import"./C4BcftDO.chunk.js";import"./3nM7jLnE.chunk.js";import"./CPXlV0fg.chunk.js";import"./ChrB5FYK.chunk.js";import"./DR2FaZH9.chunk.js";import"./KUnagq9Z.chunk.js";import"./DULWIWQR.chunk.js";import"./CCcwLDvu.chunk.js";import"./DDfKZ_ng.chunk.js";function T(a){var m;const n=f(),e=h(),[c,r]=S.useState(!1),s=D(o.getOrganisationDomains(a.id)),u=!s.hasCompleted;async function p(t){try{r(!0);const{additions:d,deletions:l}=j.getDomainChanges(s.data,t.domains);d.length>0&&await n(o.createOrganisationDomains(a.id,d)),l.length>0&&await Promise.all(l.map(g=>n(o.deleteOrganisationDomain(g.id,a.id)))),e.success("Domains updated successfully")}catch{e.error("Failed to update domains, please try again")}finally{r(!1)}}return i.jsx(v,{view:w.Organisations,children:i.jsx(C,{title:"Domains",currentTabId:"domains",id:a.id,loading:u,children:i.jsxs("div",{children:[i.jsx("p",{children:"Add domains for SSO login"}),i.jsx(y,{initialValues:{domains:(m=s.data)==null?void 0:m.map(t=>t.domain)},validationSchema:x,onSubmit:null,children:i.jsx(O,{isSaving:c,onSave:p})})]})})})}export{T as OrganisationDomainsView};
//# sourceMappingURL=CUlx1W-G.chunk.js.map
