(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-85c2295e"],{"13a2":function(t,e,s){"use strict";s.r(e);var i=function(){var t=this,e=t._self._c;return e("div",{staticStyle:{"min-height":"100vh"}},[e("section-title",{attrs:{title:"Mis preferencias"}}),t.isLoading?e("div",{staticClass:"row p-5"},[t._l(t.preferences,(function(s){return e("div",{key:s.id,staticClass:"col-md-2 text-center preference",class:[{opacity:s.selected}],on:{click:function(e){return t.editPreference(s)}}},[e("i",{class:s.icon,staticStyle:{"font-size":"2.5em"}}),e("p",[t._v(t._s(s.name))])])})),e("div",{staticClass:"col-md-12 text-right"},[e("button",{staticClass:"btn btn-success",on:{click:t.addPreferences}},[t._v("Guardar")])])],2):e("div",[e("v-container",[e("v-row",[e("v-col",{attrs:{cols:"12",md:"3"}},[e("v-skeleton-loader",{staticClass:"mx-auto",attrs:{type:"card","max-width":"300"}})],1),e("v-col",{attrs:{cols:"12",md:"3"}},[e("v-skeleton-loader",{staticClass:"mx-auto",attrs:{type:"card","max-width":"300"}})],1),e("v-col",{attrs:{cols:"12",md:"3"}},[e("v-skeleton-loader",{staticClass:"mx-auto",attrs:{type:"card","max-width":"300"}})],1),e("v-col",{attrs:{cols:"12",md:"3"}},[e("v-skeleton-loader",{staticClass:"mx-auto",attrs:{type:"card","max-width":"300"}})],1)],1),e("v-row",[e("v-col",{attrs:{cols:"12",md:"3"}},[e("v-skeleton-loader",{staticClass:"mx-auto",attrs:{type:"card","max-width":"300"}})],1),e("v-col",{attrs:{cols:"12",md:"3"}},[e("v-skeleton-loader",{staticClass:"mx-auto",attrs:{type:"card","max-width":"300"}})],1),e("v-col",{attrs:{cols:"12",md:"3"}},[e("v-skeleton-loader",{staticClass:"mx-auto",attrs:{type:"card","max-width":"300"}})],1),e("v-col",{attrs:{cols:"12",md:"3"}},[e("v-skeleton-loader",{staticClass:"mx-auto",attrs:{type:"card","max-width":"300"}})],1)],1)],1)],1)],1)},a=[],c=(s("14d9"),s("2b0e")),r=s("76bf"),l={name:"Preferences",components:{SectionTitle:r["a"]},data(){return{preferences:[],list:[],formData:[],list_init:[],isLoading:!1}},updated(){},created(){this.setPreferencesList(),this.listPreferences()},methods:{async listPreferences(){const t=await this.axios.get("category/list");if(200==t.status){const{data:e}=t.data,s=this.setSelected(e);this.preferences=s,this.isLoading=!0}},editPreference(t){if(t.selected=!t.selected,this.list.includes(t.id)){const e=this.list.indexOf(t.id);this.list.splice(e,1)}else this.list.push(t.id)},async addPreferences(){let t=[],e=[];this.list_init.forEach(t=>{this.list.includes(t)||e.push(t)}),this.list.forEach(e=>{this.list_init.includes(e)||t.push(e)}),this.list.length>=3?(this.isLoading=!1,0!=t.length&&this.toRegister(t,"save"),0!=e.length&&this.toRegister(e,"delete"),0==e.length&&0==t.length&&this.makeToast("success","No se ha realizado ningún cambio")):this.makeToast("danger","Debe seleccionar como mínimo 3 categorías")},async toRegister(t,e){let s={categorys:t};const i="save"==e?"/preferences/add":"/preferences/delete-preferences",a="save"==e?"registradas":"eliminadas",c=await this.axios.post(i,s);200===c.status?(this.makeToast("success","Categorías "+a+" correctamente"),this.setPreferencesList()):(this.makeToast("danger","Error al intentar registrar los cambios"),this.setPreferencesList())},setSelected(t){return t.forEach(t=>{c["default"].set(t,"selected",!0),this.list.forEach(e=>{e===t.id&&c["default"].set(t,"selected",!1)})}),t},async setPreferencesList(){const t=await this.axios.get("preferences/show-preferences");if(200==t.status){const{data:e}=t.data;this.list=[],this.list_init=[];for(let t=0;t<e.length;t++)this.list.includes(e[t].categories_id)||(this.list.push(e[t].categories_id),this.list_init.push(e[t].categories_id));this.preferences=this.setSelected(this.preferences),this.isLoading=!0}},makeToast(t,e){this.$bvToast.toast(e,{title:"Categorias",variant:t,toaster:"b-toaster-top-center",solid:!0})}}},o=l,n=(s("8ae9"),s("2877")),d=Object(n["a"])(o,i,a,!1,null,"4acf3ce8",null);e["default"]=d.exports},"44e3":function(t,e,s){},"529c":function(t,e,s){"use strict";s("44e3")},"76bf":function(t,e,s){"use strict";var i=function(){var t=this,e=t._self._c;return e("div",{staticClass:"row",staticStyle:{width:"50%"}},[e("div",{staticClass:"text-left px-5 mt-0 h-100 h2 section-title"},[e("div",{staticClass:"col-md-12 px-5"},[t._v(t._s(t.title))])])])},a=[],c={props:{title:{type:String,default:"Default-name"}}},r=c,l=(s("529c"),s("2877")),o=Object(l["a"])(r,i,a,!1,null,"7fa91053",null);e["a"]=o.exports},"8ae9":function(t,e,s){"use strict";s("cc6f")},cc6f:function(t,e,s){}}]);
//# sourceMappingURL=chunk-85c2295e.21a0b5a4.js.map