(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[35],{

/***/ "./src/views/Administradores/useNutriologos.js":
/*!*****************************************************!*\
  !*** ./src/views/Administradores/useNutriologos.js ***!
  \*****************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Users_ruben_Development_nutrifull_front_node_modules_babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator */ \"./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\");\n/* harmony import */ var regenerator_runtime_runtime_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! regenerator-runtime/runtime.js */ \"./node_modules/regenerator-runtime/runtime.js\");\n/* harmony import */ var regenerator_runtime_runtime_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(regenerator_runtime_runtime_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var core_js_modules_es_number_constructor_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/es.number.constructor.js */ \"./node_modules/core-js/modules/es.number.constructor.js\");\n/* harmony import */ var core_js_modules_es_number_constructor_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_number_constructor_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/es.function.name.js */ \"./node_modules/core-js/modules/es.function.name.js\");\n/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _vue_composition_api__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @vue/composition-api */ \"./node_modules/@vue/composition-api/dist/vue-composition-api.mjs\");\n/* harmony import */ var vue_toastification_composition__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! vue-toastification/composition */ \"./node_modules/vue-toastification/composition/index.js\");\n/* harmony import */ var vue_toastification_composition__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(vue_toastification_composition__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _core_components_toastification_ToastificationContent_vue__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @core/components/toastification/ToastificationContent.vue */ \"./src/@core/components/toastification/ToastificationContent.vue\");\n/* harmony import */ var _services_NutriologoService__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/services/NutriologoService */ \"./src/services/NutriologoService.js\");\n\n\n\n\n // Notification\n\n\n\n\n\nvar useNutriologos = function useNutriologos() {\n  var perPage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;\n  // Use toast\n  var toast = Object(vue_toastification_composition__WEBPACK_IMPORTED_MODULE_5__[\"useToast\"])();\n  var loading = Object(_vue_composition_api__WEBPACK_IMPORTED_MODULE_4__[\"ref\"])(false);\n  var changing = Object(_vue_composition_api__WEBPACK_IMPORTED_MODULE_4__[\"ref\"])(false);\n  var isSaving = Object(_vue_composition_api__WEBPACK_IMPORTED_MODULE_4__[\"ref\"])(false);\n  var fotoValida = Object(_vue_composition_api__WEBPACK_IMPORTED_MODULE_4__[\"ref\"])(true);\n  var fotoValidaL = Object(_vue_composition_api__WEBPACK_IMPORTED_MODULE_4__[\"ref\"])(true);\n  var perPageOptions = [10, 25, 50];\n  var statusFilter = Object(_vue_composition_api__WEBPACK_IMPORTED_MODULE_4__[\"ref\"])(null);\n  var isLoading = Object(_vue_composition_api__WEBPACK_IMPORTED_MODULE_4__[\"ref\"])(false);\n  var personalData = Object(_vue_composition_api__WEBPACK_IMPORTED_MODULE_4__[\"reactive\"])({\n    id: '',\n    name: '',\n    apellido1: '',\n    apellido2: '',\n    cat_sexo_id: '',\n    email: '',\n    foto: ''\n  });\n  var nutriologos = Object(_vue_composition_api__WEBPACK_IMPORTED_MODULE_4__[\"ref\"])([]);\n  var listQuery = Object(_vue_composition_api__WEBPACK_IMPORTED_MODULE_4__[\"reactive\"])({\n    total: 0,\n    per_page: perPage,\n    page: 1,\n    totalPages: 1,\n    query: '',\n    statusFilter: '',\n    deviceTypeFilter: '',\n    sort: 'asc',\n    sortBy: 'id',\n    from: 0,\n    to: 0\n  });\n  Object(_vue_composition_api__WEBPACK_IMPORTED_MODULE_4__[\"watch\"])(function () {\n    return listQuery.per_page;\n  }, function (currentValue, oldValue) {\n    return fetchList();\n  });\n  Object(_vue_composition_api__WEBPACK_IMPORTED_MODULE_4__[\"watch\"])(function () {\n    return listQuery.page;\n  }, function (currentValue, oldValue) {\n    return fetchList();\n  });\n  Object(_vue_composition_api__WEBPACK_IMPORTED_MODULE_4__[\"watch\"])(function () {\n    return listQuery.query;\n  }, function (currentValue, oldValue) {\n    return fetchList();\n  });\n  Object(_vue_composition_api__WEBPACK_IMPORTED_MODULE_4__[\"watch\"])(function () {\n    return listQuery.statusFilter;\n  }, function (n, old) {\n    return fetchList();\n  });\n\n  var fetchList = function fetchList() {\n    loading.value = true;\n    _services_NutriologoService__WEBPACK_IMPORTED_MODULE_7__[\"default\"].fetchListAdmin(listQuery).then(function (response) {\n      var _response$data$cuerpo = response.data.cuerpo,\n          data = _response$data$cuerpo.data,\n          total = _response$data$cuerpo.total,\n          from = _response$data$cuerpo.from,\n          to = _response$data$cuerpo.to,\n          last_page = _response$data$cuerpo.last_page,\n          per_page = _response$data$cuerpo.per_page;\n      listQuery.total = Number(total);\n      listQuery.from = Number(from);\n      listQuery.to = Number(to);\n      listQuery.totalPages = Number(last_page);\n      listQuery.per_page = Number(per_page);\n      nutriologos.value = data;\n      loading.value = false; // callback(response.data)\n    }).catch(function (e) {\n      loading.value = false;\n      toast({\n        component: _core_components_toastification_ToastificationContent_vue__WEBPACK_IMPORTED_MODULE_6__[\"default\"],\n        props: {\n          title: \"Error al cargar Nutriolgos\",\n          icon: 'AlertTriangleIcon',\n          variant: 'danger'\n        }\n      });\n    });\n  };\n\n  var changeStatus = /*#__PURE__*/function () {\n    var _ref = Object(_Users_ruben_Development_nutrifull_front_node_modules_babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__[\"default\"])( /*#__PURE__*/regeneratorRuntime.mark(function _callee(idPaciente) {\n      return regeneratorRuntime.wrap(function _callee$(_context) {\n        while (1) {\n          switch (_context.prev = _context.next) {\n            case 0:\n              changing.value = true;\n              _context.prev = 1;\n              _context.next = 4;\n              return _services_NutriologoService__WEBPACK_IMPORTED_MODULE_7__[\"default\"].changeStatusAdmin(idPaciente);\n\n            case 4:\n              changing.value = false;\n              _context.next = 11;\n              break;\n\n            case 7:\n              _context.prev = 7;\n              _context.t0 = _context[\"catch\"](1);\n              changing.value = false;\n              toast({\n                component: _core_components_toastification_ToastificationContent_vue__WEBPACK_IMPORTED_MODULE_6__[\"default\"],\n                props: {\n                  title: \"Error al Cambiar estatus\",\n                  icon: 'AlertTriangleIcon',\n                  variant: 'danger'\n                }\n              });\n\n            case 11:\n            case \"end\":\n              return _context.stop();\n          }\n        }\n      }, _callee, null, [[1, 7]]);\n    }));\n\n    return function changeStatus(_x) {\n      return _ref.apply(this, arguments);\n    };\n  }();\n\n  var changeStatusAdministrador = /*#__PURE__*/function () {\n    var _ref2 = Object(_Users_ruben_Development_nutrifull_front_node_modules_babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__[\"default\"])( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(id) {\n      return regeneratorRuntime.wrap(function _callee2$(_context2) {\n        while (1) {\n          switch (_context2.prev = _context2.next) {\n            case 0:\n              changing.value = true;\n              _context2.prev = 1;\n              _context2.next = 4;\n              return _services_NutriologoService__WEBPACK_IMPORTED_MODULE_7__[\"default\"].changeStatusAdmin(id);\n\n            case 4:\n              changing.value = false;\n              _context2.next = 11;\n              break;\n\n            case 7:\n              _context2.prev = 7;\n              _context2.t0 = _context2[\"catch\"](1);\n              changing.value = false;\n              toast({\n                component: _core_components_toastification_ToastificationContent_vue__WEBPACK_IMPORTED_MODULE_6__[\"default\"],\n                props: {\n                  title: \"Error al Cambiar estatus\",\n                  icon: 'AlertTriangleIcon',\n                  variant: 'danger'\n                }\n              });\n\n            case 11:\n            case \"end\":\n              return _context2.stop();\n          }\n        }\n      }, _callee2, null, [[1, 7]]);\n    }));\n\n    return function changeStatusAdministrador(_x2) {\n      return _ref2.apply(this, arguments);\n    };\n  }();\n\n  var getNutriologo = /*#__PURE__*/function () {\n    var _ref3 = Object(_Users_ruben_Development_nutrifull_front_node_modules_babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__[\"default\"])( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(idNutriologo) {\n      var response;\n      return regeneratorRuntime.wrap(function _callee3$(_context3) {\n        while (1) {\n          switch (_context3.prev = _context3.next) {\n            case 0:\n              isLoading.value = true;\n              _context3.prev = 1;\n              _context3.next = 4;\n              return _services_NutriologoService__WEBPACK_IMPORTED_MODULE_7__[\"default\"].getNutriologo(idNutriologo);\n\n            case 4:\n              response = _context3.sent;\n              Object.assign(personalData, response.data.cuerpo);\n              isLoading.value = false;\n              _context3.next = 13;\n              break;\n\n            case 9:\n              _context3.prev = 9;\n              _context3.t0 = _context3[\"catch\"](1);\n              isLoading.value = false;\n              throw _context3.t0;\n\n            case 13:\n            case \"end\":\n              return _context3.stop();\n          }\n        }\n      }, _callee3, null, [[1, 9]]);\n    }));\n\n    return function getNutriologo(_x3) {\n      return _ref3.apply(this, arguments);\n    };\n  }();\n\n  var getAdmins = /*#__PURE__*/function () {\n    var _ref4 = Object(_Users_ruben_Development_nutrifull_front_node_modules_babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__[\"default\"])( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(idNutriologo) {\n      var response;\n      return regeneratorRuntime.wrap(function _callee4$(_context4) {\n        while (1) {\n          switch (_context4.prev = _context4.next) {\n            case 0:\n              isLoading.value = true;\n              _context4.prev = 1;\n              _context4.next = 4;\n              return _services_NutriologoService__WEBPACK_IMPORTED_MODULE_7__[\"default\"].getAdmins(idNutriologo);\n\n            case 4:\n              response = _context4.sent;\n              Object.assign(personalData, response.data.cuerpo);\n\n              if (!personalData.cat_sexo_id) {\n                personalData.cat_sexo_id = '';\n              }\n\n              isLoading.value = false;\n              _context4.next = 14;\n              break;\n\n            case 10:\n              _context4.prev = 10;\n              _context4.t0 = _context4[\"catch\"](1);\n              isLoading.value = false;\n              throw _context4.t0;\n\n            case 14:\n            case \"end\":\n              return _context4.stop();\n          }\n        }\n      }, _callee4, null, [[1, 10]]);\n    }));\n\n    return function getAdmins(_x4) {\n      return _ref4.apply(this, arguments);\n    };\n  }();\n\n  var updateNutriologo = /*#__PURE__*/function () {\n    var _ref5 = Object(_Users_ruben_Development_nutrifull_front_node_modules_babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__[\"default\"])( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(id, data) {\n      var form, response;\n      return regeneratorRuntime.wrap(function _callee5$(_context5) {\n        while (1) {\n          switch (_context5.prev = _context5.next) {\n            case 0:\n              form = new FormData();\n              form.append('email', data.email);\n              form.append('name', data.name);\n              form.append('apellido1', data.apellido1);\n              form.append('apellido2', data.apellido2);\n              form.append('cat_sexo_id', data.cat_sexo_id ? data.cat_sexo_id : '');\n              form.append('especialidad', data.especialidad);\n              form.append('escuela', data.escuela);\n              form.append('fecha_nacimiento', data.fecha_nacimiento);\n              form.append('domicilioConsultorio', data.domicilioConsultorio); // form.append('_method', 'PUT');\n\n              if (data.fileFoto != null) {\n                form.append('foto', data.fileFoto);\n              }\n\n              if (data.fileLogo != null) {\n                form.append('logo', data.fileLogo);\n              }\n\n              isSaving.value = true;\n\n              if (!(fotoValida.value == true && fotoValidaL.value)) {\n                _context5.next = 30;\n                break;\n              }\n\n              _context5.prev = 14;\n              _context5.next = 17;\n              return _services_NutriologoService__WEBPACK_IMPORTED_MODULE_7__[\"default\"].updateNutriologo(id, form);\n\n            case 17:\n              response = _context5.sent;\n              isSaving.value = false;\n              toast({\n                component: _core_components_toastification_ToastificationContent_vue__WEBPACK_IMPORTED_MODULE_6__[\"default\"],\n                props: {\n                  title: \"Datos Guardados Correctamente!\",\n                  icon: 'CheckCircleIcon',\n                  variant: 'success'\n                }\n              });\n              return _context5.abrupt(\"return\", response);\n\n            case 23:\n              _context5.prev = 23;\n              _context5.t0 = _context5[\"catch\"](14);\n              isSaving.value = false;\n              toast({\n                component: _core_components_toastification_ToastificationContent_vue__WEBPACK_IMPORTED_MODULE_6__[\"default\"],\n                props: {\n                  title: \"Error al guardar\",\n                  icon: 'AlertTriangleIcon',\n                  variant: 'danger'\n                }\n              });\n              throw _context5.t0;\n\n            case 28:\n              _context5.next = 32;\n              break;\n\n            case 30:\n              isSaving.value = false;\n              toast({\n                component: _core_components_toastification_ToastificationContent_vue__WEBPACK_IMPORTED_MODULE_6__[\"default\"],\n                props: {\n                  title: \"El formato de imagen o el logo no es valido\",\n                  icon: 'AlertTriangleIcon',\n                  variant: 'danger'\n                }\n              });\n\n            case 32:\n            case \"end\":\n              return _context5.stop();\n          }\n        }\n      }, _callee5, null, [[14, 23]]);\n    }));\n\n    return function updateNutriologo(_x5, _x6) {\n      return _ref5.apply(this, arguments);\n    };\n  }();\n\n  var updateAdmin = /*#__PURE__*/function () {\n    var _ref6 = Object(_Users_ruben_Development_nutrifull_front_node_modules_babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__[\"default\"])( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(id, data) {\n      var form, response;\n      return regeneratorRuntime.wrap(function _callee6$(_context6) {\n        while (1) {\n          switch (_context6.prev = _context6.next) {\n            case 0:\n              form = new FormData();\n              form.append('email', data.email);\n              form.append('name', data.name);\n              form.append('apellido1', data.apellido1);\n              form.append('apellido2', data.apellido2);\n              form.append('cat_sexo_id', data.cat_sexo_id ? data.cat_sexo_id : ''); //form.append('_method', 'PUT');\n\n              if (data.fileFoto != null) {\n                form.append('foto', data.fileFoto);\n              }\n\n              isSaving.value = true;\n\n              if (!(fotoValida.value == true)) {\n                _context6.next = 25;\n                break;\n              }\n\n              _context6.prev = 9;\n              _context6.next = 12;\n              return _services_NutriologoService__WEBPACK_IMPORTED_MODULE_7__[\"default\"].updateAdmin(id, form);\n\n            case 12:\n              response = _context6.sent;\n              isSaving.value = false;\n              toast({\n                component: _core_components_toastification_ToastificationContent_vue__WEBPACK_IMPORTED_MODULE_6__[\"default\"],\n                props: {\n                  title: \"Datos Guardados Correctamente!\",\n                  icon: 'CheckCircleIcon',\n                  variant: 'success'\n                }\n              });\n              return _context6.abrupt(\"return\", response);\n\n            case 18:\n              _context6.prev = 18;\n              _context6.t0 = _context6[\"catch\"](9);\n              isSaving.value = false;\n              toast({\n                component: _core_components_toastification_ToastificationContent_vue__WEBPACK_IMPORTED_MODULE_6__[\"default\"],\n                props: {\n                  title: \"Error al guardar\",\n                  icon: 'AlertTriangleIcon',\n                  variant: 'danger'\n                }\n              });\n              throw _context6.t0;\n\n            case 23:\n              _context6.next = 27;\n              break;\n\n            case 25:\n              isSaving.value = false;\n              toast({\n                component: _core_components_toastification_ToastificationContent_vue__WEBPACK_IMPORTED_MODULE_6__[\"default\"],\n                props: {\n                  title: \"El formato de imagen no es valido\",\n                  icon: 'AlertTriangleIcon',\n                  variant: 'danger'\n                }\n              });\n\n            case 27:\n            case \"end\":\n              return _context6.stop();\n          }\n        }\n      }, _callee6, null, [[9, 18]]);\n    }));\n\n    return function updateAdmin(_x7, _x8) {\n      return _ref6.apply(this, arguments);\n    };\n  }();\n\n  var resolveStatus = function resolveStatus(status) {\n    return status ? 'success' : 'danger';\n  };\n\n  return {\n    updateAdmin: updateAdmin,\n    getAdmins: getAdmins,\n    fotoValidaL: fotoValidaL,\n    fotoValida: fotoValida,\n    loading: loading,\n    listQuery: listQuery,\n    perPageOptions: perPageOptions,\n    fetchList: fetchList,\n    nutriologos: nutriologos,\n    resolveStatus: resolveStatus,\n    changeStatus: changeStatus,\n    changing: changing,\n    personalData: personalData,\n    isSaving: isSaving,\n    getNutriologo: getNutriologo,\n    updateNutriologo: updateNutriologo,\n    changeStatusAdministrador: changeStatusAdministrador\n  };\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (useNutriologos);\n\n//# sourceURL=webpack:///./src/views/Administradores/useNutriologos.js?");

/***/ })

}]);