@ludo.ninja/components 2.1.41 → 2.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { ApolloClient, NormalizedCacheObject } from '@apollo/client';
2
2
  import { searchSchema as schema } from '@ludo.ninja/api';
3
3
  import { ProfileEntity } from '@ludo.ninja/core';
4
- import AssetEntity from '../../../../dto/AssetEntity';
4
+ import AssetEntity from '../../../../dto/AssetSearchEntity';
5
5
  export declare const prefetchFindAllTopEntitiesByName: ({ name, pageSize }: schema.IQueryFindAllTopEntitiesByNameArgs, apolloClient: ApolloClient<NormalizedCacheObject>) => Promise<import("@apollo/client").ApolloQueryResult<any> | {
6
6
  data: {
7
7
  findAllTopEntitiesByName: null;
@@ -7,7 +7,7 @@ exports.useFetchFindAllTopEntitiesByName = exports.prefetchFindAllTopEntitiesByN
7
7
  const react_1 = require("react");
8
8
  const api_1 = require("@ludo.ninja/api");
9
9
  const core_1 = require("@ludo.ninja/core");
10
- const AssetEntity_1 = __importDefault(require("../../../../dto/AssetEntity"));
10
+ const AssetSearchEntity_1 = __importDefault(require("../../../../dto/AssetSearchEntity"));
11
11
  const prefetchFindAllTopEntitiesByName = ({ name, pageSize }, apolloClient) => {
12
12
  return apolloClient
13
13
  .query({
@@ -30,7 +30,7 @@ const useFetchFindAllTopEntitiesByName = () => {
30
30
  uri: api_1.hosts.searchHost,
31
31
  },
32
32
  onCompleted: ({ findAllTopEntitiesByName }) => {
33
- const assets = findAllTopEntitiesByName.assets.map((asset) => new AssetEntity_1.default(asset)) || [];
33
+ const assets = findAllTopEntitiesByName.assets.map((asset) => new AssetSearchEntity_1.default(asset)) || [];
34
34
  const profiles = findAllTopEntitiesByName.profiles.map((profile) => new core_1.ProfileEntity(profile)) || [];
35
35
  setTopEntities({
36
36
  assets,
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import { collectionsSchema as schema } from '@ludo.ninja/api';
3
3
  import { ProfileEntity } from '@ludo.ninja/core';
4
- import AssetEntity from '../../../dto/AssetEntity';
4
+ import AssetSearchEntity from '../../../dto/AssetSearchEntity';
5
5
  interface Props {
6
- assets: AssetEntity[];
6
+ assets: AssetSearchEntity[];
7
7
  profiles: ProfileEntity[];
8
8
  collections: schema.ICollection[];
9
9
  searchTerm: string;
@@ -119,7 +119,7 @@ const SearchSuggestions = ({ searchTerm, assets, profiles, collections, isLoadin
119
119
  // image and screenshots
120
120
  miniatureUrl = (0, Urls_1.getAssetImage)(currentMedia?.url, '/noContent/noContent.svg', Urls_1.mediaSizes.small, NEXT_PUBLIC_STATIC_DOMAIN);
121
121
  }
122
- return ((0, jsx_runtime_1.jsx)(searchSuggestionsItem_1.default, { name: asset?.getName(), link: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["asset"]}/${asset.getAssetLink().replace(`${ItemType_1.LabelKeys.asset}/`, "")}`, imgUrl: miniatureUrl, searchTerm: searchTerm }, `${asset?.getAssetId()}.${Math.random()}`));
122
+ return ((0, jsx_runtime_1.jsx)(searchSuggestionsItem_1.default, { name: asset?.getName(), link: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["asset"]}${asset.getAssetLink().replace(`${ItemType_1.LabelKeys.asset}/`, "")}`, imgUrl: miniatureUrl, searchTerm: searchTerm }, `${asset?.getAssetId()}.${Math.random()}`));
123
123
  }),
124
124
  },
125
125
  ]
@@ -1,2 +1,36 @@
1
+ import React from "react";
2
+ export declare const SLink: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
3
+ href: string | import("url").UrlObject;
4
+ as?: string | import("url").UrlObject;
5
+ replace?: boolean;
6
+ scroll?: boolean;
7
+ shallow?: boolean;
8
+ passHref?: boolean;
9
+ prefetch?: boolean;
10
+ locale?: string | false;
11
+ legacyBehavior?: boolean;
12
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
13
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
14
+ onClick?: React.MouseEventHandler<HTMLAnchorElement>;
15
+ }> & {
16
+ href: string | import("url").UrlObject;
17
+ as?: string | import("url").UrlObject;
18
+ replace?: boolean;
19
+ scroll?: boolean;
20
+ shallow?: boolean;
21
+ passHref?: boolean;
22
+ prefetch?: boolean;
23
+ locale?: string | false;
24
+ legacyBehavior?: boolean;
25
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
26
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
27
+ onClick?: React.MouseEventHandler<HTMLAnchorElement>;
28
+ } & {
29
+ children?: React.ReactNode;
30
+ } & React.RefAttributes<HTMLAnchorElement>>, import("styled-components").DefaultTheme, {
31
+ scale: {
32
+ transform: string;
33
+ } | object;
34
+ }, never>;
1
35
  declare const Sidebar: () => import("react/jsx-runtime").JSX.Element;
2
36
  export default Sidebar;
@@ -3,13 +3,131 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SLink = void 0;
6
7
  const jsx_runtime_1 = require("react/jsx-runtime");
7
8
  const link_1 = __importDefault(require("next/link"));
8
- const sidebarSpa_1 = require("./sidebarSpa");
9
9
  const Userpic_1 = __importDefault(require("../../system/Img/Userpic"));
10
10
  const sidebarInviteCodeLabel_1 = __importDefault(require("./sidebarInviteCodeLabel"));
11
+ const styled_components_1 = __importDefault(require("styled-components"));
12
+ const sidebar_1 = require("@ludo.ninja/ui/build/components/sidebar");
13
+ const MainButton_1 = __importDefault(require("@ludo.ninja/ui/build/system/Buttons/MainButton"));
14
+ const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
15
+ const data_1 = require("./data");
16
+ const useSignOut_1 = require("../../modules/user/auth/useSignOut");
17
+ const store_1 = require("../../modules/user/store");
18
+ const ui_1 = require("../../store/ui");
19
+ const ScreenWidth_1 = require("../../styles/ScreenWidth");
20
+ const scale_1 = require("../../utils/adaptive/scale");
21
+ const auth_1 = require("../../utils/auth");
22
+ const screen_1 = require("../../utils/screen");
23
+ const useExtension_1 = __importDefault(require("../../hooks/extension/useExtension"));
24
+ const MenuItem = styled_components_1.default.div `
25
+ font-size: 15px;
26
+ font-weight: 500;
27
+ line-height: 22px;
28
+ display: flex;
29
+ gap: 8px;
30
+ align-items: center;
31
+ padding: 12px 4px;
32
+ text-indent: 4px;
33
+ border-radius: 4px;
34
+ cursor: pointer;
35
+ color: ${({ theme }) => theme.colors.secondaryText};
36
+
37
+ ${ScreenWidth_1.mediaQuery.mobile} {
38
+ font-size: 14px;
39
+ line-height: 20px;
40
+ }
41
+
42
+ transition: background-color 0.3s ease-in-out;
43
+
44
+ @media (hover: hover) {
45
+ &:hover {
46
+ transition: background-color 0.3s ease-in;
47
+ background-color: ${({ theme }) => theme.colors.secondaryBg};
48
+ }
49
+ }
50
+
51
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
52
+ font-size: ${(0, _4k_1.adaptiveValueCalc)(15)};
53
+ line-height: ${(0, _4k_1.adaptiveValueCalc)(22)};
54
+ gap: ${(0, _4k_1.adaptiveValueCalc)(8)};
55
+ padding: ${(0, _4k_1.adaptiveValueCalc)(12)} ${(0, _4k_1.adaptiveValueCalc)(4)};
56
+ text-indent: ${(0, _4k_1.adaptiveValueCalc)(4)};
57
+ border-radius: ${(0, _4k_1.adaptiveValueCalc)(4)};
58
+
59
+ img {
60
+ width: ${(0, _4k_1.adaptiveValueCalc)(20)};
61
+ height: ${(0, _4k_1.adaptiveValueCalc)(20)};
62
+ }
63
+ }
64
+ `;
65
+ const BeforeMenuContainer = styled_components_1.default.div `
66
+ padding: 12px 0;
67
+ border-bottom: 1px solid ${({ theme }) => theme.colors.divider};
68
+
69
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
70
+ padding: ${(0, _4k_1.adaptiveValueCalc)(12)} 0;
71
+ border-bottom: ${(0, _4k_1.adaptiveValueCalc)(1)} solid ${({ theme }) => theme.colors.divider};
72
+ }
73
+ `;
74
+ exports.SLink = (0, styled_components_1.default)(link_1.default) `
75
+ &:not(:last-child) svg path {
76
+ fill: ${({ theme }) => theme.colors.sidebarSvgPathFill};
77
+ }
78
+
79
+ .icon-wrapper {
80
+ width: 20px;
81
+ height: 20px;
82
+ display: flex;
83
+ align-items: center;
84
+ justify-content: center;
85
+
86
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
87
+ width: ${(0, _4k_1.adaptiveValueCalc)(20)};
88
+ height: ${(0, _4k_1.adaptiveValueCalc)(20)};
89
+
90
+ svg {
91
+ transform: ${(props) => "transform" in props.scale && props.scale.transform};
92
+ }
93
+ }
94
+ }
95
+ `;
96
+ // Component
11
97
  const Sidebar = () => {
12
- return ((0, jsx_runtime_1.jsx)(sidebarSpa_1.SidebarSpa, { SLink: (0, sidebarSpa_1.SLinkStyles)(link_1.default), UserPic: Userpic_1.default, SidebarInviteCodeLabel: sidebarInviteCodeLabel_1.default }));
98
+ const redirectToLoginWindow = (0, auth_1.useRedirectToLoginWindow)();
99
+ const closeSidebar = (0, ui_1.useUiStore)((state) => state.closeSidebar);
100
+ const isSidebarOpen = (0, ui_1.useUiStore)((state) => state.isSidebarOpen);
101
+ const isAuthorized = (0, store_1.useUserStore)((state) => state.isSignedIn);
102
+ const getUser = (0, store_1.useUserStore)((state) => state.user);
103
+ const signOut = (0, useSignOut_1.useSignOut)();
104
+ const { deviceType } = (0, screen_1.useWindowDimensions)();
105
+ const { isExtensionInstalled, openExtensionChromeStorePage, openExtension } = (0, useExtension_1.default)();
106
+ const { wallets, userId } = getUser ?? [""];
107
+ // Todo fav-list
108
+ const sideBarData = (0, data_1.useSidebarData)();
109
+ const { windowDimensions } = (0, screen_1.useWindowDimensionsWithServerInitial)();
110
+ return ((0, jsx_runtime_1.jsx)(sidebar_1.Sidebar, { closeSidebar: closeSidebar, isOpen: isSidebarOpen, handle: {
111
+ login: () => {
112
+ closeSidebar();
113
+ redirectToLoginWindow();
114
+ },
115
+ logout: signOut,
116
+ }, isAuthorized: isAuthorized, userWallets: wallets, slots: {
117
+ menu: sideBarData.map(({ title, href, icon, isExternalUrl }) => ((0, jsx_runtime_1.jsxs)(exports.SLink, { href: href, target: isExternalUrl ? "_blank" : "_self", onClick: closeSidebar, passHref: isExternalUrl, scale: (0, scale_1.getAdaptiveScale)({ windowDimensions, currentSize: 1 }), children: [(0, jsx_runtime_1.jsx)("span", { className: "icon-wrapper", children: icon }), title] }, title))),
118
+ userPicture: ({ children, height, width, isNeedBoxTransform }) => ((0, jsx_runtime_1.jsx)(Userpic_1.default, { width: width, height: height, userId: userId, isNeedBoxTransform: isNeedBoxTransform, children: children })),
119
+ inviteCode: (0, jsx_runtime_1.jsx)(sidebarInviteCodeLabel_1.default, {}),
120
+ ...(deviceType == "isDesktop" && isAuthorized
121
+ ? {
122
+ beforeMenu: ((0, jsx_runtime_1.jsx)(BeforeMenuContainer, { children: isExtensionInstalled ? ((0, jsx_runtime_1.jsxs)(MenuItem, { onClick: () => {
123
+ closeSidebar();
124
+ openExtension();
125
+ }, children: [(0, jsx_runtime_1.jsx)("img", { src: "/sidebar/ludoX.svg", alt: "Ludo X", width: 20, height: 20 }), "Open Ludo X"] })) : ((0, jsx_runtime_1.jsx)("div", { style: { padding: "12px 0" }, children: (0, jsx_runtime_1.jsx)(MainButton_1.default, { onClick: () => {
126
+ closeSidebar();
127
+ openExtensionChromeStorePage();
128
+ }, text: "Install Ludo X now", variant: "primaryM" }) })) })),
129
+ }
130
+ : {}),
131
+ } }));
13
132
  };
14
- // Export
15
133
  exports.default = Sidebar;
@@ -0,0 +1,60 @@
1
+ import { assetSchema as schema } from "@ludo.ninja/api";
2
+ import { BlockChainEntity, MarketPlaceEntity } from "@ludo.ninja/core";
3
+ import { LabelKeys } from '../common/ItemType';
4
+ import IAssetSearchEntity from './interface';
5
+ declare class AssetSearchEntity implements IAssetSearchEntity {
6
+ private assetId;
7
+ private blockchain;
8
+ private ownersProfiles;
9
+ private ownersAddresses;
10
+ private itemType;
11
+ private address;
12
+ private tokenId;
13
+ private medias;
14
+ private name;
15
+ private description;
16
+ private creatorsProfiles;
17
+ private creatorsAddresses;
18
+ private markets;
19
+ private originalUrls;
20
+ private rank;
21
+ private collection;
22
+ private category;
23
+ private categoryLabel;
24
+ private attributes;
25
+ private blockTimestamp;
26
+ private price;
27
+ constructor(asset: schema.IAsset);
28
+ getAssetId(): string;
29
+ getIsSlider(): boolean;
30
+ getSplitedAssetId(): string;
31
+ getName(): null | string;
32
+ getMarkets(): MarketPlaceEntity[] | null;
33
+ getBlockchain(): BlockChainEntity;
34
+ getPrice(): {
35
+ latestPriceAmount: number | null;
36
+ latestPriceCurrency: string | null;
37
+ };
38
+ getBlockTimestamp(): number;
39
+ getAttributes(): schema.IAttribute[];
40
+ getDescription(): null | string;
41
+ getTokenId(): string | null;
42
+ getCollection(): {
43
+ collectionId: string | null;
44
+ collectionTitle: string | null;
45
+ collectionMedias: schema.IMedia[];
46
+ };
47
+ getCategory(): string | null;
48
+ getCategoryLabel(): string | null;
49
+ getOriginalUrls(): schema.IMedia[] | null;
50
+ getItemType(): LabelKeys;
51
+ getRank(): number;
52
+ getAddress(): string | null;
53
+ getAssetLink(): string;
54
+ getOwnersProfiles(): schema.IProfile[];
55
+ getAssetMedias(): schema.IMedia[];
56
+ getCreatorsProfiles(): schema.IProfile[];
57
+ getOwnersAddresses(): string[] | null;
58
+ getCreatorsAddresses(): string[] | null;
59
+ }
60
+ export default AssetSearchEntity;
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@ludo.ninja/core");
4
+ const utils_1 = require("@ludo.ninja/utils");
5
+ const ItemType_1 = require("../common/ItemType");
6
+ class AssetSearchEntity {
7
+ assetId;
8
+ blockchain;
9
+ ownersProfiles;
10
+ ownersAddresses;
11
+ itemType;
12
+ address;
13
+ tokenId;
14
+ medias;
15
+ name;
16
+ description;
17
+ creatorsProfiles;
18
+ creatorsAddresses;
19
+ markets;
20
+ originalUrls;
21
+ rank;
22
+ collection;
23
+ category;
24
+ categoryLabel;
25
+ attributes;
26
+ blockTimestamp;
27
+ price;
28
+ constructor(asset) {
29
+ this.assetId = asset.assetId;
30
+ this.blockchain = new core_1.BlockChainEntity(asset?.blockchain);
31
+ this.markets =
32
+ asset.markets?.map((market) => new core_1.MarketPlaceEntity({
33
+ marketName: market?.marketName,
34
+ marketUrl: market?.marketUrl,
35
+ marketId: market?.marketUrl,
36
+ })) || [];
37
+ this.ownersProfiles = asset.ownersProfiles || null;
38
+ this.ownersAddresses = asset.ownersAddresses;
39
+ this.itemType = ItemType_1.LabelKeys.asset;
40
+ this.address = asset.address;
41
+ this.tokenId = asset.tokenId;
42
+ this.medias = asset.medias;
43
+ this.name = asset.name;
44
+ this.description = asset.description;
45
+ this.creatorsProfiles = asset.creatorsProfiles || null;
46
+ this.creatorsAddresses = asset.creatorsAddresses;
47
+ this.originalUrls = asset.originalUrls;
48
+ this.rank = asset.rank;
49
+ this.collection = {
50
+ collectionId: asset.collectionId,
51
+ collectionTitle: asset.collectionTitle,
52
+ collectionMedias: asset.collectionMedias,
53
+ };
54
+ this.category = asset.category;
55
+ this.categoryLabel = asset.categoryLabel;
56
+ this.price = {
57
+ latestPriceAmount: asset.latestPriceAmount,
58
+ latestPriceCurrency: asset.latestPriceCurrency,
59
+ };
60
+ this.attributes = asset.attributes;
61
+ this.blockTimestamp = asset.blockTimestamp;
62
+ }
63
+ // accessors
64
+ getAssetId() {
65
+ return this.assetId;
66
+ }
67
+ getIsSlider() {
68
+ return this.getAssetMedias()
69
+ ? this.getAssetMedias()?.length > 1
70
+ : false;
71
+ }
72
+ getSplitedAssetId() {
73
+ return this.getAssetId().split(".")[1] || this.getAssetId();
74
+ }
75
+ getName() {
76
+ return this.name ? this.name : null;
77
+ }
78
+ getMarkets() {
79
+ return this.markets ? this.markets : null;
80
+ }
81
+ getBlockchain() {
82
+ return this.blockchain;
83
+ }
84
+ getPrice() {
85
+ return {
86
+ latestPriceAmount: this.price.latestPriceAmount
87
+ ? this.price.latestPriceAmount
88
+ : null,
89
+ latestPriceCurrency: this.price.latestPriceCurrency
90
+ ? this.price.latestPriceCurrency
91
+ : null,
92
+ };
93
+ }
94
+ getBlockTimestamp() {
95
+ return this.blockTimestamp;
96
+ }
97
+ getAttributes() {
98
+ return this.attributes?.length
99
+ ? this.attributes
100
+ : [];
101
+ }
102
+ getDescription() {
103
+ return this.description ? this.description : null;
104
+ }
105
+ getTokenId() {
106
+ return this.tokenId ? this.tokenId : null;
107
+ }
108
+ getCollection() {
109
+ return {
110
+ collectionId: this.collection.collectionId
111
+ ? this.collection.collectionId
112
+ : null,
113
+ collectionTitle: this.collection.collectionTitle
114
+ ? this.collection.collectionTitle
115
+ : null,
116
+ collectionMedias: this.collection.collectionMedias?.length
117
+ ? this.collection.collectionMedias
118
+ : [],
119
+ };
120
+ }
121
+ getCategory() {
122
+ return this.category ? this.category : null;
123
+ }
124
+ getCategoryLabel() {
125
+ return this.categoryLabel ? this.categoryLabel : null;
126
+ }
127
+ getOriginalUrls() {
128
+ if (!this.originalUrls)
129
+ return null;
130
+ const convertedOriginalUrlsArray = [];
131
+ for (let i = 0; i < this.originalUrls?.length; i++) {
132
+ convertedOriginalUrlsArray.push({
133
+ url: (0, utils_1.checkGltfUrl)(this.originalUrls[i] || ""),
134
+ mimeType: null,
135
+ originalMime: null,
136
+ });
137
+ }
138
+ return convertedOriginalUrlsArray;
139
+ }
140
+ getItemType() {
141
+ return this.itemType;
142
+ }
143
+ getRank() {
144
+ return this.rank ? Math.round(this.rank) : 0;
145
+ }
146
+ getAddress() {
147
+ return this.address ? this.address : null;
148
+ }
149
+ getAssetLink() {
150
+ if (this.getItemType() === ItemType_1.LabelKeys.asset) {
151
+ if (this.getBlockchain().getBlockChainPrivateLabel() ===
152
+ (core_1.BlockChainKeys.elrond || core_1.BlockChainKeys.solana)) {
153
+ return `/${this.getItemType()}/${this.getBlockchain().getBlockChainPrivateLabel()}/${this.getAssetId()}`;
154
+ }
155
+ else {
156
+ return `/${this.getItemType()}/${this.getBlockchain().getBlockChainPrivateLabel()}/${this.getAddress()}/${this.getTokenId()}`;
157
+ }
158
+ }
159
+ return `/${this.getItemType()}/${this.getAssetId()}`;
160
+ }
161
+ getOwnersProfiles() {
162
+ return this.ownersProfiles
163
+ ? this.ownersProfiles
164
+ : [];
165
+ }
166
+ getAssetMedias() {
167
+ return this.medias ? this.medias : [];
168
+ }
169
+ getCreatorsProfiles() {
170
+ return this.creatorsProfiles
171
+ ? this.creatorsProfiles
172
+ : [];
173
+ }
174
+ getOwnersAddresses() {
175
+ return this.ownersAddresses ? this.ownersAddresses : null;
176
+ }
177
+ getCreatorsAddresses() {
178
+ return this.creatorsAddresses ? this.creatorsAddresses : null;
179
+ }
180
+ }
181
+ exports.default = AssetSearchEntity;
@@ -0,0 +1,36 @@
1
+ import { assetSchema as schema } from '@ludo.ninja/api';
2
+ import { BlockChainEntity, MarketPlaceEntity } from '@ludo.ninja/core';
3
+ import { LabelKeys } from '../common/ItemType';
4
+ interface IAssetSearchEntity {
5
+ getAssetId(): string;
6
+ getBlockchain(): BlockChainEntity;
7
+ getOwnersProfiles(): schema.IProfile[];
8
+ getBlockTimestamp(): number;
9
+ getCreatorsProfiles(): schema.IProfile[];
10
+ getSplitedAssetId(): string;
11
+ getAttributes(): schema.IAttribute[];
12
+ getOwnersAddresses(): string[] | null;
13
+ getCreatorsAddresses(): string[] | null;
14
+ getIsSlider(): boolean;
15
+ getMarkets(): MarketPlaceEntity[] | null;
16
+ getPrice(): {
17
+ latestPriceAmount: number | null;
18
+ latestPriceCurrency: string | null;
19
+ };
20
+ getAssetMedias(): schema.IMedia[];
21
+ getItemType(): LabelKeys;
22
+ getName(): null | string;
23
+ getOriginalUrls(): schema.IMedia[] | null;
24
+ getAddress(): string | null;
25
+ getCollection(): {
26
+ collectionId: string | null;
27
+ collectionTitle: string | null;
28
+ collectionMedias: schema.IMedia[];
29
+ };
30
+ getCategory(): string | null;
31
+ getCategoryLabel(): string | null;
32
+ getTokenId(): string | null;
33
+ getDescription(): string | null;
34
+ getRank(): number;
35
+ }
36
+ export default IAssetSearchEntity;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,12 +4,83 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = require("react");
7
8
  const image_1 = __importDefault(require("next/image"));
8
9
  const link_1 = __importDefault(require("next/link"));
9
- const UserPicSpa_1 = __importDefault(require("./UserPicSpa"));
10
+ const react_loading_skeleton_1 = __importDefault(require("react-loading-skeleton"));
11
+ const styled_components_1 = __importDefault(require("styled-components"));
12
+ const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
13
+ const store_1 = require("../../../modules/user/store");
14
+ const env_1 = require("../../../store/env");
15
+ const ScreenWidth_1 = require("../../../styles/ScreenWidth");
16
+ const boxTransform_1 = __importDefault(require("../../../styles/mixins/boxTransform"));
17
+ const ImageInterceptor_1 = require("../ImageInterceptor");
18
+ const useFetchUserPic_1 = __importDefault(require("../../../api/server-medias/queries/useFetchUserPic"));
19
+ const defaultUserpic_svg_1 = __importDefault(require("../../../public/defaultUserpics/defaultUserpic"));
20
+ const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
21
+ // Styles
22
+ const StyledHeaderUserPic = styled_components_1.default.div `
23
+ ${(props) => (props.isNeedBoxTransform ? boxTransform_1.default : null)}
24
+ .userPicBlock {
25
+ display: flex;
26
+ }
27
+
28
+ .userPicImage {
29
+ border-radius: 50%;
30
+ width: ${(props) => props.imageWidth};
31
+ height: ${(props) => props.imageHeight};
32
+
33
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
34
+ width: ${(props) => (0, _4k_1.adaptiveValueCalc)(Number(props.imageWidth.replace("px", "")))};
35
+ height: ${(props) => (0, _4k_1.adaptiveValueCalc)(Number(props.imageHeight.replace("px", "")))};
36
+ }
37
+ }
38
+ `;
10
39
  // Component
11
40
  const UserPic = ({ userId, width, height, isNeedBoxTransform, children, }) => {
12
- return ((0, jsx_runtime_1.jsx)(UserPicSpa_1.default, { userId: userId, Link: link_1.default, height: height, Image: image_1.default, width: width, isNeedBoxTransform: isNeedBoxTransform, children: children }));
41
+ const getMediaENVDomain = (0, env_1.useEnvStore)((state) => state.getMediaDomain);
42
+ const { isSignedIn, isLoadingProfileData, profileData } = (0, store_1.useUserStore)((state) => ({
43
+ isSignedIn: state.isSignedIn,
44
+ isLoadingProfileData: state.isLoadingProfileData,
45
+ profileData: state.profileData,
46
+ }));
47
+ const { load, userPic, loading } = (0, useFetchUserPic_1.default)();
48
+ const profileUserPic = profileData
49
+ ?.getUserPic({
50
+ mediaDomain: getMediaENVDomain(),
51
+ })
52
+ .includes("1.svg")
53
+ ? null
54
+ : profileData?.getUserPic({
55
+ mediaDomain: getMediaENVDomain(),
56
+ });
57
+ (0, react_1.useEffect)(() => {
58
+ if (isSignedIn &&
59
+ !isLoadingProfileData &&
60
+ profileData
61
+ ?.getUserPic({
62
+ mediaDomain: getMediaENVDomain(),
63
+ })
64
+ .includes("1.svg")) {
65
+ load(userId);
66
+ }
67
+ }, [userId, isSignedIn, isLoadingProfileData, profileData]);
68
+ const renderDefaultUserPic = () => {
69
+ return (0, jsx_runtime_1.jsx)(defaultUserpic_svg_1.default, { className: "userPicImage" });
70
+ };
71
+ const renderImage = () => {
72
+ return ((0, jsx_runtime_1.jsx)(ImageInterceptor_1.ImageInterceptor, { borderRadiusSkeleton: "50%", children: (0, jsx_runtime_1.jsx)(image_1.default, { src: (profileUserPic || userPic), className: "userPicImage", width: width, height: height, priority: true, alt: "ludo ninja userPick" }) }));
73
+ };
74
+ const renderImageOrDefaultUserPic = () => {
75
+ return profileUserPic || userPic ? renderImage() : renderDefaultUserPic();
76
+ };
77
+ const renderSkeleton = () => {
78
+ return (0, jsx_runtime_1.jsx)(react_loading_skeleton_1.default, { className: "userPicImage" });
79
+ };
80
+ const NEXT_PUBLIC_ENV_VALUE = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_ENV_VALUE);
81
+ return ((0, jsx_runtime_1.jsx)(StyledHeaderUserPic, { isNeedBoxTransform: isNeedBoxTransform, imageWidth: `${width}px`, imageHeight: `${height}px`, children: (0, jsx_runtime_1.jsxs)(link_1.default, { href: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["profile"]}/${userId}/nfts`, className: "userPicBlock", children: [loading || isLoadingProfileData
82
+ ? renderSkeleton()
83
+ : renderImageOrDefaultUserPic(), children] }) }));
13
84
  };
14
85
  // Export
15
86
  exports.default = UserPic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ludo.ninja/components",
3
- "version": "2.1.41",
3
+ "version": "2.1.43",
4
4
  "private": false,
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",