(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-8aa1f354"],{"0c81":function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"f",(function(){return a})),n.d(t,"e",(function(){return o})),n.d(t,"d",(function(){return i})),n.d(t,"c",(function(){return s})),n.d(t,"g",(function(){return c})),n.d(t,"a",(function(){return u}));var r=function(e){return"".concat(e," har blivit tillagt!")},a=function(e){return"".concat(e," sparades!")},o="Något gick fel!",i="Din åtgärd har blivit raderad!",s="Är du säker?",c="Ja",u="Avbryt"},"129f":function(e,t){e.exports=Object.is||function(e,t){return e===t?0!==e||1/e===1/t:e!=e&&t!=t}},5530:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));n("b64b"),n("a4d3"),n("4de4"),n("e439"),n("159b"),n("dbb4");var r=n("ade3");function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r={limit:t,skip:e?e-1:null,search:n};return o.a.get("/companies",{params:r})},addCompany:function(e){return o.a.post("/companies",Object(r["a"])({},e))},updateCompany:function(e){return o.a.put("/companies",Object(r["a"])({},e))},deleteCompany:function(e){return o.a.delete("/companies/".concat(e))}}},b8f6:function(e,t,n){"use strict";n("7d50")},bb2f:function(e,t,n){var r=n("d039");e.exports=!r((function(){return Object.isExtensible(Object.preventExtensions({}))}))},bce3:function(e,t,n){"use strict";var r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("paginate",{attrs:{"page-count":e.totalPages,"prev-text":e.arrow,"next-text":e.arrow,"prev-class":"prev","next-class":"next",value:e.currentPage,"click-handler":e.onPageChanged,"container-class":"vue-pagination"}})],1)},a=[],o={props:["totalPages","currentPage"],computed:{arrow:function(){return'\n \n \n \n '}},methods:{onPageChanged:function(e){this.$emit("pageChanged",e)}}},i=o,s=(n("b8f6"),n("2877")),c=Object(s["a"])(i,r,a,!1,null,null,null);t["a"]=c.exports},c8e6:function(e,t,n){"use strict";n.r(t);var r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"companies"},[e.showModal?n("app-modal",{on:{close:function(t){e.showModal=!1,e.editCompany=!1}}},[n("edit-company",{attrs:{"edit-company":e.editCompany},on:{companyChanged:e.onCompanyChanged}})],1):e._e(),n("h1",{staticClass:"section-header"},[e._v("Företag")]),n("div",{staticClass:"row justify-content-between mt-4"},[n("div",{staticClass:"row col-md-8"},[n("input-field",{staticClass:"col-md-3",attrs:{placeholder:"Sök ..."},on:{input:e.searchCompanies},model:{value:e.search,callback:function(t){e.search=t},expression:"search"}})],1),n("app-button",{staticClass:"btn--secondary mr-3",on:{click:function(t){e.showModal=!0}}},[e._v("Lägg till företag")])],1),n("div",{staticClass:"box box--outline mt-3"},[n("app-table",{attrs:{head:e.head}},e._l(e.companies,(function(t,r){return n("tr",{key:r},[n("td",{staticClass:"link-cell",on:{click:function(n){return e.openEditCompanyPopup(t)}}},[e._v(e._s(t.name))]),n("td",[e._v(e._s(t.contactPerson))]),n("td",[e._v(e._s(t.email))]),n("td",[e._v(e._s(t.phone))])])})),0)],1),n("div",{staticClass:"d-flex justify-content-end mt-5"},[n("app-pagination",{attrs:{"current-page":e.currentPage,"total-pages":e.totalPages},on:{pageChanged:e.onPageChanged}})],1)],1)},a=[],o=n("1da1"),i=(n("ac1f"),n("841c"),n("96cf"),n("a947")),s=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"edit-company"},[n("h1",{staticClass:"section-header"},[e._v("Företagsinformation")]),n("validation-observer",{ref:"companyForm",scopedSlots:e._u([{key:"default",fn:function(t){var r=t.validated;return[n("div",{staticClass:"row mt-5"},[n("validation-provider",{staticClass:"col-md-6",attrs:{rules:"required"},scopedSlots:e._u([{key:"default",fn:function(t){var a=t.invalid;return[n("input-field",{class:{error:a&&r},attrs:{label:"Företagsnamn*"},model:{value:e.form.name,callback:function(t){e.$set(e.form,"name",t)},expression:"form.name"}})]}}],null,!0)})],1),n("div",{staticClass:"row mt-5"},[n("validation-provider",{staticClass:"col-md-6",attrs:{rules:"required"},scopedSlots:e._u([{key:"default",fn:function(t){var a=t.invalid;return[n("input-field",{class:{error:a&&r},attrs:{label:"Adress*"},model:{value:e.form.address,callback:function(t){e.$set(e.form,"address",t)},expression:"form.address"}})]}}],null,!0)}),n("validation-provider",{staticClass:"col-md-6",attrs:{rules:"required"},scopedSlots:e._u([{key:"default",fn:function(t){var a=t.invalid;return[n("input-field",{class:{error:a&&r},attrs:{label:"Postnummer*"},model:{value:e.form.zipcode,callback:function(t){e.$set(e.form,"zipcode",t)},expression:"form.zipcode"}})]}}],null,!0)}),n("validation-provider",{staticClass:"col-md-6 mt-3",attrs:{rules:"required"},scopedSlots:e._u([{key:"default",fn:function(t){var a=t.invalid;return[n("input-field",{class:{error:a&&r},attrs:{label:"Ort*"},model:{value:e.form.city,callback:function(t){e.$set(e.form,"city",t)},expression:"form.city"}})]}}],null,!0)})],1),n("div",{staticClass:"row mt-5"},[n("validation-provider",{staticClass:"col-md-6",attrs:{rules:"required"},scopedSlots:e._u([{key:"default",fn:function(t){var a=t.invalid;return[n("input-field",{class:{error:a&&r},attrs:{label:"Kontaktperson*"},model:{value:e.form.contactPerson,callback:function(t){e.$set(e.form,"contactPerson",t)},expression:"form.contactPerson"}})]}}],null,!0)})],1),n("div",{staticClass:"row mt-3"},[n("div",{staticClass:"col-md-6"},[n("input-field",{attrs:{label:"Telefonnummer"},model:{value:e.form.phone,callback:function(t){e.$set(e.form,"phone",t)},expression:"form.phone"}})],1),n("div",{staticClass:"col-md-6"},[n("input-field",{attrs:{label:"E-post"},model:{value:e.form.email,callback:function(t){e.$set(e.form,"email",t)},expression:"form.email"}})],1)])]}}])}),n("div",{staticClass:"d-flex justify-content-end mt-5"},[e.editCompany?n("app-button",{staticClass:"btn--red mr-3",on:{click:e.deleteCompany}},[e._v("Radera")]):e._e(),n("app-button",{staticClass:"btn--secondary",on:{click:e.addCompany}},[e._v(" "+e._s(e.editCompany?"Spara":"Lägg till")+" ")])],1)],1)},c=[],u=n("0c81"),l=n("7c69"),d={props:["editCompany"],data:function(){return{form:{name:"",address:"",city:"",zipcode:"",contactPerson:"",phone:"",email:""},loading:!1}},methods:{addCompany:function(){var e=this;return Object(o["a"])(regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,e.$refs.companyForm.validate();case 2:if(n=t.sent,n){t.next=5;break}return t.abrupt("return");case 5:if(t.prev=5,e.loading=!0,!e.editCompany){t.next=13;break}return t.next=10,i["a"].updateCompany(e.form);case 10:e.$notify.success(Object(u["f"])("Företaget")),t.next=16;break;case 13:return t.next=15,i["a"].addCompany(e.form);case 15:e.$notify.success(Object(u["b"])("Företaget"));case 16:e.$emit("companyChanged"),t.next=23;break;case 19:t.prev=19,t.t0=t["catch"](5),r=Object(l["a"])(t.t0),e.$notify.error(r);case 23:return t.prev=23,e.loading=!1,t.finish(23);case 26:case"end":return t.stop()}}),t,null,[[5,19,23,26]])})))()},deleteCompany:function(){var e=this;return Object(o["a"])(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.$confirm("",u["c"],{confirmButtonText:u["g"],cancelButtonText:u["a"],type:"warning"});case 3:t.next=8;break;case 5:return t.prev=5,t.t0=t["catch"](0),t.abrupt("return");case 8:return t.prev=8,t.next=11,i["a"].deleteCompany(e.form._id);case 11:e.$notify.success("Företaget raderades!"),e.$emit("companyChanged"),t.next=17;break;case 15:t.prev=15,t.t1=t["catch"](8);case 17:case"end":return t.stop()}}),t,null,[[0,5],[8,15]])})))()}},created:function(){this.editCompany&&Object.assign(this.form,this.editCompany)}},f=d,p=n("2877"),m=Object(p["a"])(f,s,c,!1,null,"5163ff58",null),v=m.exports,g=n("bce3"),b={components:{AppPagination:g["a"],EditCompany:v},data:function(){return{showModal:!1,companies:[],totalPages:0,currentPage:1,search:null,editCompany:null,head:[{name:"Företagsnamn"},{name:"Kontaktperson"},{name:"E-post"},{name:"Telefonnummer"}]}},methods:{onCompanyChanged:function(){var e=this;return Object(o["a"])(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,e.getCompanies();case 2:e.showModal=!1,e.editCompany=null;case 4:case"end":return t.stop()}}),t)})))()},getCompanies:function(){var e=this;return Object(o["a"])(regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,i["a"].getCompanies(e.currentPage,10,e.search);case 3:n=t.sent,r=n.companies,a=n.totalCount,e.companies=r,e.totalPages=Math.ceil(a/10),t.next=12;break;case 10:t.prev=10,t.t0=t["catch"](0);case 12:case"end":return t.stop()}}),t,null,[[0,10]])})))()},openEditCompanyPopup:function(e){this.editCompany=e,this.showModal=!0},onPageChanged:function(e){this.currentPage=e,this.getCompanies()},searchCompanies:function(){this.currentPage=1,this.getCompanies()}},created:function(){var e=this;return Object(o["a"])(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,e.getCompanies();case 2:case"end":return t.stop()}}),t)})))()}},h=b,C=Object(p["a"])(h,r,a,!1,null,"dd67b62a",null);t["default"]=C.exports},dca8:function(e,t,n){var r=n("23e7"),a=n("bb2f"),o=n("d039"),i=n("861d"),s=n("f183").onFreeze,c=Object.freeze,u=o((function(){c(1)}));r({target:"Object",stat:!0,forced:u,sham:!a},{freeze:function(e){return c&&i(e)?c(s(e)):e}})},f183:function(e,t,n){var r=n("d012"),a=n("861d"),o=n("5135"),i=n("9bf2").f,s=n("90e3"),c=n("bb2f"),u=s("meta"),l=0,d=Object.isExtensible||function(){return!0},f=function(e){i(e,u,{value:{objectID:"O"+ ++l,weakData:{}}})},p=function(e,t){if(!a(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!o(e,u)){if(!d(e))return"F";if(!t)return"E";f(e)}return e[u].objectID},m=function(e,t){if(!o(e,u)){if(!d(e))return!0;if(!t)return!1;f(e)}return e[u].weakData},v=function(e){return c&&g.REQUIRED&&d(e)&&!o(e,u)&&f(e),e},g=e.exports={REQUIRED:!1,fastKey:p,getWeakData:m,onFreeze:v};r[u]=!0}}]); //# sourceMappingURL=chunk-8aa1f354.f0ad5771.js.map