import{aI as o,L as v,ao as e,aP as p,c4 as U,aX as D,az as M,aj as _,bN as F,gY as J,by as I,ba as H,f as j,e as C,m as f,v as $,du as b,aZ as q,dm as u}from"./app-k0jcl5PQ.js";import{L as y}from"./CIOPWeNI.chunk.js";import{C as k}from"./_XP6hjk3.chunk.js";import"./BCKXZxoz.chunk.js";const G="classrooms.joinClassroomResponseDetails",s=v.encloseNamespace(G);function N(t){const[l,r]=o.useState(""),[n,a]=o.useState("");return o.useEffect(()=>{switch(t.error){case"invalid":r(s("invalidError")),a(s("invalidMessage"));break;case"wrong-school":r(s("wrongSchoolError")),a(s("wrongSchoolMessage"));break;case"not-a-learner":r(s("notALearnerError")),a(s("notALearnerMessage"));break;default:r(s("unknownError")),a(s("unknownMessage"));break}},[t.error]),t.error?e.jsxs("div",{children:[e.jsx("img",{src:p.AddStudents.JoinClassroomResponse.ERROR,className:"w-50 mb-3 d-block mx-auto"}),e.jsx("div",{className:"text-center h6",children:e.jsx("strong",{children:l})}),e.jsx("div",{className:"text-center mb-3",children:n})]}):e.jsxs("div",{children:[e.jsx("img",{src:p.AddStudents.JoinClassroomResponse.SUCCESS,className:"w-50 mb-3 d-block mx-auto"}),e.jsx("div",{className:"text-center h6",children:e.jsx("strong",{children:s("success")})}),e.jsxs("div",{className:"text-center mb-3",children:[s("join"),e.jsx("strong",{children:t.classroomName})]})]})}const T="_logo_11232_1",B="_formContainer_11232_5",S={logo:T,formContainer:B},O="classrooms.joinClassroom",E=v.encloseNamespace(O);function Y(t){var g,x;const l=U(),{hasPermissions:r}=D(),n=M(_.currentUser());F({title:E("title")});const[a,m]=o.useState(!1),[d,i]=o.useState(null),[w,L]=o.useState("");function A(c){L(c.classroomName),m(!0)}function h(c){switch(c.status){case u.NotFound:i("invalid");break;case u.Forbidden:i("wrong-school");break;case u.BadRequest:i("not-a-learner");break;default:i("unknown");break}m(!0)}function R(){f(l,k.checkJoinCode(t.joinCode,c=>{if(n.data.isAuthenticated){P();return}$.trigger({application:C.DEFAULT,action:j.Default.CHALLENGE,params:{redirectUrl:b.GetCurrentPath()+b.GetCurrentQueryString(),skipPrompt:!0,customerId:c.customerId}})},h))}function P(){if(!r(q.JoinClassroom)){i("not-a-learner"),m(!0);return}f(l,k.joinClassroom(t.joinCode,A,h))}return o.useEffect(()=>{n.data&&R()},[(g=n.data)==null?void 0:g.isAuthenticated]),e.jsx(y,{children:e.jsxs("div",{className:`${S.formContainer} m-auto`,children:[e.jsx("div",{className:`${S.logo} mb-4 mx-auto`,children:e.jsx(J,{})}),!a&&e.jsx("div",{className:"text-center p-5",children:e.jsx(I,{as:"div",animation:"border",role:"status"})}),a&&!d&&e.jsx(N,{classroomName:w}),a&&d&&e.jsx(N,{error:d}),((x=n.data)==null?void 0:x.isAuthenticated)&&e.jsx(H,{className:"btn btn-dark w-100 mt-2 btn-lg",appLink:{application:C.STUDENT_FEED,action:j.StudentFeed.HOME},children:E("enter")})]})})}export{Y as JoinClassroomView};
//# sourceMappingURL=CzBUr2l7.chunk.js.map
