UserNotificationRow.jsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. import { createSubscribedElement } from '../../UnstatedUtils';
  5. import AppContainer from '../../../services/AppContainer';
  6. import AdminNotificationContainer from '../../../services/AdminNotificationContainer';
  7. import NotificationTypeIcon from './NotificationTypeIcon';
  8. class UserNotificationRow extends React.PureComponent {
  9. render() {
  10. const { t, notification } = this.props;
  11. const id = `user-notification-${notification._id}`;
  12. return (
  13. <React.Fragment>
  14. <tr className="admin-notif-row" key={id}>
  15. <td className="px-4">
  16. {notification.pathPattern}
  17. </td>
  18. <td className="px-4">
  19. <NotificationTypeIcon notification={notification} />{notification.channel}
  20. </td>
  21. <td>
  22. <button type="submit" className="btn btn-outline-danger" onClick={() => { this.props.onClickDeleteBtn(notification._id) }}>{t('Delete')}</button>
  23. </td>
  24. </tr>
  25. </React.Fragment>
  26. );
  27. }
  28. }
  29. const UserNotificationRowWrapper = (props) => {
  30. return createSubscribedElement(UserNotificationRow, props, [AppContainer, AdminNotificationContainer]);
  31. };
  32. UserNotificationRow.propTypes = {
  33. t: PropTypes.func.isRequired, // i18next
  34. appContainer: PropTypes.instanceOf(AppContainer).isRequired,
  35. adminNotificationContainer: PropTypes.instanceOf(AdminNotificationContainer).isRequired,
  36. notification: PropTypes.object.isRequired,
  37. onClickDeleteBtn: PropTypes.func.isRequired,
  38. };
  39. export default withTranslation()(UserNotificationRowWrapper);