import{aI as T,az as i,aj as C,bu as k,c4 as N,bc as L,aX as v,ao as s,aF as w,L as I,aP as u,Y as D,aq as h,aZ as B,ba as H,f as _,e as q,bU as f,ci as A,cb as M,m as F,o as G,W as O,q as Y,p as z,E as $,r as W}from"./app-k0jcl5PQ.js";import{T as Z,a as K}from"./m0YrH4Ug.chunk.js";import{C as P}from"./_XP6hjk3.chunk.js";import"./BUELddOb.chunk.js";import"./CnoMMtVD.chunk.js";import"./BzIt8QkE.chunk.js";import"./BEDdXV-K.chunk.js";import"./D1M9dqnr.chunk.js";import"./CnSDR2E3.chunk.js";import"./CovT_itD.chunk.js";const c="classrooms.addTeachersToClassroom",n=I.encloseNamespace(c);function V(a,l,o,e){return{userId:e,customerId:o,query:a,searchType:"user",filters:{excludeClassroom:l,userType:[M.Staff],userProfile:{status:[`${A.Active.toLowerCase()}`,`${A.Inactive.toLowerCase()}`],customerId:o}},indices:["user"],limit:K}}function ie(a){const[l,o]=T.useState(!1),[e,g]=T.useState([]),r=i(C.currentUser()),d=i(k.config()),x=i(C.token()),m=i(r.data&&P.getClassroom(a.id,r.data.id)),U=N(),S=L(),{hasPermissions:E}=v();function j(){e!=null&&e.length&&(o(!0),F(U,P.addInvitees(e.map(t=>t.id),a.id,()=>{o(!1),G.logUserAction({id:a.id,userCount:e.length},{actionType:W.Associate,entity:$.Classroom,location:z.Popup,descriptor:Y.User,workflowPhase:O.Complete}),S.success(n("success",{smartCount:e.length,classroomName:m.data.name,escapeText:!0})),a.closePopup()},()=>{o(!1),S.error(n("error",{smartCount:e.length,classroomName:m.data.name})),a.closePopup()})))}const R={application:q.USER_MANAGER,action:_.UserManager.STAFF},b=!!x.data&&!!m.data&&!!d.data&&!!r.data;return s.jsx(w,{closePopup:a.closePopup,title:n("title"),children:b&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"pb-3",children:s.jsx(Z,{placeholder:n("placeholder"),getRemoteUrl:()=>D.safeUrlConcat(d.data.gatewayApiUrl,"/v3/search"),getRemotePostBody:t=>V(t,a.id,r.data.customerId,r.data.id),requestHeaders:{authorization:`Bearer ${x.data.value}`},selections:e,formatRemoteSuggestions:t=>t.results.filter(p=>!e.find(y=>y.id===p.id)),onSuggestionSelected:t=>g([...e,t]),removeSelection:t=>g(e.filter(p=>p.id!==t.id)),imageCdnUrl:d.data.imageCdnUrl,activationLength:2,debounceTime:200,errorStateImageUrl:u.TYPEAHEAD_ERROR,emptyStateImageUrl:u.EmptyStates.TYPEAHEAD_RESULTS})}),s.jsxs("div",{className:"pb-3 d-flex flex-column align-items-center",children:[s.jsx("img",{className:"img-fluid w-50 px-1 pb-2 pt-1",src:u.EmptyStates.Classrooms.ADD_TEACHERS}),s.jsx("p",{className:"mb-0 text-center",children:s.jsx(h,{namespace:c,phrase:"info"})}),E(B.ManageUsers)&&s.jsxs("p",{className:"mb-0 text-center",children:[s.jsx(h,{namespace:c,phrase:"createStaff"})," ",s.jsx(H,{appLink:R,onClick:a.closePopup,className:"info-link",children:s.jsx(h,{namespace:c,phrase:"staffManager"})})]})]}),s.jsxs(f,{children:[s.jsx(f.Cancel,{onClick:a.closePopup}),s.jsx(f.Submit,{variant:"dark",onClick:j,text:n("addTeachers"),disabled:!(e!=null&&e.length),showSpinner:l})]})]})})}export{ie as AddTeachersToClassroomView};
//# sourceMappingURL=czJL4PnJ.chunk.js.map
