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

81 lines
3.0 KiB

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
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
5 years ago
  1. // self-info.tsx
  2. // Copyright (C) 2020 Dwayne Harris
  3. // This program is free software: you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation, either version 3 of the License, or
  6. // (at your option) any later version.
  7. // This program is distributed in the hope that it will be useful,
  8. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. // GNU General Public License for more details.
  11. // You should have received a copy of the GNU General Public License
  12. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. import React, { FC } from 'react'
  14. import { useSelector } from 'react-redux'
  15. import { Link } from 'react-router-dom'
  16. import { getAuthenticatedUser } from '../selectors/authentication'
  17. import { useTheme } from '../hooks'
  18. import HorizontalRule from '../components/horizontal-rule'
  19. const SelfInfo: FC = () => {
  20. const theme = useTheme()
  21. const user = useSelector(getAuthenticatedUser)
  22. if (!user) {
  23. return (
  24. <div className="user-info-unauthenticated" style={{ backgroundColor: theme.primary }}>
  25. <Link to="/login" style={{ color: theme.primaryAlternate, fontSize: '1.1rem' }}>Log In to Flexor</Link>
  26. <HorizontalRule />
  27. <Link to="/communities" style={{ color: theme.backgroundSecondary, fontSize: '0.9rem' }}>Create an Account</Link>
  28. </div>
  29. )
  30. }
  31. const group = user.group
  32. const groupImageUrl = group && group.iconImageUrl ? group.iconImageUrl : undefined
  33. const name = () => {
  34. if (user.name) {
  35. return (
  36. <Link to="/self" style={{ color: theme.primaryAlternate }}>
  37. <span style={{ fontSize: '1rem' }}>{user.name}</span> <span style={{ fontSize: '0.9rem', fontWeight: 'bold' }}>@{user.id}</span>
  38. </Link>
  39. )
  40. }
  41. return <Link to="/self" style={{ color: theme.primaryAlternate }}>@{user.id}</Link>
  42. }
  43. return (
  44. <div className="user-info" style={{ backgroundColor: theme.primary, color: theme.primaryAlternate }}>
  45. {user.imageUrl &&
  46. <div className="image">
  47. <img src={user.imageUrl} style={{ width: 32 }} />
  48. </div>
  49. }
  50. <div>
  51. {name()}
  52. <br />
  53. {group &&
  54. <div className="group-info">
  55. {groupImageUrl &&
  56. <div className="image">
  57. <img src={groupImageUrl} style={{ width: 16 }} />
  58. </div>
  59. }
  60. <div>
  61. <Link to={`/c/${group.id}`} style={{ color: theme.backgroundSecondary }}>{group.name}</Link>
  62. </div>
  63. </div>
  64. }
  65. </div>
  66. </div>
  67. )
  68. }
  69. export default SelfInfo