"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.NotificationSetting = NotificationSetting;
var _reactNative = require("react-native");
var _reactHookForm = require("react-hook-form");
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
var _Typography = require("../../../../core/components/Typography/Typography");
var _Action = _interopRequireDefault(require("../shared/elements/Action"));
var _Header = _interopRequireDefault(require("./components/Header"));
var _useNotificationSetting = require("./hooks/useNotificationSetting");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function NotificationSetting({
  community
}) {
  const {
    styles,
    theme,
    control,
    accessibilityId,
    isEnabled,
    isPending,
    handleToggle,
    notificationActions
  } = (0, _useNotificationSetting.useNotificationSetting)({
    community
  });
  return /*#__PURE__*/React.createElement(_reactNativeSafeAreaContext.SafeAreaView, {
    edges: ['top'],
    testID: accessibilityId,
    style: styles.container
  }, /*#__PURE__*/React.createElement(_Header.default, null), /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.switchContainer
  }, /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.labelContainer
  }, /*#__PURE__*/React.createElement(_Typography.Typography.BodyBold, {
    style: styles.colorBase
  }, "Allow notifications"), /*#__PURE__*/React.createElement(_Typography.Typography.Caption, {
    style: styles.colorBaseShade1
  }, "Turn on to receive push notifications from this community.")), /*#__PURE__*/React.createElement(_reactHookForm.Controller, {
    name: "isEnabled",
    control: control,
    render: ({
      field: {
        value,
        onChange
      }
    }) => /*#__PURE__*/React.createElement(_reactNative.Switch, {
      value: value,
      onValueChange: val => {
        onChange(val);
        handleToggle(val);
      },
      disabled: isPending,
      thumbColor: theme.colors.background,
      ios_backgroundColor: theme.colors.baseShade3,
      trackColor: {
        true: theme.colors.primary,
        false: theme.colors.baseShade3
      }
    })
  })), isEnabled && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.divider
  }), notificationActions.map(item => /*#__PURE__*/React.createElement(_Action.default, _extends({
    key: item.label
  }, item)))));
}
//# sourceMappingURL=NotificationSetting.js.map