2 lines
32 KiB
JavaScript
2 lines
32 KiB
JavaScript
|
(this.webpackJsonpplannaplan=this.webpackJsonpplannaplan||[]).push([[0],{113:function(e,n,t){"use strict";t.r(n);var r,a=t(0),o=t.n(a),c=t(10),i=t.n(c),l=t(9),u=t(5),s=t(65),d=t.n(s),p=t(66),f=t.n(p),b=t(67),m=t.n(b),v=t(68),g=t.n(v),x=t(69),h=t.n(x),w=t(70),E=t.n(w),A=t(155),j=t(156),O=t(19),k=t.n(O),y=t(16),C=t(29),S=t(39),z=t.n(S),B=Object(a.createContext)(void 0),R=function(e){var n=e.children,t=Object(a.useState)(void 0),r=Object(l.a)(t,2),c=r[0],i=r[1];Object(a.useEffect)((function(){u()}),[]);var u=function(){var e=Object(C.a)(k.a.mark((function e(){var n,t,r,a,o;return k.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=new URLSearchParams(window.location.search),(t=n.get("ticket"))||window.location.replace("https://cas.amu.edu.pl/cas/login?service=".concat(window.origin,"&locale=pl")),e.prev=3,sessionStorage.getItem("userToken")){e.next=11;break}return e.next=7,z.a.get("".concat("http://localhost:1285","/token?ticket=").concat(t));case 7:r=e.sent,a=r.data,sessionStorage.setItem("userToken",a),i(Object(y.a)(Object(y.a)({},c),{},{token:a}));case 11:o=sessionStorage.getItem("userToken"),i(Object(y.a)(Object(y.a)({},c),{},{token:o})),e.next=18;break;case 15:e.prev=15,e.t0=e.catch(3),console.log(e.t0);case 18:case"end":return e.stop()}}),e,null,[[3,15]])})));return function(){return e.apply(this,arguments)}}();return o.a.createElement(B.Provider,{value:{user:c,logout:function(){window.location.replace("https://cas.amu.edu.pl/cas/logout?service=".concat(window.origin))}}},n)},I=function(e){var n=e.anchorEl,t=e.handleClose,r=Object(a.useContext)(B).logout;return o.a.createElement(A.a,{anchorEl:n,keepMounted:!0,open:Boolean(n),onClose:t},o.a.createElement(j.a,null,"Profile"),o.a.createElement(j.a,null,"My account"),o.a.createElement(j.a,{onClick:r},"Logout"))},T=t(153),P=t(148),F=t(18);!function(e){e.LECTURE="LECTURE",e.CLASS="CLASS"}(r||(r={}));var L=Object(a.createContext)(void 0),X=function(e){var n,t=e.children,c=Object(a.useState)([]),i=Object(l.a)(c,2),u=i[0],s=i[1],d=Object(a.useState)([]),p=Object(l.a)(d,2),f=p[0],b=p[1],m=Object(a.useContext)(B),v=null===m||void 0===m||null===(n=m.user)||void 0===n?void 0:n.token,g=function(){var e=Object(C.a)(k.a.mark((function e(){var n,t,r;return k.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n=[7,43,54],t=JSON.stringify(n),{json_data:t},e.next=6,z.a.post("".concat("http://localhost:1285","/api/v1/commisions/add?"),[7,43,54],{headers:{Authorization:"Bearer ".concat(v)}});case 6:r=e.sent,console.log("api response;",r),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(0),console.log(e.t0);case 13:console.log("saving to basket");case 14:case"end":return e.stop()}}),e,null,[[0,10]])})));return function(){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){(function(){var e=Object(C.a)(k.a.mark((function e(){var n,t,a;return k.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,z.a.get("".concat("http://localhost:1285","/api/v1/courses/getCoursesWithGroups"));case 2:n=e.sent,t=n.data,(a=t.map((function(e){var n=e.id,t=e.name,a=e.groups;return{id:parseInt(n),name:t,lectures:a.filter((function(e){return e.type===r.LECTURE})),classes:a.filter((function(e){return e.type===r.CLASS}))}}))).sort((function(e,n){return e.name>n.name?1:-1})),s(a);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}})()()}),[]),o.a.createElement(L.Provider,{value:{courses:u,basket:f,addToBasket:function(e){var n={name:e.name,id:e.id,classes:e.classes[0],lecture:void 0!==e.lectures?e.lectures[0]:void 0};b([].concat(Object(F.a)(f),[n]))},addGroup:function(e,n){var t=f.filter((function(e){return e.id===n}))[0],a=e.type;a===r.CLASS?b(f.map((function(n){return n.id===t.id?Object(y.a)(Object(y.a)({},n),{},{classes:e}):n}))):a===r.LECTURE&&b(f.map((function(n){return n.id===t.id?Object(y.a)(Object(y.a)({},n),{},{lecture:e}):n})))},deleteFromBasket:function(e){return b(f.filter((function(n){return n.id!==e})))},saveBasket:g}},t)},H=t(3),Y=t(147);function W(){var e=Object(u.a)(["\n position: relativ
|
||
|
//# sourceMappingURL=main.993a2e72.chunk.js.map
|