index.tsx 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { makeStyles } from '@material-ui/core'
  2. import { useSelector } from 'react-redux';
  3. import { Carousel } from 'react-responsive-carousel';
  4. import { firstLetter, slicedWord, timeStampEU, prodAwsS3 } from '../../../../../helpers'
  5. import transparentPic from '../../../../../img/transparentPic.png'
  6. import { getChat } from '../../../../../redux/chat/selector'
  7. const useStyles = makeStyles({
  8. container: {
  9. position: 'relative',
  10. },
  11. timeTitle: {
  12. position:'absolute',
  13. color: '#ffffff',
  14. backgroundColor: 'rgb(0,0,0)',
  15. borderRadius: 10,
  16. padding:4,
  17. fontSize: 15,
  18. top: '1%',
  19. left: '50%',
  20. marginLeft: '-45%',
  21. opacity: 0.7,
  22. transition: 'opacity .35s ease-in-out'
  23. },
  24. nameTitle: {
  25. position:'absolute',
  26. color: '#ffffff',
  27. backgroundColor: 'rgb(0,0,0)',
  28. borderRadius: 10,
  29. padding:8,
  30. fontSize: 18,
  31. zIndex:10,
  32. top: '6%',
  33. left: '50%',
  34. marginLeft: '-45%',
  35. opacity: 0.7,
  36. transition: 'opacity .35s ease-in-out'
  37. },
  38. countryTitle: {
  39. position:'absolute',
  40. color: '#ffffff',
  41. backgroundColor: 'rgb(0,0,0)',
  42. borderRadius: 10,
  43. padding:4,
  44. fontSize: 15,
  45. top: '13%',
  46. left: '50%',
  47. marginLeft: '-45%',
  48. opacity: 0.7,
  49. transition: 'opacity .35s ease-in-out'
  50. },
  51. credentialsTitle: {
  52. position:'absolute',
  53. color: '#ffffff',
  54. fontSize: 100,
  55. top: '30%',
  56. left: '38%',
  57. },
  58. credentialsLowTitle: {
  59. position:'absolute',
  60. color: '#ffffff',
  61. fontSize: 25,
  62. top: '90%',
  63. left: '9%',
  64. },
  65. })
  66. const ProfilePicture = () => {
  67. const classes = useStyles()
  68. const { name, lastName, online, avatarsArr, createdAt, color, country } = useSelector(getChat)
  69. const isDefault = avatarsArr.length === 0 ? false: true
  70. return (
  71. <div className={classes.container}>
  72. <Carousel>
  73. {isDefault ?
  74. avatarsArr.map(({ avatarUrl, updatedAt }) => <div>
  75. <img alt='pic' src={`${prodAwsS3}/${avatarUrl}`}/>
  76. <p className="legend">{timeStampEU(updatedAt)}</p>
  77. </div>):
  78. [
  79. <div>
  80. <img alt='transparentPic' src={transparentPic}
  81. style={{ background: `linear-gradient(to bottom, ${color}, ${color} 80%, #5d5d5d 100%)` }} />
  82. <p className="legend">{timeStampEU(createdAt)}</p>
  83. </div>
  84. ]}
  85. </Carousel>
  86. <span className={classes.timeTitle}>{online === 'true' ? 'online' : `last seen ${timeStampEU(online)}`}</span>
  87. <span className={classes.nameTitle}>{`${firstLetter(name)}${slicedWord(name, 15, 1)}
  88. ${firstLetter(lastName)}${slicedWord(lastName, 15, 1)}`}</span>
  89. <span className={classes.countryTitle}>{country}</span>
  90. {!isDefault&&<span className={classes.credentialsTitle}>{`${firstLetter(name)}${firstLetter(lastName)}`}</span>}
  91. {!isDefault&&<span className={classes.credentialsLowTitle}>{`${firstLetter(name)}${firstLetter(lastName)}`}</span>}
  92. </div>
  93. )
  94. }
  95. export default ProfilePicture