"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _styles = _interopRequireDefault(require("./styles"));
var _reactNativeCloudCa = require("react-native-cloud-ca");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
const GetUsersProfileView = props => {
  const {
    goBack,
    headerProps
  } = props;
  const [isLoading, setIsLoading] = (0, _react.useState)(false);
  const [isShowError, setIsShowError] = (0, _react.useState)(false);
  const [errorResponse, setErrorResponse] = (0, _react.useState)('');
  const [userInfo, setUserInfo] = (0, _react.useState)();
  (0, _react.useEffect)(() => {
    (async () => {
      setIsLoading(true);
      try {
        const result = await (0, _reactNativeCloudCa.getUserProfile)();
        setUserInfo(result);
        setIsLoading(false);
      } catch (error) {
        setIsShowError(true);
        setErrorResponse(error === null || error === void 0 ? void 0 : error.message);
        setIsLoading(false);
      }
    })();
  }, []);
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: _styles.default.container
  }, /*#__PURE__*/_react.default.createElement(_reactNativeCloudCa.Header, _extends({}, headerProps, {
    label: "Th\xF4ng tin t\xE0i kho\u1EA3n",
    goBack: goBack
  })), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: _styles.default.contentContainer
  }, /*#__PURE__*/_react.default.createElement(_reactNativeCloudCa.InfoField, {
    title: "Lo\u1EA1i t\xE0i kho\u1EA3n",
    info: 'Doanh nghiệp'
  }), /*#__PURE__*/_react.default.createElement(_reactNativeCloudCa.InfoField, {
    title: "H\u1ECD v\xE0 t\xEAn",
    info: (userInfo === null || userInfo === void 0 ? void 0 : userInfo.user_name) || ''
  }), /*#__PURE__*/_react.default.createElement(_reactNativeCloudCa.InfoField, {
    title: "S\u1ED1 \u0111i\u1EC7n tho\u1EA1i",
    info: (userInfo === null || userInfo === void 0 ? void 0 : userInfo.user_mobile) || ''
  }), /*#__PURE__*/_react.default.createElement(_reactNativeCloudCa.InfoField, {
    title: "Email",
    info: (userInfo === null || userInfo === void 0 ? void 0 : userInfo.user_email) || ''
  }), /*#__PURE__*/_react.default.createElement(_reactNativeCloudCa.InfoField, {
    title: "\u0110\u1ECBa ch\u1EC9",
    info: ''
  })), /*#__PURE__*/_react.default.createElement(_reactNativeCloudCa.Dialogue, {
    modalType: "ERROR",
    onClose: () => setIsShowError(false),
    visible: isShowError
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
    style: _styles.default.contentStyle
  }, errorResponse)), isLoading && /*#__PURE__*/_react.default.createElement(_reactNativeCloudCa.Loading, null));
};
var _default = GetUsersProfileView;
exports.default = _default;
//# sourceMappingURL=GetUsersProfileView.js.map