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

ProfileMainInfo.js 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import React from "react";
  2. import PropTypes from "prop-types";
  3. import {
  4. ProfileMainInfoContainer,
  5. AvatarImageContainer,
  6. AvatarImage,
  7. ProfileMainInfoGrid,
  8. ProfileName,
  9. ProfilePIBContainer,
  10. PocketIcon,
  11. ProfilePIB,
  12. // BlockedProfileText,
  13. } from "./ProfileMainInfo.styled";
  14. import { useTranslation } from "react-i18next";
  15. import { getImageUrl, variants } from "../../../../util/helpers/imageUrlGetter";
  16. import useIsMobile from "../../../../hooks/useIsMobile";
  17. import history from "../../../../store/utils/history";
  18. import {
  19. isAdminRoute,
  20. replaceInRoute,
  21. } from "../../../../util/helpers/routeHelpers";
  22. import { ADMIN_SINGLE_USER_PAGE } from "../../../../constants/pages";
  23. import BlockedProfile from "../BlockedProfile/BlockedProfile";
  24. const ProfileMainInfo = (props) => {
  25. const { t } = useTranslation();
  26. const { isMobile } = useIsMobile();
  27. const goToUser = () => {
  28. if (isAdminRoute()) {
  29. history.push(
  30. replaceInRoute(ADMIN_SINGLE_USER_PAGE, {
  31. idProfile: props.profile?._id,
  32. })
  33. );
  34. }
  35. };
  36. return (
  37. <ProfileMainInfoContainer
  38. bigProfileCard={props.bigProfileCard}
  39. isAdmin={props.isAdmin}
  40. >
  41. <AvatarImageContainer>
  42. <AvatarImage
  43. isAdmin={props.isAdmin}
  44. src={getImageUrl(
  45. props.profile?.image,
  46. variants.profileImage,
  47. isMobile
  48. )}
  49. />
  50. </AvatarImageContainer>
  51. <ProfileMainInfoGrid bigProfileCard={props.bigProfileCard}>
  52. {props.profile?._blocked &&
  53. props.isAdmin &&
  54. (!isMobile || (isMobile && props.bigProfileCard)) && (
  55. <BlockedProfile hideIcon redText aboveTitle isAdmin />
  56. )}
  57. <ProfileName
  58. bigProfileCard={props.bigProfileCard}
  59. isAdmin={props.isAdmin}
  60. isMyProfile={props.isMyProfile}
  61. isBlocked={props.isBlocked}
  62. variant="h5"
  63. onClick={goToUser}
  64. >
  65. {props.profile?.company?.name}
  66. </ProfileName>
  67. <ProfilePIBContainer>
  68. <PocketIcon />
  69. <ProfilePIB
  70. isMyProfile={props?.isBlocked || props.isMyProfile}
  71. isBlocked={props.isBlocked}
  72. variant="subtitle2"
  73. >
  74. {t("profile.PIB")} {props.profile?.company?.PIB}
  75. </ProfilePIB>
  76. </ProfilePIBContainer>
  77. </ProfileMainInfoGrid>
  78. </ProfileMainInfoContainer>
  79. );
  80. };
  81. ProfileMainInfo.propTypes = {
  82. profile: PropTypes.object,
  83. isMyProfile: PropTypes.bool,
  84. children: PropTypes.node,
  85. isAdmin: PropTypes.any,
  86. bigProfileCard: PropTypes.bool,
  87. isBlocked: PropTypes.bool,
  88. };
  89. ProfileMainInfo.defaultProps = {
  90. isAdmin: false,
  91. bigProfileCard: false,
  92. isBlocked: false,
  93. isMyProfile: false,
  94. };
  95. export default ProfileMainInfo;