Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ProfileMainInfo.js 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. variant="subtitle2"
  72. >
  73. {t("profile.PIB")} {props.profile?.company?.PIB}
  74. </ProfilePIB>
  75. </ProfilePIBContainer>
  76. </ProfileMainInfoGrid>
  77. </ProfileMainInfoContainer>
  78. );
  79. };
  80. ProfileMainInfo.propTypes = {
  81. profile: PropTypes.object,
  82. isMyProfile: PropTypes.bool,
  83. children: PropTypes.node,
  84. isAdmin: PropTypes.any,
  85. bigProfileCard: PropTypes.bool,
  86. isBlocked: PropTypes.bool,
  87. };
  88. ProfileMainInfo.defaultProps = {
  89. isAdmin: false,
  90. bigProfileCard: false,
  91. isBlocked: false,
  92. isMyProfile: false,
  93. };
  94. export default ProfileMainInfo;