import{aw as S,R as r,j as t,ao as R,l as j,g as E,h as P,i as q,k as v,e9 as N,az as C,ax as F}from"./app-BgLa5dit.js";import{R as k}from"./BOJRju0G.chunk.js";import{E as A}from"./DTaYxhew.chunk.js";import{D}from"./C4BcftDO.chunk.js";import{a as o}from"./CVqrJ8QP.chunk.js";import{O as b}from"./BrvXpjxr.chunk.js";import{a as p}from"./KotJtg73.chunk.js";import"./DkDkjje4.chunk.js";import"./DV8zX5C-.chunk.js";import"./CIRO_mWB.chunk.js";import"./DJ0pq8J_.chunk.js";import"./BUT90D7O.chunk.js";import"./CCcwLDvu.chunk.js";import"./DDfKZ_ng.chunk.js";import"./DNClpFKN.chunk.js";function L(e){var i;const s=S();return r.useEffect(()=>{var n;(n=e.result)!=null&&n.id&&s.setValues({...s.values,uniqueId:e.result.id,externalId:e.query,mappings:void 0})},[(i=e.result)==null?void 0:i.id]),t.jsxs(t.Fragment,{children:[e.result&&t.jsx("div",{className:"mt-4",children:t.jsx(D,{disableCollapse:!0,heading:"School district",children:t.jsx("div",{className:"p-4",children:t.jsx(R.Check,{type:"radio",id:e.result.id,name:e.result.id,label:e.result.name,checked:s.values.uniqueId===e.result.id})})})}),e.query&&!e.result&&t.jsx("p",{className:"text-danger mt-1",children:"Cannot find school district. Please check the ID and try again."})]})}const O="_tenantIdInput_ah295_1",_={tenantIdInput:O};function w(e){switch(e){case o.CLASSLINK:return"Input tenant id";case o.EDLINK:return"Input integration id";case o.CLEVER:return"Input district id"}}function Y(e){const s=j(),[i,n]=r.useState(),[u,m]=r.useState(!1),[d,x]=r.useState(e.queryParams.externalId),[f,h]=r.useState(!1),c=r.useRef(0);e.queryParams.providerId||E.trigger({application:q.CRM_STUDIO,action:P.CrmStudio.ORGANISATION_ROSTERING_WIZARD,args:[e.id]}),r.useEffect(()=>{e.queryParams.externalId&&l(e.queryParams.externalId)},[e.queryParams.externalId]);const g=v();async function l(a){if(!a)return;h(!0),m(!0),n(void 0);const I=++c.current;await g(k.getExternalOrganisation(e.queryParams.providerId,a,y=>{I===c.current&&n(y)},()=>s.error("Unable to find school district, please check the id"),()=>{I===c.current&&m(!1)}))}return t.jsxs(b,{id:e.id,currentStepId:p.SELECT_EXTERNAL,queryParams:e.queryParams,isEdit:!!e.queryParams.integrationId,children:[t.jsx("h2",{className:"h3",children:"Select a school district"}),t.jsx("div",{className:"mt-4 mb-2",children:t.jsx(A,{id:e.queryParams.providerId})}),t.jsx("label",{htmlFor:"tenantId",children:"School district Id"}),t.jsxs("div",{className:"d-flex align-items-center gap-3",children:[t.jsx("input",{autoFocus:!0,className:`${_.tenantIdInput} form-control`,value:d,onChange:a=>{x(a.currentTarget.value),h(!1)},onKeyDown:a=>{a.key==="Enter"&&l(d)},placeholder:w(e.queryParams.providerId)}),t.jsx("button",{className:"btn btn-outline-dark flex-shrink-0",onClick:()=>l(d),disabled:u,children:"Find school district"})]}),u?t.jsx(N,{}):t.jsx(t.Fragment,{children:!!(f||e.queryParams.externalId)&&t.jsx(C,{children:t.jsx(F,{type:"string",name:"externalId",id:"externalId",children:()=>t.jsx(L,{query:d,result:i})})})})]})}export{Y as RosteringWizardSelectExternalView};
//# sourceMappingURL=DLvB_1cg.chunk.js.map
