選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

ProfileMini.js 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import React, { useMemo } from "react";
  2. import {
  3. ProfileHeader,
  4. ProfileHeaderIconContainer,
  5. ProfileHeaderText,
  6. ProfileMiniHeader,
  7. ProfileMiniStats,
  8. } from "./ProfileMini.styled";
  9. import { useSelector } from "react-redux";
  10. import { selectOffer } from "../../store/selectors/offersSelectors";
  11. import { selectUserId } from "../../store/selectors/loginSelectors";
  12. import { ReactComponent as ProfileIcon } from "../../assets/images/svg/user-gray.svg";
  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. return (
  29. <>
  30. {isLoadingOfferContent || isLoadingOfferContent === undefined ? (
  31. <SkeletonProfileMini />
  32. ) : (
  33. <ProfileHeader>
  34. <ProfileHeaderIconContainer>
  35. <ProfileIcon />
  36. <ProfileHeaderText>
  37. {isMyProfile
  38. ? t("profile.myProfile")
  39. : t("profile.companyProfile")}
  40. </ProfileHeaderText>
  41. </ProfileHeaderIconContainer>
  42. <ProfileMiniHeader
  43. offer={offer}
  44. isMyProfile={isMyProfile}
  45. singleOffer
  46. />
  47. <ProfileMiniStats
  48. profile={offer.companyData}
  49. percentOfSucceededExchanges={
  50. offer.companyData?.statistics?.exchanges?.total
  51. }
  52. isMyProfile={isMyProfile}
  53. />
  54. </ProfileHeader>
  55. )}
  56. </>
  57. );
  58. };
  59. export default ProfileMini;