1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3528],{16391:(e,r,o)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/classrooms",function(){return o(25807)}])},25807:(e,r,o)=>{"use strict";o.r(r),o.d(r,{__N_SSP:()=>Z,default:()=>ee});var l=o(18153),t=o(59803),i=o(42720),s=o(82736),n=o(39955),a=o(16425),c=o(50845),d=o(51362),u=o(78107),h=o(54443),p=o(75292),m=o(59035),g=o(11626),b=o(50485),y=o(13642),C=o(78732),f=o(91921),x=o(52276),Y=o(97460),A=o(44824),D=o(89099),w=o(41954),v=o(91612),$=o(46304),_=o(54260),F=o(41004),S=o(39077);function E({id:e,title:r,code:o,classroomSize:i,createdAt:a}){let c=(0,D.useRouter)(),[d,u]=(0,S.A)({classroomId:e,title:r}),[h,p]=(0,F.A)({classroomId:e,title:r}),k=async r=>{(0,v.A)(r.target,e=>"BUTTON"===e.tagName)||await c.push((0,$.JVf)(e,"certifications"))};return(0,l.FD)(n.a,{borderRadius:"8px",width:"100%",border:"2px solid",borderColor:"border",backgroundColor:"bg",_hover:{cursor:"pointer",backgroundColor:"bg.subtle",border:"2px solid",borderColor:"primary.border"},_active:{cursor:"pointer",backgroundColor:"bg.muted",border:"2px solid",borderColor:"border.emphasized"},children:[(0,l.Y)(n.a,{px:"32px",py:"32px",onClick:k,children:(0,l.FD)(t.s,{direction:"column",gap:8,children:[(0,l.FD)(n.a,{children:[(0,l.FD)(t.s,{justify:"space-between",align:"center",children:[(0,l.Y)(s.D,{size:"lg",as:"h3",children:r}),(0,l.FD)(m.W,{variant:"normal",closeOnSelect:!0,placement:"bottom-end",children:[(0,l.Y)(g.I,{as:b.K,variant:"icon",border:"2px",borderRadius:"8px",borderColor:"border.emphasized",style:{height:"40px",width:"40px"},icon:(0,l.Y)(Y.g,{icon:x.vHW,color:(0,w.A)("primary.fg")})}),(0,l.FD)(y.c,{bg:"bg",border:"2px solid",borderColor:"border.emphasized",mx:"16px",py:"8px",borderRadius:"5px",filter:"drop-shadow(0px 4px 3px rgba(0, 0, 0, 0.15))",children:[(0,l.FD)(C.D,{borderRadius:0,cursor:"pointer",value:"withdraw",py:"8px",px:"16px",onClick:u,children:[(0,l.Y)(n.a,{width:"20px",children:(0,l.Y)(Y.g,{color:(0,w.A)("fg.muted"),icon:x.MT7})}),(0,l.Y)(f.E,{color:"fg.muted",ml:"12px",children:"Rename Classroom"})]}),(0,l.FD)(C.D,{borderRadius:0,cursor:"pointer",value:"withdraw",py:"8px",px:"16px",onClick:p,children:[(0,l.Y)(n.a,{width:"20px",children:(0,l.Y)(Y.g,{color:(0,w.A)("error.fg"),icon:x.BeE})}),(0,l.Y)(f.E,{ml:"12px",color:"error.fg",children:"Delete Classroom"})]})]})]})]}),(0,l.Y)(f.E,{fontWeight:"bold",color:"fg.muted",children:`Created On ${A.c9.fromISO(a).toLocaleString(A.c9.DATE_MED)}`})]}),(0,l.FD)(t.s,{justify:"space-between",align:"center",children:[(0,l.Y)(n.a,{bgColor:"primary.subtle",px:4,py:2,rounded:4,children:(0,l.Y)(f.E,{fontWeight:"bold",children:o})}),(0,l.Y)(n.a,{children:(0,l.Y)(_.A,{faIcon:x.O26,text:`${i}`})})]})]})}),d,h]})}var k=o(38890),T=o(87365),R=o(14232),X=o(74175),z=o(9496),N=o(41130),j=o(33678),I=o(65956);let L={join:{heading:"Join a Class",subText:"Enter the class code for your classroom to join",placeholder:"e.g. V7B8T2 ",buttonText:"Join"},create:{heading:"Create a Class",subText:"Enter a class name to create a classroom",placeholder:"e.g. Period 2 Algebra",buttonText:"Create"}};function J({type:e,size:r}){let o=(0,N._)(),i=(0,D.useRouter)(),[a,c]=(0,R.useState)(null),[d,u]=(0,R.useState)(!1),{heading:h,subText:p,placeholder:m,buttonText:g}=L[e],[b,y]=(0,X.A)(async()=>{await z.Vf.joinClassroom({code:a??""}),o({title:"Successfully joined classroom",status:"success"}),u(!1),c(null)},[o,a],"Joining Classroom"),[C]=(0,X.A)(async()=>{let e=await z.Vf.createClassroom({title:a??""});o({title:(0,l.FD)(f.E,{children:["Successfully created the classroom ",a,"!"," ",(0,l.Y)(k.$,{variant:"link-btn",color:"primary.fg",onClick:()=>i.push((0,$.JVf)(e,"certifications")),children:"Go to classroom"})]}),status:"success"}),c(null)},[o,a,i],"Adding Classroom");return(0,l.FD)(t.s,{width:"100%",py:"condensed"===r?"32px":"96px",px:"32px",direction:"column",alignItems:"condensed"===r?"left":"center",bgColor:"bg.subtle",rounded:8,gap:8,children:[(0,l.FD)(t.s,{direction:"column",alignItems:"condensed"===r?"left":"center",gap:2,children:[(0,l.Y)(s.D,{size:"2xl",as:"h2",children:h}),(0,l.Y)(f.E,{children:p})]}),(0,l.FD)(t.s,{direction:"row",gap:4,children:[(0,l.Y)(n.a,{maxW:"272px",children:(0,l.Y)(j.S,{onInput:e=>c(e.target.value),placeholder:m,value:a??"",type:"text"})}),(0,l.Y)(k.$,{onClick:"join"===e?()=>u(!0):C,isDisabled:null==a||0===a.length,children:g})]}),(0,l.Y)(I.A,{open:d,onClose:()=>u(!1),title:"Join Classroom",size:"lg",body:()=>(0,l.FD)(n.a,{children:[(0,l.Y)(f.E,{children:"By joining this classroom, you are agreeing to share your activity on Schoolhouse with the teacher. This includes your sessions attended, sessions hosted, certification attempts, and more."}),(0,l.FD)(t.s,{mt:"16px",children:[(0,l.Y)(T.h,{}),(0,l.Y)(k.$,{variant:"outline",onClick:()=>u(!1),mr:"8px",children:"Cancel"}),(0,l.Y)(k.$,{isLoading:y,onClick:b,children:"Join"})]})]})})]})}function M(){let e=(0,h.I)(),r=(0,p.Jd)(),o=e.many(u.A.where({userId:r.id})).map(e=>({id:e(u.A.id)??0,title:e(u.A.title)??"",code:e(u.A.code)??"",createdAt:e(u.A.created_at)??"",classroomMembers:e(u.A.countClassroomMembers())??0})),t=0===o.length;return(0,l.FD)(l.FK,{children:[(0,l.Y)(c.E,{colSpan:t?12:[12,12,5],children:(0,l.Y)(J,{size:t?"full":"condensed",type:"create"})}),(0,l.Y)(c.E,{colSpan:[12,12,7],children:(0,l.FD)(d.T,{spacing:"18px",children:[t?null:(0,l.Y)(s.D,{size:"xl",as:"h3",mb:"8px",alignSelf:"flex-start",children:"My Created Classrooms"}),o.map(e=>(0,l.Y)(E,{id:e.id,title:e.title,code:e.code,classroomSize:e.classroomMembers,createdAt:e.createdAt},e.id??0))]})})]})}var O=o(35525),W=o(55720),U=o(44517),K=o(47808);function V({id:e,teacherName:r,classroomTitle:o,joinDate:i,code:a}
1){let[c,d]=(0,R.useState)(!1),u=(0,N._)(),[h,p]=(0,X.A)(async()=>{await z.Vf.leaveClassroom({classroomId:e}),u({title:"Successfully left classroom",status:"success"})},[e,u],"Leaving Classroom");return(0,l.FD)(n.a,{borderRadius:"8px",width:"100%",border:"2px solid",borderColor:"border",backgroundColor:"bg",children:[(0,l.Y)(n.a,{px:"32px",py:"32px",children:(0,l.FD)(t.s,{direction:"column",gap:8,children:[(0,l.FD)(n.a,{children:[(0,l.FD)(t.s,{justify:"space-between",align:"center",children:[(0,l.Y)(s.D,{size:"lg",as:"h3",children:o}),(0,l.Y)(K.A,{content:"Leave Classroom",children:(0,l.Y)(n.a,{userSelect:"none",pointerEvents:"all",borderRadius:"50%",justifyContent:"center",bg:"bg",_hover:{bg:"bg.muted",color:"fg.subtle",cursor:"pointer"},_active:{bg:"bg.subtle",boxShadow:"inset 0 0 6px rgba(0, 0, 0, 0.05)"},onClick:()=>d(!0),children:(0,l.Y)(b.K,{size:"sm",pointerEvents:"none",variant:"icon",border:"2px",borderRadius:"8px",borderColor:"border.emphasized",color:"fg.error",height:"40px",width:"40px","aria-label":"Leave Classroom",icon:(0,l.Y)(Y.g,{style:{height:"16px",width:"16px"},icon:U.XBh})})})})]}),(0,l.Y)(f.E,{fontWeight:"bold",color:"fg.muted",children:`Created by ${r} ⢠Joined ${A.c9.fromISO(i).toLocaleString(A.c9.DATE_MED)}`})]}),(0,l.Y)(t.s,{justify:"space-between",align:"center",children:(0,l.Y)(n.a,{bgColor:"info.subtle",px:4,py:2,rounded:4,children:(0,l.Y)(f.E,{fontWeight:"bold",children:a})})})]})}),(0,l.Y)(I.A,{open:c,onClose:()=>d(!1),title:"Leave Classroom",size:"lg",body:()=>(0,l.FD)(n.a,{children:[(0,l.FD)(f.E,{children:['When you leave "',o,'", your certification, tutoring, and learning activity will no longer be shared.']}),(0,l.FD)(t.s,{mt:"16px",children:[(0,l.Y)(T.h,{}),(0,l.Y)(k.$,{variant:"outline",onClick:()=>d(!1),mr:"8px",children:"Cancel"}),(0,l.Y)(k.$,{isLoading:p,onClick:h,children:"Leave"})]})]})})]})}function P(){let e=(0,p.Jd)(),r=(0,h.I)().one(W.Ay.where({id:e.id})).many(O.A.where({userId:W.Ay.id,include:[{association:"Classroom",required:!0}]})).map(e=>{let r=e.one(u.A.getUser());return{id:e(u.A.id)??0,teacherName:r(W.Ay.display_name)??"",classroomTitle:e(u.A.title)??"",joinDate:e(O.A.created_at)??"",code:e(u.A.code)??""}}),o=0===r.length;return(0,l.FD)(l.FK,{children:[(0,l.Y)(c.E,{colSpan:o?12:[12,12,5],children:(0,l.Y)(J,{size:o?"full":"condensed",type:"join"})}),(0,l.Y)(c.E,{colSpan:[12,12,7],children:(0,l.FD)(d.T,{spacing:"18px",children:[o?null:(0,l.Y)(s.D,{size:"xl",as:"h3",mb:"8px",alignSelf:"flex-start",children:"My Joined Classrooms"}),r.map(e=>(0,l.Y)(V,{id:e.id,teacherName:e.teacherName,classroomTitle:e.classroomTitle,joinDate:e.joinDate,code:e.code},e.id??0))]})})]})}var q=o(49783),B=o(71822),H=o(81727),G=o(64829);let Q=(0,a.A)(function(){let[e,r]=(0,G.A)({queryKey:"filter",tabToQueryParam:{"Create a Class":"created","Join a Class":"joined"},defaultTab:"Create a Class"});return(0,l.FD)(q.A,{title:"My Classrooms",children:[(0,l.Y)(t.s,{direction:"column",bgColor:"bg.subtle",align:"center",position:"relative",py:"16px",overflow:"hidden",children:(0,l.Y)(i.m,{children:(0,l.Y)(s.D,{size:"3xl",as:"h1",mt:"48px",children:"My Classrooms"})})}),(0,l.FD)(i.m,{children:[(0,l.Y)(n.a,{my:4,children:(0,l.Y)(H.A,{currentTab:e,tabToUrl:r,tabs:["Create a Class","Join a Class"]})}),(0,l.FD)(B.A,{children:["Create a Class"===e?(0,l.Y)(M,{}):null,"Join a Class"===e?(0,l.Y)(P,{}):null]})]})]})},{userRoles:["user:basic"]});var Z=!0;let ee=Q},35525:(e,r,o)=>{"use strict";o.d(r,{A:()=>a});var l=o(78919),t=o(78107),i=o(74856),s=o(55720);let n={...(0,i.SN)("classroom_member")(["id","user_id","classroom_id","created_at","deleted_at"]),associations:()=>({User:{query:s.Ay,foreignKey:s.Ay.id,sourceKey:n.user_id},Classroom:{query:t.A,foreignKey:t.A.id,sourceKey:n.classroom_id}}),where:({id:e,userId:r,classroomId:o,include:t=[],order:s=null,paranoid:a=!0},c=null)=>(0,l.Xs)` 2 FROM ${n} 3 ${(0,i.cA)(n,t)} 4 WHERE 5 ${null!=e?(0,l.Xs)`${n.id} = ${e} AND`:(0,l.Xs)``} 6 ${null!=r?(0,l.Xs)`${n.user_id} = ${r} AND`:(0,l.Xs)``} 7 ${null!=o?(0,l.Xs)`${n.classroom_id} = ${o} AND`:(0,l.Xs)``} 8 ${a?(0,l.Xs)`${n.deleted_at} IS NULL AND`:(0,l.Xs)``} 9 ${null!=c?c:(0,l.Xs)`TRUE`} 10 ${(0,i.k5)(s)} 11 `},a=n},39077:(e,r,o)=>{"use strict";o.d(r,{A:()=>m});var l=o(18153),t=o(39955),i=o(59803),s=o(87365),n=o(38890),a=o(14232),c=o(74175),d=o(9496),u=o(41130),h=o(33678),p=o(65956);function m({title:e,classroomId:r}){let o=(0,u._)(),[g,b]=(0,a.useState)(!1),[y,C]=(0,a.useState)(e),[f,x]=(0,c.A)(async()=>{await d.Vf.editClassroom({classroomId:r,title:y}),o({title:"Successfully edited classroom",status:"success"}),b(!1)},[r,y,o],"Editing Classroom");return[(0,l.Y)(p.A,{open:g,onClose:()=>
11b(!1),title:"Rename Classroom",size:"lg",body:()=>(0,l.FD)(t.a,{children:[(0,l.Y)(h.S,{onInput:e=>C(e.target.value),value:y,type:"text"}),(0,l.FD)(i.s,{mt:"16px",children:[(0,l.Y)(s.h,{}),(0,l.Y)(n.$,{variant:"outline",onClick:()=>b(!1),mr:"8px",children:"Cancel"}),(0,l.Y)(n.$,{isLoading:x,onClick:f,children:"Rename"})]})]})}),()=>b(!0)]}},41004:(e,r,o)=>{"use strict";o.d(r,{A:()=>b});var l=o(18153),t=o(39955),i=o(91921),s=o(59803),n=o(87365),a=o(38890),c=o(89099),d=o(14232),u=o(74175),h=o(9496),p=o(46304),m=o(41130),g=o(65956);function b({title:e,classroomId:r}){let o=(0,m._)(),y=(0,c.useRouter)(),[C,f]=(0,d.useState)(!1),[x,Y]=(0,u.A)(async()=>{let e=(0,p.gdb)().endsWith(y.asPath);e?await h.Vf.deleteClassroom({classroomId:r}):await h.Ay.deleteClassroom({classroomId:r}),o({title:"Successfully deleted classroom",status:"success"}),e||await y.push((0,p.gdb)())},[r,y,o],"Deleting Classroom");return[(0,l.Y)(g.A,{open:C,onClose:()=>f(!1),title:"Delete Classroom",size:"lg",body:()=>(0,l.FD)(t.a,{children:[(0,l.FD)(i.E,{children:["â",e,"â will be deleted forever. You will no longer have access to your studentsâ certification, tutoring, and learning activity."]}),(0,l.FD)(s.s,{mt:"16px",children:[(0,l.Y)(n.h,{}),(0,l.Y)(a.$,{variant:"outline",onClick:()=>f(!1),mr:"8px",children:"Cancel"}),(0,l.Y)(a.$,{bgColor:"error.solid",isLoading:Y,onClick:x,children:"Delete"})]})]})}),()=>f(!0)]}},54260:(e,r,o)=>{"use strict";o.d(r,{A:()=>a});var l=o(18153),t=o(76032),i=o(39955),s=o(97460),n=o(41954);function a({faIcon:e,iconColor:r="gray.emphasized",iconSecondaryColor:o,text:c}){let d=null==o?{}:{"--fa-primary-color":(0,n.A)(r),"--fa-secondary-color":(0,n.A)(o),"--fa-primary-opacity":1,"--fa-secondary-opacity":1};return(0,l.FD)(t.B,{flex:1,direction:"row",color:"fg.muted",fontWeight:600,align:"center",spacing:"8px",fontSize:"14px",children:[(0,l.Y)(s.g,{icon:e,color:(0,n.A)(r??"gray.emphasized"),style:{fontSize:"16px",...d}}),(0,l.Y)(i.a,{children:c})]})}},64829:(e,r,o)=>{"use strict";o.d(r,{A:()=>t});var l=o(89099);function t({queryKey:e,tabs:r,tabToQueryParam:o,defaultTab:i,shallow:s=!1}){let n=(0,l.useRouter)(),a=e=>o?.[e]??e;return[(r??Object.keys(o??{})).find(r=>a(r)===n.query[e])??i,r=>{let o=new URLSearchParams(Object.entries(n.query));return o.set(e,a(r)),`${n.pathname}?${o.toString()}`},s]}},78107:(e,r,o)=>{"use strict";o.d(r,{A:()=>a});var l=o(78919),t=o(35525),i=o(74856),s=o(55720);let n={...(0,i.SN)("classroom")(["id","code","user_id","title","created_at","deleted_at"]),getUser:()=>(0,l.Xs)`${s.Ay.where({id:n.user_id})}`,countClassroomMembers:()=>(0,l.Xs)`count(*)::integer ${t.A.where({classroomId:n.id})}`,where:({id:e,userId:r,groupBy:o=null,order:t=null,paranoid:s=!0},a=null)=>(0,l.Xs)` 12 FROM ${n} 13 WHERE 14 ${null!=e?(0,l.Xs)`${n.id} = ${e} AND`:(0,l.Xs)``} 15 ${null!=r?(0,l.Xs)`${n.user_id} = ${r} AND`:(0,l.Xs)``} 16 ${s?(0,l.Xs)`${n.deleted_at} IS NULL AND`:(0,l.Xs)``} 17 ${null!=a?a:(0,l.Xs)`TRUE`} 18 ${(0,i.G1)(o)} 19 ${(0,i.k5)(t)} 20 `},a=n}},e=>{e.O(0,[6425,636,6593,8792],()=>e(e.s=16391)),_N_E=e.O()}]); 21//# sourceMappingURL=classrooms-0408c158863e8901.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.