import React, { useEffect } from 'react';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { createStructuredSelector } from 'reselect';
// import { withReducer } from '../../app/core/with-reducer';
// import { withEpics } from '../../app/core/with-epics';
import { ACTION } from '../reducer';
// import * as epics from '../epics';
import { withErrorBoundary } from '../../common/hoc/with-error-boundary';
// TODO: NotificationsNew
import { enableForegroundNotifications } from '../services/push-notifications';
import { TRootNotificationsState } from '../types';
// import { make___Selector } from '../selectors';

type TStructured = {};

type TPropsExternal = {};

type TConnected = TStructured & {
  // newNotification: () => void;
  checkPermissions: () => void;
};

const mapStateToProps = createStructuredSelector<
  TRootNotificationsState,
  TStructured
>({
  // prop1: makeSelector(),
  //†prop
});
const mapDispatchToProps = {
  // action1: ACTION.action1,
  newNotification: ACTION.newNotification,
  checkPermissions: ACTION.checkPermissions,
  //†action
};

// Uncomment to write componentDidMount hook
const Connected: React.FC<TConnected> = ({ checkPermissions }) => {
  useEffect(() => {
    // TODO: NotificationsNew
    enableForegroundNotifications();
    checkPermissions();
  }, []);
  return null;
};

export default compose(
  // withReducer('notifications', reducer),
  // withEpics('notifications', epics),
  withErrorBoundary('notifications:notifications-registrator'),
  connect(
    mapStateToProps,
    mapDispatchToProps
  )
)(Connected) as React.FC<TPropsExternal>;
