"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
var _reactHookForm = require("react-hook-form");
var _CoverImageUpload = _interopRequireDefault(require("../shared/components/CoverImageUpload"));
var _enums = require("../../../enums");
var _FormInput = _interopRequireDefault(require("../../../components/FormInput"));
var _Categories = _interopRequireDefault(require("../shared/components/Categories"));
var _Privacy = _interopRequireDefault(require("../shared/components/Privacy"));
var _constants = require("../../../../core/constants");
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
var _Header = _interopRequireDefault(require("./components/Header"));
var _useEditCommunity = require("./hooks/useEditCommunity");
var _ActionButton = _interopRequireDefault(require("../../../elements/ActionButton"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function EditCommunity({
  community
}) {
  const {
    control,
    isDirty,
    isSubmitting,
    isValid,
    handleSubmit,
    onSubmit,
    openCamera,
    openImageGallery,
    progress,
    styles,
    navigation
  } = (0, _useEditCommunity.useEditCommunity)(community);
  return /*#__PURE__*/React.createElement(_reactNativeSafeAreaContext.SafeAreaView, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(_Header.default, {
    isFormDirty: isDirty
  }), /*#__PURE__*/React.createElement(_reactNative.ScrollView, {
    contentContainerStyle: styles.contentContainer
  }, /*#__PURE__*/React.createElement(_reactHookForm.Controller, {
    name: "image",
    control: control,
    render: ({
      field: {
        onChange,
        value
      }
    }) => /*#__PURE__*/React.createElement(_CoverImageUpload.default, {
      value: value,
      onChange: onChange,
      progress: progress,
      openCamera: openCamera,
      openImageGallery: openImageGallery
    })
  }), /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.allInputContainer
  }, /*#__PURE__*/React.createElement(_reactHookForm.Controller, {
    name: "displayName",
    control: control,
    render: ({
      field: {
        onChange,
        onBlur,
        value
      }
    }) => /*#__PURE__*/React.createElement(_FormInput.default, {
      value: value,
      onBlur: onBlur,
      multiline: false,
      onChangeText: onChange,
      placeholder: "Name your community",
      pageId: _enums.PageID.community_setup_page,
      maxLength: _constants.CHARACTER_LIMIT.COMMUNITY_NAME,
      elementId: _enums.ElementID.community_name_title
    })
  }), /*#__PURE__*/React.createElement(_reactHookForm.Controller, {
    name: "description",
    control: control,
    render: ({
      field: {
        onChange,
        onBlur,
        value
      }
    }) => /*#__PURE__*/React.createElement(_FormInput.default, {
      optional: true,
      value: value,
      onBlur: onBlur,
      multiline: true,
      onChangeText: onChange,
      placeholder: "Enter description",
      pageId: _enums.PageID.community_setup_page,
      elementId: _enums.ElementID.community_about_title,
      maxLength: _constants.CHARACTER_LIMIT.COMMUNITY_DESCRIPTION
    })
  }), /*#__PURE__*/React.createElement(_reactHookForm.Controller, {
    name: "categories",
    control: control,
    render: ({
      field: {
        onChange,
        value
      }
    }) => /*#__PURE__*/React.createElement(_Categories.default, {
      categories: value,
      onChange: onChange,
      goBack: navigation.goBack
    })
  }), /*#__PURE__*/React.createElement(_reactHookForm.Controller, {
    name: "privacy",
    control: control,
    render: ({
      field: {
        onChange,
        value
      }
    }) => /*#__PURE__*/React.createElement(_Privacy.default, {
      value: value,
      onChange: onChange
    })
  }))), /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.submitButtonContainer
  }, /*#__PURE__*/React.createElement(_ActionButton.default, {
    onPress: handleSubmit(onSubmit),
    pageId: _enums.PageID.community_setup_page,
    elementId: _enums.ElementID.community_edit_button,
    disabled: !isDirty || !isValid || isSubmitting || progress > 0
  })));
}
var _default = exports.default = EditCommunity;
//# sourceMappingURL=Edit.js.map