"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.PostsNotificationSetting = PostsNotificationSetting;
var _reactNative = require("react-native");
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
var _reactHookForm = require("react-hook-form");
var _Typography = require("../../../../core/components/Typography/Typography");
var _Radio = require("../../../../core/components/Radio");
var _Header = _interopRequireDefault(require("./components/Header"));
var _usePostsNotificationSetting = require("./hooks/usePostsNotificationSetting");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function PostsNotificationSetting({
  community
}) {
  const {
    styles,
    isDirty,
    control,
    disabled,
    onSubmit,
    handleSubmit,
    notifications,
    accessibilityId
  } = (0, _usePostsNotificationSetting.usePostsNotificationSetting)({
    community
  });
  return /*#__PURE__*/React.createElement(_reactNativeSafeAreaContext.SafeAreaView, {
    edges: ['top'],
    testID: accessibilityId,
    style: styles.container
  }, /*#__PURE__*/React.createElement(_Header.default, {
    disabled: disabled,
    isFormDirty: isDirty,
    onSave: handleSubmit(onSubmit)
  }), /*#__PURE__*/React.createElement(_reactNative.ScrollView, {
    contentContainerStyle: styles.scrollContainer
  }, notifications.map((item, index, list) => /*#__PURE__*/React.createElement(_reactNative.View, {
    key: item.radio.name
  }, /*#__PURE__*/React.createElement(_reactHookForm.Controller, {
    control: control,
    name: item.radio.name,
    render: ({
      field: {
        onChange,
        value
      }
    }) => /*#__PURE__*/React.createElement(_reactNative.View, null, /*#__PURE__*/React.createElement(_reactNative.View, {
      style: styles.labelContainer
    }, /*#__PURE__*/React.createElement(_Typography.Typography.BodyBold, {
      style: styles.colorBase
    }, item.title), /*#__PURE__*/React.createElement(_Typography.Typography.Caption, {
      style: styles.colorBaseShade1
    }, item.description)), /*#__PURE__*/React.createElement(_Radio.Radio.Group, {
      value: value,
      onChange: onChange
    }, item.radio.items.map(radioItem => /*#__PURE__*/React.createElement(_Radio.Radio.Option, {
      key: radioItem.value,
      value: radioItem.value
    }, /*#__PURE__*/React.createElement(_Radio.Radio.Label, null, /*#__PURE__*/React.createElement(_Typography.Typography.Body, null, radioItem.label)), /*#__PURE__*/React.createElement(_Radio.Radio.Icon, null)))))
  }), index !== list.length - 1 && /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.divider
  })))));
}
//# sourceMappingURL=PostsNotificationSetting.js.map