(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-ee778bec"],{"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("e9f5"),s("7d54"),s("2b0e")),r=s("76bf"),o={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})}}},n=o,l=(s("8ae9"),s("2877")),d=Object(l["a"])(n,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,o=(s("529c"),s("2877")),n=Object(o["a"])(r,i,a,!1,null,"7fa91053",null);e["a"]=n.exports},"7d54":function(t,e,s){"use strict";var i=s("23e7"),a=s("c65b"),c=s("2266"),r=s("59ed"),o=s("825a"),n=s("46c4"),l=s("2a62"),d=s("f99f"),h=d("forEach",TypeError);i({target:"Iterator",proto:!0,real:!0,forced:h},{forEach:function(t){o(this);try{r(t)}catch(i){l(this,"throw",i)}if(h)return a(h,this,t);var e=n(this),s=0;c(e,(function(e){t(e,s++)}),{IS_RECORD:!0})}})},"8ae9":function(t,e,s){"use strict";s("cc6f")},cc6f:function(t,e,s){}}]);
//# sourceMappingURL=chunk-ee778bec.47a4bcf7.js.map