import { View, ScrollView } from 'react-native';
import { Controller } from 'react-hook-form';
import CoverImage from '../shared/components/CoverImageUpload';
import { ElementID, PageID } from '../../../enums';
import FormInput from '../../../components/FormInput';
import Categories from '../shared/components/Categories';
import Privacy from '../shared/components/Privacy';
import { CHARACTER_LIMIT } from '../../../../core/constants';
import { SafeAreaView } from 'react-native-safe-area-context';
import Header from './components/Header';
import { useEditCommunity } from './hooks/useEditCommunity';
import ActionButton from '../../../elements/ActionButton';
function EditCommunity({
  community
}) {
  const {
    control,
    isDirty,
    isSubmitting,
    isValid,
    handleSubmit,
    onSubmit,
    openCamera,
    openImageGallery,
    progress,
    styles,
    navigation
  } = useEditCommunity(community);
  return /*#__PURE__*/React.createElement(SafeAreaView, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(Header, {
    isFormDirty: isDirty
  }), /*#__PURE__*/React.createElement(ScrollView, {
    contentContainerStyle: styles.contentContainer
  }, /*#__PURE__*/React.createElement(Controller, {
    name: "image",
    control: control,
    render: ({
      field: {
        onChange,
        value
      }
    }) => /*#__PURE__*/React.createElement(CoverImage, {
      value: value,
      onChange: onChange,
      progress: progress,
      openCamera: openCamera,
      openImageGallery: openImageGallery
    })
  }), /*#__PURE__*/React.createElement(View, {
    style: styles.allInputContainer
  }, /*#__PURE__*/React.createElement(Controller, {
    name: "displayName",
    control: control,
    render: ({
      field: {
        onChange,
        onBlur,
        value
      }
    }) => /*#__PURE__*/React.createElement(FormInput, {
      value: value,
      onBlur: onBlur,
      multiline: false,
      onChangeText: onChange,
      placeholder: "Name your community",
      pageId: PageID.community_setup_page,
      maxLength: CHARACTER_LIMIT.COMMUNITY_NAME,
      elementId: ElementID.community_name_title
    })
  }), /*#__PURE__*/React.createElement(Controller, {
    name: "description",
    control: control,
    render: ({
      field: {
        onChange,
        onBlur,
        value
      }
    }) => /*#__PURE__*/React.createElement(FormInput, {
      optional: true,
      value: value,
      onBlur: onBlur,
      multiline: true,
      onChangeText: onChange,
      placeholder: "Enter description",
      pageId: PageID.community_setup_page,
      elementId: ElementID.community_about_title,
      maxLength: CHARACTER_LIMIT.COMMUNITY_DESCRIPTION
    })
  }), /*#__PURE__*/React.createElement(Controller, {
    name: "categories",
    control: control,
    render: ({
      field: {
        onChange,
        value
      }
    }) => /*#__PURE__*/React.createElement(Categories, {
      categories: value,
      onChange: onChange,
      goBack: navigation.goBack
    })
  }), /*#__PURE__*/React.createElement(Controller, {
    name: "privacy",
    control: control,
    render: ({
      field: {
        onChange,
        value
      }
    }) => /*#__PURE__*/React.createElement(Privacy, {
      value: value,
      onChange: onChange
    })
  }))), /*#__PURE__*/React.createElement(View, {
    style: styles.submitButtonContainer
  }, /*#__PURE__*/React.createElement(ActionButton, {
    onPress: handleSubmit(onSubmit),
    pageId: PageID.community_setup_page,
    elementId: ElementID.community_edit_button,
    disabled: !isDirty || !isValid || isSubmitting || progress > 0
  })));
}
export default EditCommunity;
//# sourceMappingURL=Edit.js.map