1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1908],{21831:(e,t,r)=>{"use strict";r.d(t,{A:()=>l});var n=r(73556),a=r(96540),s=r(86715),c=r(61512),i=r(77255),o=r(74848);function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}let l=function(e){var t=function(t){var r=(0,c.A)(),l=r.user,d=r.loading,p=r.subscriptionStatus,f=r.subscriptionLoading,h=r.subscriptionError,x=(0,s.useRouter)(),m=(0,a.useState)(!1),v=m[0],b=m[1],j=(0,i.Bd)("common").t;return((0,a.useEffect)(function(){if(!d&&!f){if("/oauth/callback"===x.pathname){b(!0);return}l?h?(console.warn("Subscription status could not be loaded, allowing access to prevent false redirect"),b(!0)):(!p||p&&"active"!==p.status&&"trialing"!==p.status)&&"/settings"!==x.pathname?setTimeout(function(){x.replace("/settings?tab=subscription")},100):b(!0):x.replace("/signin")}},[l,d,x,p,f,h]),(0,a.useEffect)(function(){var e=function(){"/oauth/callback"!==x.pathname&&!localStorage.getItem("token")&&l&&x.replace("/signin")};e();var t=setInterval(e,3e4);return function(){return clearInterval(t)}},[l,x,p]),d||f||!v)?(0,o.jsx)("div",{className:"flex items-center justify-center h-screen",children:(0,o.jsxs)("div",{className:"text-center",children:[(0,o.jsx)("div",{className:"spinner"}),(0,o.jsx)("p",{className:"mt-4",children:j("loading")})]})}):l?(0,o.jsx)(e,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach(function(t){(0,n.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({},t)):null};return t.displayName="WithAuth(".concat(e.displayName||e.name||"Component",")"),t}},93222:(e,t,r)=>{"use strict";r.d(t,{C_:()=>u,E0:()=>o,fl:()=>i,o$:()=>d,zs:()=>l});var n=r(5820),a=r(54756),s=r.n(a),c=r(57598),i=function(){var e=(0,n.A)(s().mark(function e(){var t,r,n,a,i,o,u,l,d,p,f,h,x,m=arguments;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=void 0===(r=(t=m.length>0&&void 0!==m[0]?m[0]:{}).page)?1:r,i=void 0===(a=t.limit)?20:a,u=void 0===(o=t.search)?"":o,d=void 0===(l=t.sort)?"updated_at:desc":l,p=t.area_id,f=t.status,h=new URLSearchParams({page:n.toString(),limit:i.toString(),sort:d}),u&&h.append("search",u),p&&h.append("area_id",p.toString()),f&&h.append("status",f),e.next=8,c.api.get("/courses?".concat(h.toString()));case 8:return x=e.sent,e.abrupt("return",x.data);case 10:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),o=function(){var e=(0,n.A)(s().mark(function e(t){var r;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(!t||"undefined"===t)){e.next=2;break}throw Error("Invalid course ID");case 2:return e.next=4,c.api.get("/courses/".concat(t));case 4:return r=e.sent,e.abrupt("return",r.data);case 6:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),u=function(){var e=(0,n.A)(s().mark(function e(t){var r;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c.api.post("/courses",t);case 2:return r=e.sent,e.abrupt("return",r.data);case 4:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),l=function(){var e=(0,n.A)(s().mark(function e(t){var r;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c.api.delete("/courses/".concat(t));case 2:return r=e.sent,e.abrupt("return",r.data);case 4:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),d=function(){var e=(0,n.A)(s().mark(function e(t){var r;return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c.api.post("/courses/".concat(t,"/archive"));case 2:return r=e.sent,e.abrupt("return",r.data);case 4:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()},39600:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>b});var n=r(86715),a=r(84491),s=r(21831),c=r(73556),i=r(5820),o=r(54756),u=r.n(o),l=r(96540),d=r(91106),p=r.n(d),f=r(93222),h=r(74848);function x(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?x(Object(r),!0).forEach(function(t){(0,c.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function v(e){var t,r,n,a,s=e.courseId,c=e.onChange,o=(0,l.useState)(null),d=o[0],x=o[1],v=(0,l.useState)(!0),b=v[0],j=v[1],g=(0,l.useState)(null),y=g[0],w=g[1];if((0,l.useEffect)(function(){if(s){var e=!1;return j(!0),w(null),(0,f.E0)(s).then(function(t){return!e&&x(t)}).catch(function(t){return!e&&w(t)}).finally(function(){return!e&&j(!1)}),function(){e=!0}}},[s]),b)return(0,h.jsx)("div",{"data-testid":"course-details-loading",className:"p-4 text-gray-500",children:"Loading courseâ¦"});if(y||!d)return(0,h.jsx)("div",{"data-testid":"course-details-error",className:"p-4 text-red-500",children:"Could not load course."});var N=(t=(0,i.A)(u().mark(function e(){return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,f.o$)(d.id);case 3:null==c||c(),x(m(m({},d),{},{status:"archived"})),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.error("archive failed",e.t0);case 10:case"end":return e.stop()}},e,null,[[0,7]])})),function(){return t.apply(this,arguments)}),O=(r=(0,i.A)(u().mark(function e(){return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(confirm("Delete this course? Attached projects will be detached, not deleted.")){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,(0,f.zs)(d.id);case 5:null==c||c(),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(2),console.error("delete failed",e.t0);case 11:case"end":return e.stop()}},e,null,[[2,8]])})),function(){return r.apply(this,arguments)});return(0,h.jsxs)("div",{"data-testid":"course-details",className:"space-y-6",children:[(0,h.jsxs)("header",{className:"space-y-1",children:[(0,h.jsxs)("nav",{className:"text-sm text-gray-500","aria-label":"Breadcrumb",children:[(0,h.jsx)(p(),{href:"/areas",className:"hover:underline",children:"Areas"}),d.area_id&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("span",{className:"mx-1",children:"âº"}),(0,h.jsxs)(p(),{href:"/areas/".concat(d.area_id),className:"hover:underline",children:["Area #",d.area_id]})]}),(0,h.jsx)("span",{className:"mx-1",children:"âº"}),(0,h.jsx)("span",{className:"text-gray-700",children:d.name})]}),(0,h.jsx)("h1",{className:"text-2xl font-semibold",children:d.name}),(0,h.jsx)("p",{className:"text-sm text-gray-500",children:[d.subject,d.term,d.instructor].filter(Boolean).join(" \xb7 ")}),(0,h.jsxs)("div",{className:"flex gap-3 pt-2",children:[(0,h.jsxs)("span",{"data-testid":"course-details-resource-count",className:"rounded-full bg-indigo-50 px-3 py-1 text-xs text-indigo-700",children:[null!==(n=d.aggregate_resource_count)&&void 0!==n?n:0," resources"]}),(0,h.jsxs)("span",{"data-testid":"course-details-due-count",className:"rounded-full bg-amber-50 px-3 py-1 text-xs text-amber-700",children:[null!==(a=d.aggregate_due_review_count)&&void 0!==a?a:0," due reviews"]}),(0,h.jsx)("span",{className:"rounded-full bg-gray-100 px-3 py-1 text-xs text-gray-600",children:d.status})]})]}),(0,h.jsxs)("section",{children:[(0,h.jsx)("h2",{className:"mb-2 text-sm font-medium uppercase tracking-wide text-gray-500",children:"Projects"}),Array.isArray(d.projects)&&d.projects.length>0?(0,h.jsx)("ul",{className:"space-y-2",children:d.projects.map(function(e){return(0,h.jsxs)("li",{"data-testid":"course-details-project-".concat(e.id),className:"rounded border bg-white p-3",children:[(0,h.jsx)(p(),{href:"/projects/".concat(e.id),className:"font-medium text-gray-800 hover:underline",children:e.name}),e.status&&(0,h.jsx)("span",{className:"ml-2 text-xs text-gray-400",children:e.status})]},e.id)})}):(0,h.jsx)("p",{"data-testid":"course-details-no-projects",className:"text-sm text-gray-500",children:"No projects attached yet."})]}),(0,h.jsxs)("footer",{className:"flex gap-2 border-t pt-4",children:["archived"!==d.status&&(0,h.jsx)("button",{onClick:N,type:"button",className:"rounded border border-gray-300 px-3 py-1.5 text-sm hover:bg-gray-50",children:"Archive"}),(0,h.jsx)("button",{onClick:O,type:"button",className:"rounded border border-red-300 px-3 py-1.5 text-sm text-red-600 hover:bg-red-50",children:"Delete"})]})]})}let b=(0,s.A)(function(){var e=(0,n.useRouter)(),t=e.query.id;return t?(0,h.jsx)(a.A,{children:(0,h.jsx)("div",{className:"container mx-auto py-4 sm:py-6 md:py-8",children:(0,h.jsx)(v,{c
1ourseId:t,onChange:function(){return e.replace(e.asPath)}})})}):(0,h.jsx)(a.A,{children:(0,h.jsx)("div",{className:"container mx-auto py-4 sm:py-6 md:py-8",children:(0,h.jsx)("div",{className:"text-gray-500",children:"Loadingâ¦"})})})})},30842:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/courses/[id]",function(){return r(39600)}])}},e=>{var t=t=>e(e.s=t);e.O(0,[9965,3158,4491,636,6593,8792],()=>t(30842)),_N_E=e.O()}]);
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.