(this["webpackJsonpvem-frontend"]=this["webpackJsonpvem-frontend"]||[]).push([[0],{73:function(e,t,n){"use strict";n.r(t);var a=n(0),c=n.n(a),o=n(10),s=n(44),i=n(45),l=n(46),r=function(){function e(){var t=this;Object(s.a)(this,e),this.auth0=void 0,this.handleAuthentication=function(){t.auth0.parseHash({_idTokenVerification:!1},(function(e,n){n&&n.accessToken&&n.idToken&&t.setSession(n)}))},this.login=function(){t.auth0.authorize()},this.logout=function(){console.log("logout"),localStorage.removeItem("access_token"),localStorage.removeItem("expires_at"),window.location.reload(!0)},this.isAuthenticated=function(){if("undefined"===typeof localStorage)return!1;var e=JSON.parse(localStorage.getItem("expires_at")||"null");return"number"===typeof e&&(new Date).getTime()0}));v(t),r(!1)})).catch((function(e){console.log(e),b(e)}))}),[n]);var _=k(),E=Object(a.useCallback)((function(e){o(e.target.value)}),[o]);return Object(O.jsx)("div",{className:_.root,children:Object(O.jsx)(x.a,{position:"static",children:Object(O.jsxs)(N.a,{children:[Object(O.jsx)(S.a,{className:_.icon}),Object(O.jsx)(w.a,{variant:"h6",className:_.title,children:"Vem Frontend"}),n&&Object(O.jsxs)(O.Fragment,{children:[Object(O.jsxs)(I.a,{className:_.tenantSelector,native:!0,value:c,onChange:E,children:[Object(O.jsx)("option",{value:"",children:"Select a tenant"}),g&&g.map((function(e){return Object(O.jsx)("option",{value:e.name,children:e.name},e.name)}))]}),l&&Object(O.jsx)(y.a,{}),h&&Object(O.jsx)("p",{children:"COULD NOT LOAD TENANTS"}),Object(O.jsx)("div",{className:_.divider}),Object(O.jsx)(T.a,{onClick:t.logout,color:"inherit",children:"Logout"})]})]})})})},E=n(115),C=n(114),D=n(116),A=n(51),z=n.n(A),G=Object(p.a)((function(e){return Object(g.a)({emptyStateGrid:{minHeight:"40vh","& > * + *":{marginTop:e.spacing(2)}},emptyStateIcon:{fontSize:100,opacity:.8},emptyStateTitle:{color:"#777777"},emptyStateSubtitle:{color:"grey"}})})),F=function(e){var t=Object(a.useState)(!1),n=Object(u.a)(t,2),o=n[0],s=n[1],i=Object(a.useState)(localStorage.getItem("tenant")),l=Object(u.a)(i,2),r=l[0],j=l[1],d=e.auth;Object(a.useEffect)((function(){var e=d&&d.isAuthenticated();e||d.handleAuthentication(),s(e)}),[d]),Object(a.useEffect)((function(){null!==r&&localStorage.setItem("tenant",r)}),[r]);var h=G();return Object(O.jsxs)("div",{className:"app-root",children:[Object(O.jsx)(_,{auth:e.auth,authenticated:o,selectedTenant:r,setSelectedTenant:j}),Object(O.jsxs)(c.a.Fragment,{children:[Object(O.jsx)(C.a,{}),Object(O.jsx)(E.a,{maxWidth:"lg",style:{marginTop:"30px"},children:o&&null!==r?Object(O.jsx)(f,{selectedTenant:r}):Object(O.jsxs)(D.a,{className:h.emptyStateGrid,container:!0,spacing:0,direction:"column",alignItems:"center",justify:"center",children:[Object(O.jsx)(z.a,{className:h.emptyStateIcon}),Object(O.jsx)(w.a,{variant:"h4",className:h.emptyStateTitle,children:"Not Logged In"}),Object(O.jsx)(w.a,{variant:"subtitle1",className:h.emptyStateSubtitle,children:"Please login first."}),Object(O.jsx)(T.a,{variant:"outlined",color:"primary",onClick:function(){return localStorage.setItem("user_url",window.location.pathname),void d.login()},children:"Login"})]})})]})]})},L=new r;o.render(Object(O.jsx)(F,{auth:L}),document.getElementById("root"))}},[[73,1,2]]]); //# sourceMappingURL=main.b14ce8e3.chunk.js.map