Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

MyProfileButton.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import React from "react";
  2. import PropTypes from "prop-types";
  3. import { DrawerButton, DrawerOption } from "../../Drawer.styled";
  4. import { IconButton } from "../../../../Buttons/IconButton/IconButton";
  5. import { MyUsername, UserIcon } from "./MyProfileButton.styled";
  6. import { useTranslation } from "react-i18next";
  7. import { useSelector } from "react-redux";
  8. import { selectProfileName } from "../../../../../store/selectors/profileSelectors";
  9. import { selectUserId } from "../../../../../store/selectors/loginSelectors";
  10. import history from "../../../../../store/utils/history";
  11. import { PROFILE_PAGE } from "../../../../../constants/pages";
  12. import { replaceInRoute } from "../../../../../util/helpers/routeHelpers";
  13. const MyProfileButton = (props) => {
  14. const name = useSelector(selectProfileName);
  15. const userId = useSelector(selectUserId);
  16. const { t } = useTranslation();
  17. const handleClick = () => {
  18. props.toggleDrawer();
  19. history.push(
  20. replaceInRoute(PROFILE_PAGE, {
  21. profileId: userId,
  22. })
  23. );
  24. };
  25. return (
  26. <DrawerButton onClick={handleClick}>
  27. <IconButton sx={{ borderRadius: "4px" }}>
  28. <UserIcon />
  29. </IconButton>
  30. <DrawerOption>{t("header.myProfile")}</DrawerOption>
  31. <MyUsername>({name})</MyUsername>
  32. </DrawerButton>
  33. );
  34. };
  35. MyProfileButton.propTypes = {
  36. toggleDrawer: PropTypes.func,
  37. };
  38. export default MyProfileButton;