(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-1fda221e"],{"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 i})),n.d(t,"d",(function(){return o})),n.d(t,"c",(function(){return c})),n.d(t,"g",(function(){return s})),n.d(t,"a",(function(){return l}));var r=function(e){return"".concat(e," har blivit tillagt!")},a=function(e){return"".concat(e," sparades!")},i="Något gick fel!",o="Din åtgärd har blivit raderad!",c="Är du säker?",s="Ja",l="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 i}));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 i(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o={limit:n,skip:t?t-1:null,search:r,bindStatus:e,company:i};return a.a.get("/boxes",{params:o})},addBox:function(e){return a.a.post("/boxes",e)},setBoxToVehicleLink:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"bind";return a.a.put("/vehicles/".concat(e,"/").concat(r,"/box/").concat(t,"?company=").concat(n))},deleteBox:function(e){return a.a.delete("/boxes/".concat(e))}}},"7c69":function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return o}));n("dca8");var r=Object.freeze({UNKNOWN_ERROR:"Hoppsan! Något gick fel, försök igen!",INVALID_CREDENTIALS:"Fel inloggningsuppgifter!",BOX_ALREADY_EXISTS:"Detta IMEI-nummer finns redan i bruk!",VEHICLE_ALREADY_EXISTS:"Detta fordon finns redan!",USER_ALREADY_EXISTS:"Denna e-post används redan som användarnamn!",COMPANY_ALREADY_EXISTS:"Detta företag finns redan!",PASSWORD_RESET_SUCCESS:"En återställningslänk har skickats till din e-post!",BOX_DELETED:"Enheten togs bort!",SOMETHING_WENT_WRONG:"Hoppsan! Något gick fel, försök igen!"}),a=Object.freeze({ERR_0000:r.UNKNOWN_ERROR,ERR_0001:r.INVALID_CREDENTIALS,ERR_0002:r.BOX_ALREADY_EXISTS,ERR_0003:r.VEHICLE_ALREADY_EXISTS,ERR_0004:r.USER_ALREADY_EXISTS,ERR_0005:r.COMPANY_ALREADY_EXISTS}),i=function(e){return a[e]?a[e]:r.UNKNOWN_ERROR},o=function(e){var t=null===e||void 0===e?void 0:e.response.data,n=t.drivelogErrorCode;return i(n)}},"7d50":function(e,t,n){},"7db0":function(e,t,n){"use strict";var r=n("23e7"),a=n("b727").find,i=n("44d2"),o="find",c=!0;o in[]&&Array(1)[o]((function(){c=!1})),r({target:"Array",proto:!0,forced:c},{find:function(e){return a(this,e,arguments.length>1?arguments[1]:void 0)}}),i(o)},"841c":function(e,t,n){"use strict";var r=n("d784"),a=n("825a"),i=n("1d80"),o=n("129f"),c=n("14c3");r("search",1,(function(e,t,n){return[function(t){var n=i(this),r=void 0==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](String(n))},function(e){var r=n(t,e,this);if(r.done)return r.value;var i=a(e),s=String(this),l=i.lastIndex;o(l,0)||(i.lastIndex=0);var u=c(i,s);return o(i.lastIndex,l)||(i.lastIndex=l),null===u?-1:u.index}]}))},a947:function(e,t,n){"use strict";var r=n("5530"),a=n("bc3a"),i=n.n(a);t["a"]={getCompanies:function(){var e=arguments.length>0&&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 i.a.get("/companies",{params:r})},addCompany:function(e){return i.a.post("/companies",Object(r["a"])({},e))},updateCompany:function(e){return i.a.put("/companies",Object(r["a"])({},e))},deleteCompany:function(e){return i.a.delete("/companies/".concat(e))}}},b0c0:function(e,t,n){var r=n("83ab"),a=n("9bf2").f,i=Function.prototype,o=i.toString,c=/^\s*function ([^ (]*)/,s="name";r&&!(s in i)&&a(i,s,{configurable:!0,get:function(){try{return o.call(this).match(c)[1]}catch(e){return""}}})},b1d7: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",[e.showModal?n("app-modal",{on:{close:function(t){e.showModal=!1,e.editVehicle=null}}},[n("add-vehicle",{attrs:{"edit-vehicle":e.editVehicle,isCompanyAdmin:e.isCompanyAdmin,companies:e.companies},on:{vehicleChanged:e.onVehicleChanged}})],1):e._e(),n("h1",{staticClass:"section-header"},[e._v("Fordon")]),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.searchVehicles},model:{value:e.search,callback:function(t){e.search=t},expression:"search"}}),e.isCompanyAdmin?e._e():n("v-select",{staticClass:"col-md-4 mt-2",attrs:{reduce:function(e){return e._id},options:e.companies,label:"name",placeholder:"Företag"},on:{input:e.searchVehicles},model:{value:e.company,callback:function(t){e.company=t},expression:"company"}})],1),n("app-button",{staticClass:"btn--secondary mr-3",on:{click:function(t){e.showModal=!0}}},[e._v("Lägg till fordon")])],1),n("div",{staticClass:"box box--outline mt-3"},[n("app-table",{attrs:{head:e.head}},e._l(e.vehicles,(function(t,r){return n("tr",{key:r},[n("td",{staticClass:"link-cell",on:{click:function(n){return e.openEditVehicle(t)}}},[e._v(e._s(t.licencePlate)+" ("+e._s(e.vehicleType(t.vehicleCategory))+") ")]),n("td",[e._v(e._s(t.brand)+" "+e._s(t.model)+" "+e._s(t.fuelType))]),e.isCompanyAdmin?e._e():n("td",[e._v(e._s(t.company.name))]),e.isCompanyAdmin&&t.user?n("td",[e._v(e._s(t.user.firstname)+" "+e._s(t.user.lastname))]):e._e(),n("td",[e._v(e._s(t.boxId))]),n("td",[t.user.email?n("span",{staticClass:"table-icon"},[n("app-icon",{staticClass:"active-icon",attrs:{name:"checkmark"}})],1):e._e()])])})),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=[],i=n("1da1"),o=(n("ac1f"),n("841c"),n("7db0"),n("b0c0"),n("96cf"),n("bb26")),c=n("a947"),s=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"add-vehicle"},[n("h1",{staticClass:"section-header"},[e._v("Fordonsinformation")]),n("validation-observer",{ref:"vehicleForm",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:{disabled:!!e.editVehicle,label:"Reg.nr*"},model:{value:e.form.licencePlate,callback:function(t){e.$set(e.form,"licencePlate",t)},expression:"form.licencePlate"}})]}}],null,!0)}),e.isCompanyAdmin?e._e():n("validation-provider",{staticClass:"col-md-6 select-item",attrs:{rules:"required"},scopedSlots:e._u([{key:"default",fn:function(t){var a=t.invalid;return[n("label",{staticClass:"mb-2"},[e._v("Företag*")]),n("v-select",{class:{error:a&&r},attrs:{disabled:!!e.editVehicle,reduce:function(e){return e._id},options:e.companies,label:"name"},model:{value:e.form.company,callback:function(t){e.$set(e.form,"company",t)},expression:"form.company"}})]}}],null,!0)})],1),n("div",{staticClass:"row mt-5"},[n("validation-provider",{staticClass:"col-md-6 select-item",attrs:{rules:"required"},scopedSlots:e._u([{key:"default",fn:function(t){var a=t.invalid;return[n("label",{staticClass:"mb-2"},[e._v("Märke*")]),n("v-select",{class:{error:a&&r},attrs:{options:e.makers},model:{value:e.form.brand,callback:function(t){e.$set(e.form,"brand",t)},expression:"form.brand"}})]}}],null,!0)}),n("validation-provider",{staticClass:"col-md-6 select-item",attrs:{rules:"required"},scopedSlots:e._u([{key:"default",fn:function(t){var a=t.invalid;return[n("label",{staticClass:"mb-2"},[e._v("Modell*")]),n("v-select",{class:{error:a&&r},attrs:{options:e.models},scopedSlots:e._u([{key:"no-options",fn:function(){return[e._v("Inga tillgängliga val.")]},proxy:!0}],null,!0),model:{value:e.form.model,callback:function(t){e.$set(e.form,"model",t)},expression:"form.model"}})]}}],null,!0)}),n("validation-provider",{staticClass:"col-md-6 mt-4 select-item",attrs:{rules:"required"},scopedSlots:e._u([{key:"default",fn:function(t){var a=t.invalid;return[n("label",{staticClass:"mb-2"},[e._v("Bränsle*")]),n("v-select",{class:{error:a&&r},attrs:{options:e.fuelTypes},model:{value:e.form.fuelType,callback:function(t){e.$set(e.form,"fuelType",t)},expression:"form.fuelType"}})]}}],null,!0)})],1),n("div",{staticClass:"row mt-5"},[n("div",{staticClass:"col-md-6 select-item"},[n("label",{staticClass:"mb-2"},[e._v("Enheter")]),n("v-select",{attrs:{reduce:function(e){return e.boxId},options:e.allowedBoxes,label:"boxId"},scopedSlots:e._u([{key:"no-options",fn:function(){return[e._v("Inga tillgängliga val.")]},proxy:!0}],null,!0),model:{value:e.form.boxId,callback:function(t){e.$set(e.form,"boxId",t)},expression:"form.boxId"}})],1),n("div",{staticClass:"col-md-5"},[n("input-field",{attrs:{"append-content":"km",label:"Nuvarande mätarställning"},model:{value:e.form.startMileage,callback:function(t){e.$set(e.form,"startMileage",t)},expression:"form.startMileage"}})],1)])]}}])}),n("div",{staticClass:"d-flex justify-content-end mt-5"},[e.editVehicle?n("app-button",{staticClass:"btn--red mr-3",on:{click:e.deleteVehicle}},[e._v("Radera")]):e._e(),n("app-button",{staticClass:"btn--secondary",attrs:{loading:e.loading},on:{click:e.addVehicle}},[e.editVehicle?[e._v("Spara")]:[e._v("Lägg till")]],2)],1)],1)},l=[],u=(n("caad"),n("2532"),n("4de4"),n("5962")),d=n("0c81"),f=(n("159b"),n("b64b"),n("7c69")),p={props:["companies","isCompanyAdmin","editVehicle"],data:function(){return{form:{brand:null,model:null,fuelType:null,startMileage:"",licencePlate:"",company:null,boxId:null},fuelTypes:["Bensin","Diesel","El","Hybrid"],boxes:[],loading:!1,makers:[],models:[]}},watch:{"form.brand":{immediate:!0,handler:function(e){var t=this;return Object(i["a"])(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:if(e){n.next=5;break}t.models=[],t.form.model=null,n.next=8;break;case 5:return n.next=7,t.getModels(e);case 7:t.models.includes(t.form.model)||(t.form.model=null);case 8:case"end":return n.stop()}}),n)})))()}}},computed:{user:function(){return this.$store.state.user},allowedBoxes:function(){var e=this;return this.isCompanyAdmin?this.boxes.filter((function(t){return t.company._id===e.user.company})):this.boxes.filter((function(t){return t.company._id===e.form.company}))}},methods:{addVehicle:function(){var e=this;return Object(i["a"])(regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.$refs.vehicleForm.validate();case 3:if(n=t.sent,n){t.next=6;break}return t.abrupt("return");case 6:if(e.loading=!0,!e.editVehicle){t.next=13;break}return t.next=10,o["a"].updateVehicle(e.form);case 10:e.$notify.success(Object(d["f"])("Fordonet")),t.next=16;break;case 13:return t.next=15,o["a"].addVehicle(e.form);case 15:e.$notify.success(Object(d["b"])("Fordonet"));case 16:e.$emit("vehicleChanged"),t.next=23;break;case 19:t.prev=19,t.t0=t["catch"](0),r=Object(f["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,[[0,19,23,26]])})))()},deleteVehicle:function(){var e=this;return Object(i["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("",d["c"],{confirmButtonText:d["g"],cancelButtonText:d["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,o["a"].deleteVehicle(e.form.licencePlate);case 11:e.$notify.success("Fordonet togs bort!"),e.$emit("vehicleChanged"),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]])})))()},getMakers:function(){var e=this;return Object(i["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,o["a"].getMakers();case 3:e.makers=t.sent,t.next=8;break;case 6:t.prev=6,t.t0=t["catch"](0);case 8:case"end":return t.stop()}}),t,null,[[0,6]])})))()},getModels:function(e){var t=this;return Object(i["a"])(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,o["a"].getModelsForMake(e);case 3:t.models=n.sent,n.next=8;break;case 6:n.prev=6,n.t0=n["catch"](0);case 8:case"end":return n.stop()}}),n,null,[[0,6]])})))()}},created:function(){var e,t=this;this.editVehicle&&(Object.assign(this.form,this.editVehicle),this.form.company=null===(e=this.editVehicle.company)||void 0===e?void 0:e._id);u["a"].getBoxes("unbound").then((function(e){var n=e.boxes;t.boxes=n})),this.getMakers()}},m=p,v=(n("c98e"),n("2877")),h=Object(v["a"])(m,s,l,!1,null,"15932190",null),b=h.exports,g=n("5627"),x=n("bce3"),y={components:{AppPagination:x["a"],AddVehicle:b},data:function(){return{head:[{name:"Reg.nr"},{name:"Fordon"},{name:"Företag"},{name:"Enheter"},{name:""}],vehicles:[],companies:[],currentPage:1,totalPages:1,editVehicle:null,showModal:!1,search:null,company:null}},computed:{isCompanyAdmin:function(){return this.$store.getters.isCompanyAdmin}},methods:{getCompanies:function(){var e=this;return Object(i["a"])(regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,c["a"].getCompanies();case 3:n=t.sent,r=n.companies,e.companies=r,t.next=11;break;case 8:t.prev=8,t.t0=t["catch"](0),e.$notify.error("Error fetching companies");case 11:case"end":return t.stop()}}),t,null,[[0,8]])})))()},getVehicles:function(){var e=this;return Object(i["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,o["a"].getVehicles({limit:10,page:e.currentPage,search:e.search,company:e.company});case 3:n=t.sent,r=n.vehicles,a=n.totalCount,e.vehicles=r,e.totalPages=Object(g["a"])(a),t.next=13;break;case 10:t.prev=10,t.t0=t["catch"](0),e.$notify.error("Error fetching vehicles");case 13:case"end":return t.stop()}}),t,null,[[0,10]])})))()},getCompanyName:function(e){var t=this.companies.find((function(t){return t._id===e}));return t?null===t||void 0===t?void 0:t.name:""},onVehicleChanged:function(){this.getVehicles(),this.editVehicle=null,this.showModal=!1},searchVehicles:function(){this.currentPage=1,this.getVehicles()},onPageChanged:function(e){this.currentPage=e,this.getVehicles()},openEditVehicle:function(e){this.editVehicle=e,this.showModal=!0},vehicleType:function(e){return e?"business"===e?"Företagsbil":"Förmånsbil":"Företagsbil"}},created:function(){var e=this;return Object(i["a"])(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(e.isCompanyAdmin){t.next=3;break}return t.next=3,e.getCompanies();case 3:return e.isCompanyAdmin&&(e.head[2]={name:"Användare"}),t.next=6,e.getVehicles();case 6:case"end":return t.stop()}}),t)})))()}},k=y,_=Object(v["a"])(k,r,a,!1,null,"0dcc57d8",null);t["default"]=_.exports},b8f6:function(e,t,n){"use strict";n("7d50")},bb26:function(e,t,n){"use strict";var r=n("5530"),a=(n("ac1f"),n("841c"),n("bc3a")),i=n.n(a);t["a"]={getVehicles:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.bindStatus,n=void 0===t?null:t,r=e.limit,a=void 0===r?null:r,o=e.page,c=void 0===o?null:o,s=e.search,l=void 0===s?null:s,u=e.company,d=void 0===u?null:u,f=e.boxBindStatus,p=void 0===f?null:f,m=e.includeDeleted,v=void 0===m?null:m;return c=c?c-1:null,i.a.get("/vehicles",{params:{bindStatus:n,limit:a,skip:c,search:l,company:d,boxBindStatus:p,includeDeleted:v}})},addVehicle:function(e){return i.a.post("/vehicles",Object(r["a"])({},e))},updateVehicle:function(e){return i.a.put("/vehicles",e)},deleteVehicle:function(e){return i.a.delete("/vehicles/".concat(e))},getMakers:function(){return i.a.get("/vehiclecodebook/make")},getModelsForMake:function(e){return i.a.get("/vehiclecodebook/make/".concat(e,"/model"))},getCurrentLocation:function(e){return i.a.get("vehicles/".concat(e,"/current-location"))}}},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=[],i={props:["totalPages","currentPage"],computed:{arrow:function(){return'\n \n \n \n '}},methods:{onPageChanged:function(e){this.$emit("pageChanged",e)}}},o=i,c=(n("b8f6"),n("2877")),s=Object(c["a"])(o,r,a,!1,null,null,null);t["a"]=s.exports},c98e:function(e,t,n){"use strict";n("e08b")},dca8:function(e,t,n){var r=n("23e7"),a=n("bb2f"),i=n("d039"),o=n("861d"),c=n("f183").onFreeze,s=Object.freeze,l=i((function(){s(1)}));r({target:"Object",stat:!0,forced:l,sham:!a},{freeze:function(e){return s&&o(e)?s(c(e)):e}})},e08b:function(e,t,n){},f183:function(e,t,n){var r=n("d012"),a=n("861d"),i=n("5135"),o=n("9bf2").f,c=n("90e3"),s=n("bb2f"),l=c("meta"),u=0,d=Object.isExtensible||function(){return!0},f=function(e){o(e,l,{value:{objectID:"O"+ ++u,weakData:{}}})},p=function(e,t){if(!a(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!i(e,l)){if(!d(e))return"F";if(!t)return"E";f(e)}return e[l].objectID},m=function(e,t){if(!i(e,l)){if(!d(e))return!0;if(!t)return!1;f(e)}return e[l].weakData},v=function(e){return s&&h.REQUIRED&&d(e)&&!i(e,l)&&f(e),e},h=e.exports={REQUIRED:!1,fastKey:p,getWeakData:m,onFreeze:v};r[l]=!0}}]); //# sourceMappingURL=chunk-1fda221e.ee7e87df.js.map