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

BigProfileCard.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import React, { useState } from "react";
  2. import PropTypes from "prop-types";
  3. import {
  4. BlockIcon,
  5. BlockIconContainer,
  6. BlockLabelIcon,
  7. ButtonsContainer,
  8. CheckButton,
  9. EditButton,
  10. EditIcon,
  11. ProfileCardContainer,
  12. ProfileCardWrapper,
  13. ProfileInfoContainer,
  14. RemoveIcon,
  15. RemoveIconContainer,
  16. } from "./BigProfileCard.styled";
  17. import ProfileMainInfo from "../ProfileMainInfo/ProfileMainInfo";
  18. import ProfileContact from "../ProfileContact/ProfileContact";
  19. import EditProfile from "../EditProfile/EditProfile";
  20. import selectedTheme from "../../../../themes";
  21. import { useTranslation } from "react-i18next";
  22. import history from "../../../../store/utils/history";
  23. import { replaceInRoute } from "../../../../util/helpers/routeHelpers";
  24. import { ADMIN_SINGLE_USER_PAGE } from "../../../../constants/pages";
  25. import DeleteCategory from "../../../Modals/DeleteCategory/DeleteCategory";
  26. import UserLabeledCard from "../../LabeledCard/User/UserLabeledCard";
  27. const BigProfileCard = (props) => {
  28. const { t } = useTranslation();
  29. const [editProfileModal, setEditProfileModal] = useState(false);
  30. const [deleteOrEditModal, setDeleteOrEditModal] = useState({
  31. show: false,
  32. type: "",
  33. });
  34. const closeModalHandler = () => {
  35. if (editProfileModal) setEditProfileModal(false);
  36. else setDeleteOrEditModal({ show: false, type: "" });
  37. };
  38. const removeUser = () => {
  39. setDeleteOrEditModal({
  40. show: true,
  41. type: "deleteUser",
  42. });
  43. };
  44. console.log(props.profile);
  45. const blockUser = () => {
  46. setDeleteOrEditModal({
  47. show: true,
  48. type: "blockUser",
  49. });
  50. };
  51. const goToUser = () => {
  52. history.push(
  53. replaceInRoute(ADMIN_SINGLE_USER_PAGE, {
  54. idProfile: props.profile?._id,
  55. })
  56. );
  57. };
  58. return (
  59. <>
  60. <ProfileCardContainer halfwidth={props.halfwidth}>
  61. <ProfileCardWrapper variant="outlined">
  62. <ButtonsContainer>
  63. <EditButton onClick={() => setEditProfileModal(true)}>
  64. <EditIcon />
  65. </EditButton>
  66. <RemoveIconContainer onClick={removeUser}>
  67. <RemoveIcon />
  68. </RemoveIconContainer>
  69. <BlockIconContainer onClick={blockUser}>
  70. <BlockIcon />
  71. </BlockIconContainer>
  72. </ButtonsContainer>
  73. <ProfileInfoContainer>
  74. {/* Profile Main Info */}
  75. <ProfileMainInfo profile={props.profile} isAdmin />
  76. {/* Profile Contact */}
  77. <ProfileContact profile={props.profile} isAdmin />
  78. </ProfileInfoContainer>
  79. <CheckButton
  80. halfwidth={props.halfwidth}
  81. variant={"outlined"}
  82. buttoncolor={selectedTheme.colors.primaryPurple}
  83. textcolor={selectedTheme.colors.primaryPurple}
  84. style={{ fontWeight: "600" }}
  85. onClick={goToUser}
  86. >
  87. {t("admin.users.checkProfile")}
  88. </CheckButton>
  89. </ProfileCardWrapper>
  90. </ProfileCardContainer>
  91. {editProfileModal && (
  92. <EditProfile
  93. profile={props.profile}
  94. closeModalHandler={closeModalHandler}
  95. reFetchProfile={() => {}}
  96. isAdmin
  97. userId={props.profile._id}
  98. />
  99. )}
  100. {deleteOrEditModal.show && (
  101. <DeleteCategory
  102. customId={props.profile._id}
  103. setOpenedDeleteModal={closeModalHandler}
  104. type={deleteOrEditModal.type}
  105. customLabeledCard={<UserLabeledCard user={props.profile} />}
  106. customLabeledCardHeight="90px"
  107. customLabeledCardIcon={
  108. deleteOrEditModal.type === "blockUser" && <BlockLabelIcon />
  109. }
  110. />
  111. )}
  112. </>
  113. );
  114. };
  115. BigProfileCard.propTypes = {
  116. profile: PropTypes.any,
  117. halfwidth: PropTypes.bool,
  118. };
  119. export default BigProfileCard;