[ABANDONED] React/Redux front end for the Flexor social network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.0 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. import React, { FC } from 'react'
  2. import { useSelector, useDispatch } from 'react-redux'
  3. import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
  4. import { faDoorOpen } from '@fortawesome/free-solid-svg-icons'
  5. import { setNotificationAuto, removeNotification } from '../actions/notifications'
  6. import { getNotifications } from '../selectors'
  7. import Notification from './notification'
  8. const NotificationContainer: FC = () => {
  9. const notifications = useSelector(getNotifications)
  10. const dispatch = useDispatch()
  11. const setAuto = (id: string) => {
  12. dispatch(setNotificationAuto(id))
  13. }
  14. const dismiss = (id: string) => {
  15. dispatch(removeNotification(id))
  16. }
  17. return (
  18. <div className="notification-container">
  19. {notifications.map(notification => {
  20. const content = () => {
  21. switch (notification.type) {
  22. case 'welcome':
  23. return (
  24. <p>
  25. <span className="icon">
  26. <FontAwesomeIcon icon={faDoorOpen} />
  27. </span>
  28. &nbsp;&nbsp;
  29. <span>{notification.content}</span>
  30. </p>
  31. )
  32. default:
  33. return <span>{notification.content}</span>
  34. }
  35. }
  36. return (
  37. <Notification
  38. key={notification.id}
  39. id={notification.id}
  40. type={notification.type}
  41. auto={notification.auto}
  42. setAuto={setAuto}
  43. dismiss={dismiss}>
  44. {content()}
  45. </Notification>
  46. )
  47. })}
  48. </div>
  49. )
  50. }
  51. export default NotificationContainer