import{k as g,l as h,R as S,o as y,j as i,G as x}from"./app-BgLa5dit.js";import{b as s,D as j,a as v}from"./C3CE5EQd.chunk.js";import{C as w}from"./C2cKa2R1.chunk.js";import{C as F,a as A}from"./8iu0vnCW.chunk.js";import{C as m}from"./q-IBKcuF.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";import"./DUpYPoLs.chunk.js";import"./EZim8aq-.chunk.js";import"./BD9MrUJP.chunk.js";import"./s6cGcwlA.chunk.js";import"./Zwjmkasg.chunk.js";import"./4qGb1BIY.chunk.js";import"./DnXDEnAR.chunk.js";import"./DpUpv6rY.chunk.js";import"./CG7zbly5.chunk.js";import"./m4aqaK_l.chunk.js";import"./MEkA24R1.chunk.js";import"./C53kfXmd.chunk.js";function $(t){const e=g(),r=h(),[u,n]=S.useState(!1),a=y(m.getCustomerDomains(t.id)),d=s.filterCustomerDomains(a.data),p=s.filterOrganisationDomains(a.data),f=!a.hasCompleted;async function C(o){try{n(!0);const{additions:l,deletions:c}=s.getDomainChanges(d,o.domains);l.length>0&&await e(m.createCustomerDomains(t.id,l)),c.length>0&&await Promise.all(c.map(D=>e(m.deleteCustomerDomain(D.id,t.id)))),r.success("Domains updated successfully")}catch{r.error("Failed to update domains, please try again")}finally{n(!1)}}return i.jsx(F,{view:A.Customers,children:i.jsx(w,{title:"Domains",currentTabId:"domains",id:t.id,loading:f,children:i.jsxs("div",{children:[i.jsx("p",{children:"Add domains for SSO login"}),i.jsx(x,{initialValues:{domains:d.map(o=>o.domain)},validationSchema:j,onSubmit:null,children:i.jsx(v,{isSaving:u,onSave:C,organisationDomains:p.map(o=>o.domain)})})]})})})}export{$ as CustomerDomainsView};
//# sourceMappingURL=CgUuko9U.chunk.js.map
