import{aw as b,j as s,l as P,k as D,dk as F,R as q,h as t,i as o,e9 as A,ek as E,g as p}from"./app-BgLa5dit.js";import{D as h}from"./C4BcftDO.chunk.js";import{u as L}from"./8Im-OACs.chunk.js";import{a as l,C as T}from"./Bl0YdmfD.chunk.js";import{O as M}from"./DNClpFKN.chunk.js";import{S as U}from"./C-49bs9g.chunk.js";import{S as _}from"./DjR16E2i.chunk.js";import{S as k}from"./CIRO_mWB.chunk.js";import{E as W}from"./DTaYxhew.chunk.js";import{O as g,a as j}from"./FnDeqFLV.chunk.js";import{u as z}from"./jfOju8wm.chunk.js";import{O as G}from"./u6fIQ8Ti.chunk.js";import"./g56uS58q.chunk.js";import"./lZO4aq5x.chunk.js";import"./C8_78Eqq.chunk.js";import"./Zwjmkasg.chunk.js";import"./DeKZULrh.chunk.js";import"./itQZri94.chunk.js";import"./wvigAl7i.chunk.js";import"./c3I67AiW.chunk.js";import"./B11DWb8Z.chunk.js";import"./DV8zX5C-.chunk.js";import"./CVqrJ8QP.chunk.js";import"./DJ0pq8J_.chunk.js";import"./CCcwLDvu.chunk.js";import"./DDfKZ_ng.chunk.js";import"./BUT90D7O.chunk.js";function V(r){const n=b();return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"row mt-2 align-items-center",children:[s.jsx("label",{className:"col-4",children:"Provider"}),s.jsx("div",{className:"col-6",children:s.jsx(W,{id:r.idpId})})]}),s.jsxs("div",{className:"row mt-2",children:[s.jsx("label",{className:"col-4",children:"External customer ID"}),s.jsx("span",{className:"col-6",children:n.values.mapTo})]})]})}function fs(r){const n=P(),f=D(),S=F();async function I(i){var x;const C={idpId:i.idpId,externalOrganisationId:i.mapTo};try{await f(G.addIdpMappings(r.id,C)),p.trigger({application:o.CRM_STUDIO,action:t.CrmStudio.ORGANISATION_SSO,args:[r.id]})}catch(R){n.error(((x=R.responseJSON)==null?void 0:x.message)||"Failed to save SSO setup, please try again")}}const c=!!r.queryParams.orgId,{idp:e,certificates:N,isLoading:y}=z({idpId:r.queryParams.idpId,enabled:c});function m(i){return M.getCustomersFromOrganisation(r.queryParams.orgId,i)}function d(i){return S(m(i))}const{items:a,isFetching:u,hasMore:O,nextCursor:v}=L(m,d),w=q.useMemo(()=>[l.name(i=>({application:o.CRM_STUDIO,action:t.CrmStudio.CUSTOMER_SSO_WIZARD_PROVIDER,args:[i],params:{idpId:r.queryParams.idpId,isOrgIdp:!0,type:k.SAML2}}),!0),l.id(),l.status()],[]);return c?y?s.jsx(A,{}):s.jsx(g,{id:r.id,currentStepId:j.REVIEW,queryParams:r.queryParams,onSubmit:async()=>(p.trigger({application:o.CRM_STUDIO,action:t.CrmStudio.ORGANISATION_SSO,args:[r.id]}),Promise.resolve()),children:s.jsxs("div",{className:"crm-studio-wizard-form",children:[s.jsx("h2",{className:"h3 mb-4",children:"Review"}),s.jsxs("p",{className:"alert text-info bg-light-blue",children:[e==null?void 0:e.name," has been created. Bindings must be configured using the customer SSO Wizard."]}),s.jsx(h,{heading:(e==null?void 0:e.name)??"-",className:"overflow-hidden",innerContainerClassName:"border-bottom-0",children:s.jsxs("div",{children:[s.jsx("div",{className:"row px-3 pt-3 mx-0",children:s.jsx("h4",{children:"IDP Details"})}),s.jsx(U,{className:"row mx-3",idp:e}),s.jsxs("div",{className:"row mx-3 my-0 py-3 px-0",children:[s.jsx("span",{className:"col-3 fw-semibold",children:"Entity ID"}),s.jsx("span",{className:"col",children:(e==null?void 0:e.entityId)??"-"})]}),s.jsxs("div",{className:"row mx-3 my-0 py-3 px-0",children:[s.jsx("span",{className:"col-3 fw-semibold",children:"Login URL"}),s.jsx("span",{className:"col",children:(e==null?void 0:e.loginUrl)??"-"})]}),s.jsxs("div",{className:"row mx-3 my-0 py-3 px-0",children:[s.jsx("span",{className:"col-3 fw-semibold",children:"Logout URL"}),s.jsx("span",{className:"col",children:(e==null?void 0:e.logoutUrl)??"-"})]}),s.jsxs("div",{className:"row mx-3 my-0 py-3 px-0",children:[s.jsx("span",{className:"col-3 fw-semibold",children:"Certificate fingerprint"}),s.jsx("div",{className:"col",children:N.map((i=>s.jsxs("div",{className:"col d-flex justify-content-between",children:[s.jsx("span",{children:i.fingerPrint??"-"}),s.jsx(_,{expiryDate:i.validBefore})]})))})]})]})}),s.jsx(h,{heading:"Customers in organisation",disableCollapse:!0,children:s.jsx("div",{children:a!=null&&a.length?s.jsxs(s.Fragment,{children:[s.jsx(T,{data:a,columns:w}),(O||u)&&s.jsx(E,{isFetching:u,fetchNext:d,nextCursor:v,fetchOnScroll:!0})]}):s.jsx("p",{className:"px-3 pt-3",children:"There are currently no customers in this organisation."})})})]})}):s.jsxs(g,{id:r.id,currentStepId:j.REVIEW,queryParams:r.queryParams,onSubmit:I,children:[s.jsx("h2",{className:"h3 mb-4",children:"Review and confirm"}),s.jsx("p",{children:"Please check and confirm all details for organisation SSO setup:"}),s.jsx(V,{idpId:r.queryParams.idpId})]})}export{fs as OrganisationSsoWizardReviewView};
//# sourceMappingURL=BitpGmzz.chunk.js.map
