import { Modal } from "antd";
import React from "react";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectNotifications } from "../../../redux/user/user.selectors";
import NotificationDisplayMolecule from "../../molecules/notification-display/notification-display.molecule";
const mapStateToProps = createStructuredSelector({
  //currentUser: selectCurrentUser
  notifications: selectNotifications,
});
const mapDispatchToProps = (dispatch) => ({
  //setUserLanguage: language => dispatch(setUserLanguage(language))
});
export default connect(mapStateToProps, mapDispatchToProps)(NotificationModal);

export function NotificationModal({ notifications }) {
  if (!notifications || notifications.length === 0) return null;
  return (
    <Modal
      open={notifications && notifications.length > 0}
      closable={false}
      footer={null}
    >
      {notifications &&
        notifications.map((n) => (
          <NotificationDisplayMolecule key={n.id} notification={n} />
        ))}
    </Modal>
  );
}
