[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.

52 lines
1.5 KiB

5 years ago
5 years ago
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
4 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, useEffect } from 'react'
  2. import { useSelector, useDispatch } from 'react-redux'
  3. import { Link } from 'react-router-dom'
  4. import moment from 'moment'
  5. import { handleApiError } from '../api/errors'
  6. import { fetchLogs } from '../actions/groups'
  7. import { getLogs } from '../selectors/groups'
  8. import { useTheme } from '../hooks'
  9. interface Props {
  10. group: string
  11. }
  12. const MemberList: FC<Props> = ({ group }) => {
  13. const theme = useTheme()
  14. const logs = useSelector(getLogs)
  15. const dispatch = useDispatch()
  16. useEffect(() => {
  17. if (logs.length === 0) {
  18. try {
  19. dispatch(fetchLogs())
  20. } catch (err) {
  21. handleApiError(err, dispatch)
  22. }
  23. }
  24. }, [group])
  25. return (
  26. <table>
  27. <thead style={{ backgroundColor: theme.primary }}>
  28. <tr style={{ color: theme.primaryAlternate, fontWeight: 700 }}>
  29. <th>Who</th>
  30. <th>What</th>
  31. <th>When</th>
  32. </tr>
  33. </thead>
  34. <tbody>
  35. {logs.map(log => (
  36. <tr style={{ backgroundColor: theme.backgroundSecondary }}>
  37. <td><Link style={{ color: theme.primary }} to={`/u/${log.user.id}`}>{log.user.id}</Link></td>
  38. <td>{log.content}</td>
  39. <td>{moment(log.created).format('MMMM Do YYYY, h:mm:ss a')}</td>
  40. </tr>
  41. ))}
  42. </tbody>
  43. </table>
  44. )
  45. }
  46. export default MemberList