"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _Header = _interopRequireDefault(require("./components/Header"));
var _elements = require("../../../elements");
var _reactNative = require("react-native");
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
var _icons = require("../../../../core/assets/icons");
var _Action = _interopRequireDefault(require("../shared/elements/Action"));
var _enums = require("../../../enums");
var _LeaveCommunity = _interopRequireDefault(require("./elements/LeaveCommunity/LeaveCommunity"));
var _CloseCommunity = _interopRequireDefault(require("./elements/CloseCommunity"));
var _CloseCommunityDescription = _interopRequireDefault(require("./elements/CloseCommunityDescription"));
var _permissions = require("../../../utils/permissions");
var _useCommunitySetting = require("./hooks/useCommunitySetting");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const CommunitySetting = ({
  community
}) => {
  const {
    styles,
    handleCloseCommunity,
    handleLeaveCommunity,
    handleEditCommunity,
    handleCommunityMembership,
    handleCommunityPostPermission,
    handleCommunityStorySetting,
    handleCommunityNotificationSetting,
    isNotificationEnabled,
    isNetworkNotificationsEnabled
  } = (0, _useCommunitySetting.useCommunitySetting)(community);
  return /*#__PURE__*/React.createElement(_reactNativeSafeAreaContext.SafeAreaView, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(_Header.default, {
    title: community === null || community === void 0 ? void 0 : community.displayName
  }), /*#__PURE__*/React.createElement(_reactNative.ScrollView, null, /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.titleContainer
  }, /*#__PURE__*/React.createElement(_elements.Title, null, "Community information")), (0, _permissions.checkEditCommunityPermission)(community.communityId) && /*#__PURE__*/React.createElement(_Action.default, {
    iconProps: {
      xml: (0, _icons.penFill)()
    },
    onPress: handleEditCommunity,
    elementId: _enums.ElementID.edit_profile,
    pageId: _enums.PageID.community_setting_page
  }), /*#__PURE__*/React.createElement(_Action.default, {
    iconProps: {
      xml: (0, _icons.member)()
    },
    elementId: _enums.ElementID.members,
    onPress: handleCommunityMembership,
    pageId: _enums.PageID.community_setting_page
  }), /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.divider
  }), (0, _permissions.checkEditCommunityPermission)(community.communityId) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.titleContainer
  }, /*#__PURE__*/React.createElement(_elements.Title, null, "Community permissions")), /*#__PURE__*/React.createElement(_Action.default, {
    onPress: handleCommunityPostPermission,
    iconProps: {
      xml: (0, _icons.postPermission)()
    },
    elementId: _enums.ElementID.post_permission,
    pageId: _enums.PageID.community_setting_page
  }), /*#__PURE__*/React.createElement(_Action.default, {
    iconProps: {
      xml: (0, _icons.story)()
    },
    elementId: _enums.ElementID.story_setting,
    onPress: handleCommunityStorySetting,
    pageId: _enums.PageID.community_setting_page
  }), /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.divider
  })), isNetworkNotificationsEnabled && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.titleContainer
  }, /*#__PURE__*/React.createElement(_elements.Title, null, "Your preferences")), /*#__PURE__*/React.createElement(_Action.default, {
    description: isNotificationEnabled ? 'On' : 'Off',
    iconProps: {
      xml: (0, _icons.bell)()
    },
    elementId: _enums.ElementID.notifications,
    pageId: _enums.PageID.community_setting_page,
    onPress: handleCommunityNotificationSetting
  }), /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.divider
  })), (community === null || community === void 0 ? void 0 : community.isJoined) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_LeaveCommunity.default, {
    onPress: handleLeaveCommunity,
    pageId: _enums.PageID.community_setting_page
  })), (0, _permissions.checkDeleteCommunityPermission)(community.communityId) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.divider
  }), /*#__PURE__*/React.createElement(_CloseCommunity.default, {
    onPress: handleCloseCommunity,
    pageId: _enums.PageID.community_setting_page
  }), /*#__PURE__*/React.createElement(_CloseCommunityDescription.default, {
    pageId: _enums.PageID.community_setting_page
  }))));
};
var _default = exports.default = CommunitySetting;
//# sourceMappingURL=Setting.js.map