PrivatChatHeader.jsx 969 B

123456789101112131415161718192021222324252627282930
  1. import { useSelector } from "react-redux"
  2. import './userInfo.scss';
  3. import { StyledAvatar } from "../messageForm/StyledAvatar";
  4. import { Avatar } from "@mui/material";
  5. export const PrivatChatHeader = () => {
  6. const SERVER_URL = process.env.REACT_APP_SERVER_URL
  7. //add dispatch and saving name for user to store
  8. const selectedUser = useSelector(state => state.dataReducer.selectedUser)
  9. return (
  10. <div className="active" >
  11. <StyledAvatar
  12. sx={{ marginRight:2}}
  13. anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
  14. >
  15. <Avatar
  16. src= {SERVER_URL + '/'+ selectedUser?.avatar}
  17. sx={{ alignSelf: 'flex-end'}}
  18. >
  19. {selectedUser.userName.slice(0, 1)}
  20. </Avatar>
  21. </StyledAvatar>
  22. Private Chat with {selectedUser.userName}
  23. </div>
  24. )
  25. }