import Header from './components/Header';
import { Title } from '../../../elements';
import { View, ScrollView } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { bell, member, penFill, postPermission, story } from '../../../../core/assets/icons';
import Action from '../shared/elements/Action';
import { ElementID, PageID } from '../../../enums';
import LeaveCommunity from './elements/LeaveCommunity/LeaveCommunity';
import CloseCommunity from './elements/CloseCommunity';
import CloseCommunityDescription from './elements/CloseCommunityDescription';
import { checkDeleteCommunityPermission, checkEditCommunityPermission } from '../../../utils/permissions';
import { useCommunitySetting } from './hooks/useCommunitySetting';
const CommunitySetting = ({
  community
}) => {
  const {
    styles,
    handleCloseCommunity,
    handleLeaveCommunity,
    handleEditCommunity,
    handleCommunityMembership,
    handleCommunityPostPermission,
    handleCommunityStorySetting,
    handleCommunityNotificationSetting,
    isNotificationEnabled,
    isNetworkNotificationsEnabled
  } = useCommunitySetting(community);
  return /*#__PURE__*/React.createElement(SafeAreaView, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(Header, {
    title: community === null || community === void 0 ? void 0 : community.displayName
  }), /*#__PURE__*/React.createElement(ScrollView, null, /*#__PURE__*/React.createElement(View, {
    style: styles.titleContainer
  }, /*#__PURE__*/React.createElement(Title, null, "Community information")), checkEditCommunityPermission(community.communityId) && /*#__PURE__*/React.createElement(Action, {
    iconProps: {
      xml: penFill()
    },
    onPress: handleEditCommunity,
    elementId: ElementID.edit_profile,
    pageId: PageID.community_setting_page
  }), /*#__PURE__*/React.createElement(Action, {
    iconProps: {
      xml: member()
    },
    elementId: ElementID.members,
    onPress: handleCommunityMembership,
    pageId: PageID.community_setting_page
  }), /*#__PURE__*/React.createElement(View, {
    style: styles.divider
  }), checkEditCommunityPermission(community.communityId) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
    style: styles.titleContainer
  }, /*#__PURE__*/React.createElement(Title, null, "Community permissions")), /*#__PURE__*/React.createElement(Action, {
    onPress: handleCommunityPostPermission,
    iconProps: {
      xml: postPermission()
    },
    elementId: ElementID.post_permission,
    pageId: PageID.community_setting_page
  }), /*#__PURE__*/React.createElement(Action, {
    iconProps: {
      xml: story()
    },
    elementId: ElementID.story_setting,
    onPress: handleCommunityStorySetting,
    pageId: PageID.community_setting_page
  }), /*#__PURE__*/React.createElement(View, {
    style: styles.divider
  })), isNetworkNotificationsEnabled && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
    style: styles.titleContainer
  }, /*#__PURE__*/React.createElement(Title, null, "Your preferences")), /*#__PURE__*/React.createElement(Action, {
    description: isNotificationEnabled ? 'On' : 'Off',
    iconProps: {
      xml: bell()
    },
    elementId: ElementID.notifications,
    pageId: PageID.community_setting_page,
    onPress: handleCommunityNotificationSetting
  }), /*#__PURE__*/React.createElement(View, {
    style: styles.divider
  })), (community === null || community === void 0 ? void 0 : community.isJoined) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LeaveCommunity, {
    onPress: handleLeaveCommunity,
    pageId: PageID.community_setting_page
  })), checkDeleteCommunityPermission(community.communityId) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
    style: styles.divider
  }), /*#__PURE__*/React.createElement(CloseCommunity, {
    onPress: handleCloseCommunity,
    pageId: PageID.community_setting_page
  }), /*#__PURE__*/React.createElement(CloseCommunityDescription, {
    pageId: PageID.community_setting_page
  }))));
};
export default CommunitySetting;
//# sourceMappingURL=Setting.js.map