UserNotificationRow.jsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import React from 'react';
  2. import { useTranslation } from 'next-i18next';
  3. import PropTypes from 'prop-types';
  4. import AdminNotificationContainer from '~/client/services/AdminNotificationContainer';
  5. import { withUnstatedContainers } from '../../UnstatedUtils';
  6. import { NotificationTypeIcon } from './NotificationTypeIcon';
  7. class UserNotificationRow extends React.PureComponent {
  8. render() {
  9. const { t, notification } = this.props;
  10. const id = `user-notification-${notification._id}`;
  11. return (
  12. <React.Fragment>
  13. <tr className="admin-notif-row" key={id}>
  14. <td className="px-4">{notification.pathPattern}</td>
  15. <td className="px-4">
  16. <NotificationTypeIcon notification={notification} />
  17. {notification.channel}
  18. </td>
  19. <td>
  20. <button
  21. type="submit"
  22. className="btn btn-outline-danger"
  23. onClick={() => {
  24. this.props.onClickDeleteBtn(notification._id);
  25. }}
  26. >
  27. {t('Delete')}
  28. </button>
  29. </td>
  30. </tr>
  31. </React.Fragment>
  32. );
  33. }
  34. }
  35. UserNotificationRow.propTypes = {
  36. t: PropTypes.func.isRequired, // i18next
  37. adminNotificationContainer: PropTypes.instanceOf(AdminNotificationContainer)
  38. .isRequired,
  39. notification: PropTypes.object.isRequired,
  40. onClickDeleteBtn: PropTypes.func.isRequired,
  41. };
  42. // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
  43. const UserNotificationRowWrapperWrapperFC = (props) => {
  44. const { t } = useTranslation();
  45. return <UserNotificationRow t={t} {...props} />;
  46. };
  47. const UserNotificationRowWrapper = withUnstatedContainers(
  48. UserNotificationRowWrapperWrapperFC,
  49. [AdminNotificationContainer],
  50. );
  51. export default UserNotificationRowWrapper;