1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[856],{5728:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/school/teachers/bulk-add",function(){return t(28665)}])},45965:function(e,n,t){"use strict";t.d(n,{Jn:function(){return s},Q2:function(){return i},Y7:function(){return r}});var r="\n mutation CreateTeacher(\n $input: CreateTeacherInput!\n $condition: ModelTeacherConditionInput\n ) {\n createTeacher(input: $input, condition: $condition) {\n id\n name\n schoolCode\n email\n cognitoSub\n expertise\n description\n isActive\n createdAt\n updatedAt\n }\n }\n",s="\n mutation UpdateTeacher(\n $input: UpdateTeacherInput!\n $condition: ModelTeacherConditionInput\n ) {\n updateTeacher(input: $input, condition: $condition) {\n id\n name\n schoolCode\n email\n cognitoSub\n expertise\n description\n isActive\n createdAt\n updatedAt\n }\n }\n",i="\n mutation DeleteTeacher(\n $input: DeleteTeacherInput!\n $condition: ModelTeacherConditionInput\n ) {\n deleteTeacher(input: $input, condition: $condition) {\n id\n }\n }\n"},71505:function(e,n,t){"use strict";t.d(n,{j:function(){return s},n:function(){return r}});var r="\n query TeachersBySchool(\n $schoolCode: String!\n $filter: ModelTeacherFilterInput\n $limit: Int\n $nextToken: String\n ) {\n teachersBySchool(\n schoolCode: $schoolCode\n filter: $filter\n limit: $limit\n nextToken: $nextToken\n ) {\n items {\n id\n name\n schoolCode\n email\n cognitoSub\n expertise\n description\n isActive\n createdAt\n updatedAt\n }\n nextToken\n }\n }\n",s="\n query GetTeacher($id: ID!) {\n getTeacher(id: $id) {\n id\n name\n schoolCode\n email\n cognitoSub\n expertise\n description\n isActive\n createdAt\n updatedAt\n }\n }\n"},28665:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return S}});var r=t(47568),s=t(29815),i=t(70655),o=t(85893),a=t(67294),c=t(10552),l=t(44541),u=t(38901),d=t(17984),h=t(71505),p=t(22680),m=["teacher name"],f=["expertise","description","active"],v=1e3,b=function(e){return String(e||"").trim().toLowerCase()},g=function(e,n,t){var r=n.find((function(e){return e.normalized===t}));if(!r)return"";var s=e[r.original];return void 0!==s&&null!==s?String(s).trim():""},x=function(e){var n=String(e||"").trim().toLowerCase();return!n||(!!["true","yes","1","active"].includes(n)||!["false","no","0","inactive"].includes(n)&&null)},w=function(e){var n=[];if(!e||!e.length)return{valid:!1,errors:["File is empty or has no rows"],columns:[]};var t=Object.keys(e[0]).map((function(e){return{original:e,normalized:(n=e,n.trim().toLowerCase().replace(/[_\s]+/g," "))};var n})),r=t.map((function(e){return e.normalized})),s=m.filter((function(e){return!r.includes(e)}));return s.length&&(n.push("Missing required columns: ".concat(s.join(", "))),n.push("Expected columns: ".concat(m.join(", "),", ").concat(f.join(" (optional), ")," (optional)"))),{valid:0===n.length,errors:n,columns:t}},y=function(){var e=(0,r.Z)((function(e){var n,t,r,s,o,a,c,l,u=arguments;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:if(n=u.length>1&&void 0!==u[1]?u[1]:[],!(t=(0,p.Sh)(e)).valid)return[2,{valid:!1,errors:t.errors,rows:[]}];r=[],i.label=1;case 1:return i.trys.push([1,3,,4]),[4,(0,p.P4)(e)];case 2:return r=i.sent(),[3,4];case 3:return[2,{valid:!1,errors:[i.sent().message||"Failed to parse file"],rows:[]}];case 4:return r.length>v?[2,{valid:!1,errors:["File exceeds maximum rows (".concat(v,")")],rows:[]}]:(s=w(r)).valid?(o=new Set(n.map((function(e){return b(e.name)}
1))),a=new Set,c=[],l=[],r.forEach((function(e,n){var t=n+2,r=g(e,s.columns,"teacher name"),i=g(e,s.columns,"expertise"),u=g(e,s.columns,"description"),d=g(e,s.columns,"active");r?(r.length<2||r.length>80)&&c.push("Row ".concat(t,": Teacher Name must be 2-80 characters")):c.push("Row ".concat(t,": Teacher Name is required"));var h=b(r);h&&(a.has(h)?c.push("Row ".concat(t,": Duplicate Teacher Name in file (").concat(r,")")):a.add(h),o.has(h)&&c.push("Row ".concat(t,": Teacher already exists (").concat(r,")")));var p=x(d);null===p&&c.push("Row ".concat(t,": Active must be one of true/false/yes/no/1/0")),l.push({valid:!0,data:{name:r,expertise:i||null,description:u||null,isActive:null===p||p}})})),[2,{valid:0===c.length,errors:c,rows:l,columns:s.columns}]):[2,{valid:!1,errors:s.errors,rows:[]}]}}))}));return function(n){return e.apply(this,arguments)}}(),T=t(26042),j=t(69396),_=t(45965),N=function(){var e=(0,r.Z)((function(e,n,t){var r,s,o,a,u,d;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:r={success:[],errors:[],total:e.length},s=0,i.label=1;case 1:if(!(s<e.length))return[3,7];o=e[s],i.label=2;case 2:return i.trys.push([2,4,,5]),[4,c.b.graphql((0,l.wT)(_.Y7,{input:{name:o.name.trim(),schoolCode:n,expertise:o.expertise||null,description:o.description||null,isActive:!1!==o.isActive}}))];case 3:return i.sent(),r.success.push(o),[3,5];case 4:return a=i.sent(),r.errors.push((0,j.Z)((0,T.Z)({},o),{error:(null===a||void 0===a||null===(u=a.errors)||void 0===u||null===(d=u[0])||void 0===d?void 0:d.message)||a.message||"Failed to create teacher"})),[3,5];case 5:t&&t({current:s+1,total:e.length,success:r.success.length,errors:r.errors.length}),i.label=6;case 6:return s++,[3,1];case 7:return[2,r]}}))}));return function(n,t,r){return e.apply(this,arguments)}}(),S=function(){var e=(0,a.useState)(""),n=e[0],t=e[1],p=(0,a.useState)([]),m=p[0],f=p[1],v=(0,a.useState)(null),b=v[0],g=v[1],x=(0,a.useState)(null),w=x[0],T=x[1],j=(0,a.useState)(!1),_=j[0],S=j[1],C=(0,a.useState)(!1),k=C[0],$=C[1],A=(0,a.useState)({current:0,total:0,success:0,errors:0}),E=A[0],Z=A[1],F=(0,a.useState)(null),R=F[0],I=F[1],D=function(){var e=(0,r.Z)((function(e){var n,t,r,s,o;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:n=[],t=null,i.label=1;case 1:return[4,c.b.graphql((0,l.wT)(h.n,{schoolCode:e,nextToken:t}))];case 2:s=i.sent(),o=null===s||void 0===s||null===(r=s.data)||void 0===r?void 0:r.teachersBySchool,n=n.concat((null===o||void 0===o?void 0:o.items)||[]),t=null===o||void 0===o?void 0:o.nextToken,i.label=3;case 3:if(t)return[3,1];i.label=4;case 4:return f(n),[2,n]}}))}));return function(n){return e.apply(this,arguments)}}();(0,a.useEffect)((function(){(0,r.Z)((function(){var e,n,r,s;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),[4,u.g.currentAuthenticatedUser()];case 1:return n=i.sent(),r=(null===n||void 0===n||null===(e=n.attributes)||void 0===e?void 0:e["custom:code"])||"",t(r),r?[4,D(r)]:[3,3];case 2:i.sent(),i.label=3;case 3:return[3,5];case 4:return s=i.sent(),console.error("Failed to load teacher bulk context:",s),[3,5];case 5:return[2]}}
1))}))()}),[]);var U=function(){var e=(0,r.Z)((function(e){var n;return(0,i.__generator)(this,(function(t){switch(t.label){case 0:return n=e.target.files[0],g(n||null),T(null),I(null),n?[4,L(n)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}));return function(n){return e.apply(this,arguments)}}(),L=function(){var e=(0,r.Z)((function(e){var n,t;return(0,i.__generator)(this,(function(r){switch(r.label){case 0:if(!e)return[2];S(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,y(e,m)];case 2:return n=r.sent(),T(n),[3,5];case 3:return t=r.sent(),T({valid:!1,errors:[t.message||"Failed to validate file"],rows:[]}),[3,5];case 4:return S(!1),[7];case 5:return[2]}}))}));return function(n){return e.apply(this,arguments)}}(),q=function(){var e=(0,r.Z)((function(){var e,t,r;return(0,i.__generator)(this,(function(s){switch(s.label){case 0:if(!(null===w||void 0===w?void 0:w.valid))return[2];$(!0),Z({current:0,total:w.rows.length,success:0,errors:0}),s.label=1;case 1:return s.trys.push([1,4,5,6]),e=w.rows.map((function(e){return e.data})),[4,N(e,n,Z)];case 2:return t=s.sent(),I(t),[4,D(n)];case 3:return s.sent(),[3,6];case 4:return r=s.sent(),alert("Failed to process teachers: ".concat(r.message)),[3,6];case 5:return $(!1),[7];case 6:return[2]}}
1))}));return function(){return e.apply(this,arguments)}}();return(0,o.jsx)(d.Z,{children:(0,o.jsxs)("div",{className:"mb-2 border-solid border-gray-300 rounded border shadow-sm w-full",children:[(0,o.jsx)("div",{className:"bg-purple-bright text-white text-bold px-2 py-3 border-solid border-gray-200 border-b",children:"Bulk Add Teachers"}),(0,o.jsxs)("div",{className:"p-4 space-y-4",children:[(0,o.jsxs)("p",{className:"text-sm text-gray-700",children:["Download template:"," ",(0,o.jsx)("a",{href:"/templates/teacher-import-template.csv",className:"text-indigo-600 underline",children:"teacher-import-template.csv"})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{className:"block uppercase tracking-wide text-xs font-light mb-2",children:"Upload CSV or Excel *"}),(0,o.jsx)("input",{type:"file",accept:".csv,.xlsx,.xls",onChange:U,className:"block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100"})]}),b?(0,o.jsx)("button",{type:"button",onClick:function(){return L(b)},disabled:_,className:"px-4 py-2 rounded bg-green-600 text-white disabled:bg-gray-400",children:_?"Validating...":"
1Validate File"}):null,w?(0,o.jsxs)("div",{className:"p-3 rounded border ".concat(w.valid?"border-green-200 bg-green-50":"border-red-200 bg-red-50"),children:[(0,o.jsx)("p",{className:"font-semibold",children:w.valid?"Validation Passed":"Validation Failed"}),(0,o.jsxs)("p",{className:"text-sm",children:["Total rows: ",w.rows.length]}),w.errors.length?(0,o.jsx)("div",{className:"mt-2 max-h-64 overflow-y-auto text-sm text-red-700",children:w.errors.map((function(e,n){return(0,o.jsx)("p",{children:e},"".concat(e,"-").concat(n))}))}):null]}):null,!(null===w||void 0===w?void 0:w.valid)||k||R?null:(0,o.jsxs)("button",{type:"button",onClick:q,className:"px-4 py-2 rounded bg-indigo-600 text-white",children:["Process ",w.rows.length," Teachers"]}),k?(0,o.jsxs)("div",{className:"p-3 rounded border border-blue-200 bg-blue-50 text-sm",children:[(0,o.jsxs)("p",{children:["Processing: ",E.current," / ",E.total]}),(0,o.jsxs)("p",{className:"text-green-700",children:["Success: ",E.success]}),(0,o.jsxs)("p",{className:"text-red-700",children:["Errors: ",E.errors]})]}):null,R?(0,o.jsxs)("div",{className:"p-3 rounded border border-gray-200 bg-gray-50 text-sm",children:[(0,o.jsxs)("p",{children:["Total: ",R.total]}),(0,o.jsxs)("p",{className:"text-green-700",children:["Success: ",R.success.length]}),(0,o.jsxs)("p",{className:"text-red-700",children:["Errors: ",R.errors.length]}),R.errors.length?(0,o.jsx)("button",{type:"button",onClick:function(){var e;if(null===R||void 0===R||null===(e=R.errors)||void 0===e?void 0:e.length){var n=R.errors.map((function(e){return[e.name||"",e.expertise||"",e.description||"",e.error||""]})),t=[["Teacher Name","Expertise","Description","Error"]].concat((0,s.Z)(n)).map((function(e){return e.map((function(e){return'"'.concat(String(e).replace(/"/g,'""'),'"')})).join(",")})).join("\n"),r=new Blob([t],{type:"text/csv"}),i=window.URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download="school_bulk_teachers_failures_".concat(Date.now(),".csv"),o.click(),window.URL.revokeObjectURL(i)}},className:"mt-2 px-4 py-2 rounded bg-red-600 text-white",children:"Download Error Report"}):null]}):null]})]})})}}},function(e){e.O(0,[2251,1664,3654,3616,9424,9356,5558,7984,306,9774,2888,179],(function(){return n=5728,e(e.s=n);var n}));var n=e.O();_N_E=n}]);
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.