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

ProfileMini.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import React, { useMemo } from "react";
  2. import {
  3. ProfileHeader,
  4. ProfileHeaderIconContainer,
  5. ProfileHeaderText,
  6. ProfileMiniStats,
  7. } from "./ProfileMini.styled";
  8. import { useSelector } from "react-redux";
  9. import { selectOffer } from "../../store/selectors/offersSelectors";
  10. import { selectUserId } from "../../store/selectors/loginSelectors";
  11. import { ReactComponent as ProfileIcon } from "../../assets/images/svg/user-gray.svg";
  12. import ItemDetailsHeaderCard from "../ItemDetails/ItemDetailsHeaderCard/ItemDetailsHeaderCard";
  13. import { useTranslation } from "react-i18next";
  14. import { selectIsLoadingByActionType } from "../../store/selectors/loadingSelectors";
  15. import SkeletonProfileMini from "./SkeletonProfileMini/SkeletonProfileMini";
  16. import { ONE_OFFER_SCOPE } from "../../store/actions/offers/offersActionConstants";
  17. const ProfileMini = () => {
  18. const offer = useSelector(selectOffer);
  19. const userId = useSelector(selectUserId);
  20. const { t } = useTranslation();
  21. const isLoadingOfferContent = useSelector(
  22. selectIsLoadingByActionType(ONE_OFFER_SCOPE)
  23. );
  24. let isMyProfile = useMemo(() => {
  25. if (offer?.offer?.userId?.toString() === userId?.toString()) return true;
  26. return false;
  27. }, [offer, userId]);
  28. console.log(offer);
  29. return (
  30. <>
  31. {isLoadingOfferContent || isLoadingOfferContent === undefined ? (
  32. <SkeletonProfileMini />
  33. ) : (
  34. <ProfileHeader>
  35. <ProfileHeaderIconContainer>
  36. <ProfileIcon />
  37. <ProfileHeaderText>
  38. {isMyProfile
  39. ? t("profile.myProfile")
  40. : t("profile.companyProfile")}
  41. </ProfileHeaderText>
  42. </ProfileHeaderIconContainer>
  43. <ItemDetailsHeaderCard
  44. offer={offer}
  45. isMyProfile={isMyProfile}
  46. singleOffer
  47. />
  48. <ProfileMiniStats
  49. profile={offer.companyData}
  50. percentOfSucceededExchanges={
  51. offer.companyData?.statistics?.exchanges?.total
  52. }
  53. />
  54. </ProfileHeader>
  55. )}
  56. </>
  57. );
  58. };
  59. export default ProfileMini;