@ludo.ninja/components 2.2.36 → 2.2.38

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.
Files changed (92) hide show
  1. package/build/api/server-galleries/queries/useFetchGallery/index.d.ts +5 -5
  2. package/build/api/server-galleries/queries/useFetchGallery/index.js +5 -8
  3. package/build/api/server-galleries/queries/useFetchMyFavorites/index.d.ts +3 -3
  4. package/build/api/server-galleries/queries/useFetchMyFavorites/index.js +5 -11
  5. package/build/api/server-galleries/queries/useFetchMyGalleries/index.d.ts +3 -3
  6. package/build/api/server-galleries/queries/useFetchMyGalleries/index.js +5 -11
  7. package/build/api/server-galleries/queries/useFetchUserFavorites/index.d.ts +4 -4
  8. package/build/api/server-galleries/queries/useFetchUserFavorites/index.js +6 -9
  9. package/build/api/server-search/queries/useFetchAllCreations/index.d.ts +7 -7
  10. package/build/api/server-search/queries/useFetchAllCreations/index.js +7 -10
  11. package/build/api/server-search/queries/useFetchCollections/index.d.ts +6 -6
  12. package/build/api/server-search/queries/useFetchCollections/index.js +10 -12
  13. package/build/api/server-search/queries/useFetchDynamicCollectionData/index.d.ts +4 -4
  14. package/build/api/server-search/queries/useFetchDynamicCollectionData/index.js +8 -11
  15. package/build/api/server-search/queries/useFindCreations/index.d.ts +7 -7
  16. package/build/api/server-search/queries/useFindCreations/index.js +9 -12
  17. package/build/api/server-search/queries/useFindUserCreations/index.d.ts +3 -3
  18. package/build/api/server-search/queries/useFindUserCreations/index.js +7 -10
  19. package/build/api/server-search/queries/useFindUserLudoCreations/index.d.ts +3 -3
  20. package/build/api/server-search/queries/useFindUserLudoCreations/index.js +7 -10
  21. package/build/components/assetPage/assetLikes/index.js +7 -7
  22. package/build/components/gallery/add/addCreationToGallery/index.js +7 -7
  23. package/build/components/search/searchSuggestions/index.js +2 -2
  24. package/build/dto/AssetEntity/index.d.ts +3 -3
  25. package/build/dto/AssetEntity/index.js +16 -33
  26. package/build/dto/AssetSearchEntity/index.d.ts +2 -2
  27. package/build/dto/AssetSearchEntity/index.js +12 -29
  28. package/build/dto/Collection/CollectionCreationEntity/index.d.ts +3 -3
  29. package/build/dto/Collection/CollectionCreationEntity/index.js +13 -13
  30. package/build/dto/Collection/CollectionCreationEntity/interface.d.ts +2 -2
  31. package/build/dto/Collection/CollectionEntity/index.d.ts +2 -2
  32. package/build/dto/Collection/CollectionEntity/index.js +1 -1
  33. package/build/dto/CreationEntity/index.d.ts +3 -3
  34. package/build/dto/CreationEntity/index.js +9 -9
  35. package/build/dto/GalleryEntityV2/index.d.ts +4 -4
  36. package/build/dto/GalleryEntityV2/index.js +6 -8
  37. package/build/dto/common/ItemType/data.d.ts +1 -1
  38. package/build/dto/common/ItemType/data.js +25 -25
  39. package/build/entities/creation/collectionCreationBuilder.d.ts +2 -2
  40. package/build/entities/creation/collectionCreationBuilder.js +4 -3
  41. package/build/entities/gallery/builder.js +1 -1
  42. package/build/hooks/favorites/useGetFavoriteGallaryCreations/index.d.ts +6 -7
  43. package/build/hooks/favorites/useGetFavoriteGallaryCreations/index.js +19 -23
  44. package/build/hooks/favorites/useGetUserFevoritesCreations/index.d.ts +8 -9
  45. package/build/hooks/favorites/useGetUserFevoritesCreations/index.js +25 -38
  46. package/build/hooks/galleries/useGetUserGalleriesCreations/index.d.ts +8 -9
  47. package/build/hooks/galleries/useGetUserGalleriesCreations/index.js +25 -38
  48. package/build/hooks/likes/dynamic/useFindCollectionsAndLikes.d.ts +6 -6
  49. package/build/hooks/likes/dynamic/useFindCollectionsAndLikes.js +15 -17
  50. package/build/hooks/likes/dynamic/useFindCreationsAndLikes.d.ts +4 -4
  51. package/build/hooks/likes/dynamic/useFindCreationsAndLikes.js +12 -15
  52. package/build/hooks/likes/dynamic/useGetCollectionInfoAndLikes.d.ts +4 -4
  53. package/build/hooks/likes/dynamic/useGetCollectionInfoAndLikes.js +11 -18
  54. package/build/hooks/likes/dynamic/useGetCreationsAndLikes.d.ts +4 -5
  55. package/build/hooks/likes/dynamic/useGetCreationsAndLikes.js +12 -17
  56. package/build/hooks/likes/dynamic/useGetCreationsAndLikesByType.d.ts +4 -4
  57. package/build/hooks/likes/dynamic/useGetCreationsAndLikesByType.js +16 -19
  58. package/build/hooks/likes/dynamic/useGetMixedLikesFavoriteList.d.ts +5 -6
  59. package/build/hooks/likes/dynamic/useGetMixedLikesFavoriteList.js +9 -10
  60. package/build/hooks/likes/dynamic/useGetTableLikes.d.ts +4 -5
  61. package/build/hooks/likes/dynamic/useGetTableLikes.js +14 -21
  62. package/build/hooks/likes/index.d.ts +1 -1
  63. package/build/hooks/likes/index.js +12 -12
  64. package/build/modules/gallery/api/useGetAssetsAndCollectionForFavorite.d.ts +5 -5
  65. package/build/modules/gallery/api/useGetAssetsAndCollectionForFavorite.js +39 -47
  66. package/build/modules/gallery/store.d.ts +3 -3
  67. package/build/modules/gallery/store.js +7 -11
  68. package/build/modules/gallery/ui/EditGallery.d.ts +2 -2
  69. package/build/modules/gallery/ui/EditGallery.js +11 -11
  70. package/build/modules/gallery/ui/chooseGalleryItems/chooseGalleryItem/index.d.ts +3 -3
  71. package/build/modules/gallery/ui/chooseGalleryItems/chooseGalleryItem/index.js +1 -1
  72. package/build/modules/gallery/ui/chooseGalleryItems/index.d.ts +1 -1
  73. package/build/modules/gallery/ui/chooseGalleryItems/index.js +19 -20
  74. package/build/modules/gallery/ui/itemsPreview/index.d.ts +2 -3
  75. package/build/modules/gallery/ui/itemsPreview/index.js +9 -4
  76. package/build/modules/gallery/useToGalleryAsset.d.ts +5 -5
  77. package/build/modules/gallery/useToGalleryAsset.js +7 -7
  78. package/build/modules/opportunity/OpportunityCard.js +25 -27
  79. package/build/modules/virtuoso/types.d.ts +0 -3
  80. package/build/system/Cards/CardContent/CardCategory/CardCategory.test.d.ts +1 -1
  81. package/build/system/Cards/CardContent/CardCategory/CardCategory.test.js +9 -9
  82. package/build/system/Cards/CardContent/CardCategory/index.d.ts +1 -1
  83. package/build/system/Cards/CardContent/CardCategory/index.js +3 -3
  84. package/build/system/Cards/CreationCard/CardHead.d.ts +2 -3
  85. package/build/system/Cards/CreationCard/CardHead.js +16 -30
  86. package/build/system/Cards/CreationCard/index.d.ts +4 -4
  87. package/build/system/Cards/CreationCard/index.js +10 -9
  88. package/build/system/Cards/MultiMediaCard/index.d.ts +5 -6
  89. package/build/system/Cards/MultiMediaCard/index.js +8 -7
  90. package/build/utils/extractItemIds.d.ts +2 -2
  91. package/build/utils/extractItemIds.js +1 -7
  92. package/package.json +1 -1
@@ -3,14 +3,14 @@ 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
- const core_1 = require("@ludo.ninja/core");
7
- const ItemType_1 = require("../common/ItemType");
8
- const data_1 = __importDefault(require("../common/ItemType/data"));
9
6
  const CreationAudio_1 = __importDefault(require("../common/ItemViews/CreationAudio"));
10
7
  const CreationImage_1 = __importDefault(require("../common/ItemViews/CreationImage"));
11
8
  const CreationObject_1 = __importDefault(require("../common/ItemViews/CreationObject"));
12
9
  const CreationOther_1 = __importDefault(require("../common/ItemViews/CreationOther"));
13
10
  const CreationVideo_1 = __importDefault(require("../common/ItemViews/CreationVideo"));
11
+ const types_1 = require("../../entities/labelCreationType/types");
12
+ const data_1 = __importDefault(require("../../entities/labelCreationType/data"));
13
+ const core_1 = require("@ludo.ninja/core");
14
14
  class CreationEntity {
15
15
  itemId;
16
16
  itemType;
@@ -57,13 +57,13 @@ class CreationEntity {
57
57
  }
58
58
  // accessors
59
59
  getAddress() {
60
- return this.address ? this.address : '';
60
+ return this.address ? this.address : "";
61
61
  }
62
62
  getId() {
63
- return this.id ? this.id : '';
63
+ return this.id ? this.id : "";
64
64
  }
65
65
  getTokenId() {
66
- return this.tokenId ? this.tokenId : '';
66
+ return this.tokenId ? this.tokenId : "";
67
67
  }
68
68
  getItemId() {
69
69
  return this.itemId;
@@ -87,7 +87,7 @@ class CreationEntity {
87
87
  return this.isCheckboxSelected;
88
88
  }
89
89
  getCreationLink() {
90
- if (this.getItemType() === ItemType_1.LabelKeys.asset) {
90
+ if (this.getItemType() === types_1.LabelKeys.asset) {
91
91
  const blockChainPrivateLabel = this.getBlockchain().getBlockChainPrivateLabel();
92
92
  if (blockChainPrivateLabel === core_1.BlockChainKeys.elrond) {
93
93
  return `/${this.getItemType()}/${this.getBlockchain().getBlockChainPrivateLabel()}/${this.getId()}`;
@@ -144,10 +144,10 @@ class CreationEntity {
144
144
  return null;
145
145
  return isMobileView
146
146
  ? this.name && this.name.length >= 20
147
- ? this.name?.substring(0, 22).concat('...')
147
+ ? this.name?.substring(0, 22).concat("...")
148
148
  : this.name
149
149
  : this.name && this.name.length >= 11
150
- ? this.name?.substring(0, 13).concat('...')
150
+ ? this.name?.substring(0, 13).concat("...")
151
151
  : this.name;
152
152
  }
153
153
  // methods
@@ -1,7 +1,7 @@
1
- import { galleriesSchema as schema } from '@ludo.ninja/api';
2
- import { ProfileEntity } from '@ludo.ninja/core';
3
- import { LabelKeys, LabelType } from '../common/ItemType';
4
- import IGalleryEntityV2 from './interface';
1
+ import { LabelKeys, LabelType } from "../common/ItemType";
2
+ import IGalleryEntityV2 from "./interface";
3
+ import { galleriesSchema as schema } from "@ludo.ninja/api";
4
+ import { ProfileEntity } from "@ludo.ninja/core";
5
5
  declare class GalleryEntityV2 implements IGalleryEntityV2 {
6
6
  private galleryId;
7
7
  private galleryType;
@@ -3,8 +3,8 @@ 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
+ const data_1 = __importDefault(require("../../entities/labelCreationType/data"));
6
7
  const core_1 = require("@ludo.ninja/core");
7
- const data_1 = __importDefault(require("../common/ItemType/data"));
8
8
  class GalleryEntityV2 {
9
9
  galleryId;
10
10
  galleryType;
@@ -45,10 +45,10 @@ class GalleryEntityV2 {
45
45
  return this.galleryId;
46
46
  }
47
47
  getGalleryUsername() {
48
- return this.username ?? '';
48
+ return this.username ?? "";
49
49
  }
50
50
  getGalleryUserpic() {
51
- return this.userpic ?? '';
51
+ return this.userpic ?? "";
52
52
  }
53
53
  getGalleryUserWallets() {
54
54
  return this.userWallets;
@@ -57,15 +57,13 @@ class GalleryEntityV2 {
57
57
  return this.name;
58
58
  }
59
59
  getGalleryItemsCount() {
60
- return this.items
61
- ? `${this?.items > 1 ? `${this?.items} items` : `${this?.items} item`}`
62
- : '0 items';
60
+ return this.items ? `${this?.items > 1 ? `${this?.items} items` : `${this?.items} item`}` : "0 items";
63
61
  }
64
62
  getGalleryCreationIds() {
65
63
  return this.creationIds ? this.creationIds : [];
66
64
  }
67
65
  getGalleryDescription() {
68
- return this.description ? this.description : '';
66
+ return this.description ? this.description : "";
69
67
  }
70
68
  getGalleryType() {
71
69
  return this.galleryType;
@@ -74,7 +72,7 @@ class GalleryEntityV2 {
74
72
  return data_1.default[this.getGalleryType()];
75
73
  }
76
74
  getCreationLink() {
77
- return this.getGalleryType() === 'likelist'
75
+ return this.getGalleryType() === "likelist"
78
76
  ? `/favorites/${this.getGalleryId()}`
79
77
  : `/${this.getGalleryType()}/${this.getGalleryId()}`;
80
78
  }
@@ -1,3 +1,3 @@
1
- import { LabelItem } from './';
1
+ import { LabelItem } from '../../../entities/labelCreationType/types';
2
2
  declare const labelsData: LabelItem;
3
3
  export default labelsData;
@@ -1,36 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const ItemType_1 = require("./");
3
+ const types_1 = require("../../../entities/labelCreationType/types");
4
4
  const labelsData = {
5
- [ItemType_1.LabelKeys.asset]: {
6
- backgroundColor: ItemType_1.LabelBackground.asset,
7
- color: ItemType_1.LabelColor.asset,
8
- text: ItemType_1.LabelText.asset,
5
+ [types_1.LabelKeys.asset]: {
6
+ backgroundColor: types_1.LabelBackground.asset,
7
+ color: types_1.LabelColor.asset,
8
+ text: types_1.LabelText.asset,
9
9
  },
10
- [ItemType_1.LabelKeys.collection]: {
11
- backgroundColor: ItemType_1.LabelBackground.collection,
12
- color: ItemType_1.LabelColor.collection,
13
- text: ItemType_1.LabelText.collection,
10
+ [types_1.LabelKeys.collection]: {
11
+ backgroundColor: types_1.LabelBackground.collection,
12
+ color: types_1.LabelColor.collection,
13
+ text: types_1.LabelText.collection,
14
14
  },
15
- [ItemType_1.LabelKeys.gallery]: {
16
- backgroundColor: ItemType_1.LabelBackground.gallery,
17
- color: ItemType_1.LabelColor.gallery,
18
- text: ItemType_1.LabelText.gallery,
15
+ [types_1.LabelKeys.gallery]: {
16
+ backgroundColor: types_1.LabelBackground.gallery,
17
+ color: types_1.LabelColor.gallery,
18
+ text: types_1.LabelText.gallery,
19
19
  },
20
- [ItemType_1.LabelKeys.favorites]: {
21
- backgroundColor: ItemType_1.LabelBackground.favorites,
22
- color: ItemType_1.LabelColor.favorites,
23
- text: ItemType_1.LabelText.favorites,
20
+ [types_1.LabelKeys.favorites]: {
21
+ backgroundColor: types_1.LabelBackground.favorites,
22
+ color: types_1.LabelColor.favorites,
23
+ text: types_1.LabelText.favorites,
24
24
  },
25
- [ItemType_1.LabelKeys.likelist]: {
26
- backgroundColor: ItemType_1.LabelBackground.likelist,
27
- color: ItemType_1.LabelColor.likelist,
28
- text: ItemType_1.LabelText.likelist,
25
+ [types_1.LabelKeys.likelist]: {
26
+ backgroundColor: types_1.LabelBackground.likelist,
27
+ color: types_1.LabelColor.likelist,
28
+ text: types_1.LabelText.likelist,
29
29
  },
30
- [ItemType_1.LabelKeys.opportunity]: {
31
- backgroundColor: ItemType_1.LabelBackground.opportunity,
32
- color: ItemType_1.LabelColor.opportunity,
33
- text: ItemType_1.LabelText.opportunity,
30
+ [types_1.LabelKeys.opportunity]: {
31
+ backgroundColor: types_1.LabelBackground.opportunity,
32
+ color: types_1.LabelColor.opportunity,
33
+ text: types_1.LabelText.opportunity,
34
34
  },
35
35
  };
36
36
  exports.default = labelsData;
@@ -1,3 +1,3 @@
1
1
  import { LabelKeys } from '../labelCreationType/types';
2
- import { collectionsSchema as schema } from "@ludo.ninja/api";
3
- export declare const buildCollectionCreation: (creation: schema.ICollectionAsset, type?: LabelKeys) => import("./types").TCreation;
2
+ import { collectionsSchema, searchSchema } from "@ludo.ninja/api";
3
+ export declare const buildCollectionCreation: (creation: collectionsSchema.ICollectionAsset | searchSchema.ICollection, type?: LabelKeys) => import("./types").TCreation;
@@ -6,10 +6,10 @@ const types_1 = require("../labelCreationType/types");
6
6
  const utils_1 = require("@ludo.ninja/utils");
7
7
  const buildCollectionCreation = (creation, type) => (0, builder_1.buildCreation)({
8
8
  itemId: creation.collectionId || "",
9
- id: creation.id || "",
9
+ id: "id" in creation ? creation.id || "" : "",
10
10
  itemType: type ?? types_1.LabelKeys.asset,
11
11
  blockchain: creation.blockchain,
12
- address: creation.address,
12
+ address: "address" in creation ? creation.address : null,
13
13
  tokenId: creation.tokenId,
14
14
  originalUrls: creation.originalUrls
15
15
  ? creation.originalUrls.map((el) => (0, utils_1.checkGltfUrl)(el || ""))
@@ -17,9 +17,10 @@ const buildCollectionCreation = (creation, type) => (0, builder_1.buildCreation)
17
17
  rank: creation.rank,
18
18
  likes: creation.likes,
19
19
  liked: creation.liked,
20
- name: creation.name,
20
+ name: "name" in creation ? creation.name : null,
21
21
  creatorsAddresses: creation.creatorsAddresses,
22
22
  media: creation?.medias?.[0]?.url || null,
23
23
  mimeType: creation?.medias?.[0]?.mimeType,
24
24
  });
25
25
  exports.buildCollectionCreation = buildCollectionCreation;
26
+ //todo: update collectionCreationId to new field in TCreation
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.buildGallery = void 0;
7
- const data_1 = __importDefault(require("../../dto/common/ItemType/data"));
7
+ const data_1 = __importDefault(require("../labelCreationType/data"));
8
8
  const core_1 = require("@ludo.ninja/core");
9
9
  const buildGallery = (gallery) => {
10
10
  const newGallery = {
@@ -1,14 +1,13 @@
1
- import { IQueryFetchGalleryV2Args } from '@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema';
2
- import CollectionCreationEntity from '../../../dto/Collection/CollectionCreationEntity';
3
- import CreationEntity from '../../../dto/CreationEntity';
4
- import GalleryEntityV2 from '../../../dto/GalleryEntityV2';
1
+ import { TCreation } from '../../../entities/creation/types';
2
+ import { TGallery } from '../../../entities/gallery/types';
3
+ import { IQueryFetchGalleryV2Args } from "@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema";
5
4
  declare const useGetFavoriteGallaryCreations: ({ galleryId, itemsCount, }: {
6
5
  galleryId: string;
7
6
  itemsCount: number | null;
8
7
  }) => {
9
- gallery: GalleryEntityV2[] | null;
8
+ gallery: TGallery[] | null;
10
9
  loading: boolean;
11
- creationsList: (CreationEntity | CollectionCreationEntity)[];
10
+ creationsList: TCreation[];
12
11
  loadingAssets: boolean;
13
12
  loadingGallery: boolean;
14
13
  loadingCollections: boolean;
@@ -17,7 +16,7 @@ declare const useGetFavoriteGallaryCreations: ({ galleryId, itemsCount, }: {
17
16
  errorGallery: import("@apollo/client").ApolloError | undefined;
18
17
  fetchError: boolean;
19
18
  allResults: number | null;
20
- refetchQueryGalleryCreation: ({ galleryId, }: IQueryFetchGalleryV2Args) => Promise<void>;
19
+ refetchQueryGalleryCreation: ({ galleryId }: IQueryFetchGalleryV2Args) => Promise<void>;
21
20
  loadMore: () => void;
22
21
  };
23
22
  export { useGetFavoriteGallaryCreations };
@@ -1,20 +1,18 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.useGetFavoriteGallaryCreations = void 0;
7
- const react_1 = require("react");
4
+ const useGetUserFevoritesCreations_1 = require("../useGetUserFevoritesCreations");
5
+ const builder_1 = require("../../../entities/creation/builder");
6
+ const collectionCreationBuilder_1 = require("../../../entities/creation/collectionCreationBuilder");
7
+ const builder_2 = require("../../../entities/gallery/builder");
8
+ const types_1 = require("../../../entities/labelCreationType/types");
9
+ const ui_1 = require("../../../store/ui");
8
10
  const client_1 = require("@apollo/client");
9
11
  const api_1 = require("@ludo.ninja/api");
10
12
  const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema");
11
13
  const schema_2 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
12
14
  const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
13
- const ui_1 = require("../../../store/ui");
14
- const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
15
- const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
16
- const GalleryEntityV2_1 = __importDefault(require("../../../dto/GalleryEntityV2"));
17
- const useGetUserFevoritesCreations_1 = require("../useGetUserFevoritesCreations");
15
+ const react_1 = require("react");
18
16
  const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
19
17
  const [gallery, setGallery] = (0, react_1.useState)([]);
20
18
  const [assets, setAssets] = (0, react_1.useState)(null);
@@ -30,9 +28,9 @@ const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
30
28
  uri: api_1.hosts.galleriesHost,
31
29
  },
32
30
  notifyOnNetworkStatusChange: true,
33
- fetchPolicy: 'no-cache',
31
+ fetchPolicy: "no-cache",
34
32
  onCompleted: ({ fetchGalleryV2 }) => {
35
- setGallery([new GalleryEntityV2_1.default(fetchGalleryV2)]);
33
+ setGallery([(0, builder_2.buildGallery)(fetchGalleryV2)]);
36
34
  setAllResults(fetchGalleryV2.items);
37
35
  },
38
36
  onError: () => {
@@ -44,13 +42,13 @@ const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
44
42
  });
45
43
  const [fetchAssets, { loading: assetsLoading, error: assetsError }] = (0, client_1.useLazyQuery)(schema_2.FetchAssetsDocument, {
46
44
  context: { uri: api_1.hosts.searchHost },
47
- fetchPolicy: 'no-cache',
45
+ fetchPolicy: "no-cache",
48
46
  onCompleted: ({ fetchAssets: data }) => {
49
47
  setAssets((prevAssets) => [
50
48
  ...(prevAssets || []),
51
- ...data.map((asset) => new CreationEntity_1.default({
49
+ ...data.map((asset) => (0, builder_1.buildCreation)({
52
50
  ...asset,
53
- itemType: 'asset',
51
+ itemType: "asset",
54
52
  itemId: asset.assetId,
55
53
  })),
56
54
  ]);
@@ -58,25 +56,25 @@ const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
58
56
  onError: () => {
59
57
  openAlert({
60
58
  type: type_1.alertVariants.error,
61
- caption: 'Oops, something went wrong.',
59
+ caption: "Oops, something went wrong.",
62
60
  });
63
61
  setAssets([]);
64
62
  setFetchError(true);
65
63
  },
66
64
  });
67
- const [fetchCollections, { loading: collectionsLoading, error: collectionsError },] = (0, client_1.useLazyQuery)(schema_2.FetchCollectionsByIdsDocument, {
65
+ const [fetchCollections, { loading: collectionsLoading, error: collectionsError }] = (0, client_1.useLazyQuery)(schema_2.FetchCollectionsByIdsDocument, {
68
66
  context: { uri: api_1.hosts.searchHost },
69
- fetchPolicy: 'no-cache',
67
+ fetchPolicy: "no-cache",
70
68
  onCompleted: ({ fetchCollectionsByIds: data }) => {
71
69
  setCollections((prevCollections) => [
72
70
  ...(prevCollections || []),
73
- ...data.map((collection) => new CollectionCreationEntity_1.default(collection, 'collection')),
71
+ ...data.map((collection) => (0, collectionCreationBuilder_1.buildCollectionCreation)(collection, types_1.LabelKeys.collection)),
74
72
  ]);
75
73
  },
76
74
  onError: () => {
77
75
  openAlert({
78
76
  type: type_1.alertVariants.error,
79
- caption: 'Oops, something went wrong.',
77
+ caption: "Oops, something went wrong.",
80
78
  });
81
79
  setCollections([]);
82
80
  setFetchError(true);
@@ -85,9 +83,7 @@ const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
85
83
  (0, react_1.useEffect)(() => {
86
84
  if (gallery && gallery.length > 0) {
87
85
  const { assetArray, collectionsArray } = (0, useGetUserFevoritesCreations_1.getMediaForGallery)(gallery, false, currentPage, itemsCount);
88
- const assetPromise = assetArray.length > 0
89
- ? fetchAssets({ variables: { assetIds: assetArray } })
90
- : Promise.resolve();
86
+ const assetPromise = assetArray.length > 0 ? fetchAssets({ variables: { assetIds: assetArray } }) : Promise.resolve();
91
87
  const collectionsPromise = collectionsArray.length > 0
92
88
  ? fetchCollections({ variables: { collectionIds: collectionsArray } })
93
89
  : Promise.resolve();
@@ -101,7 +97,7 @@ const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
101
97
  });
102
98
  }
103
99
  }, [gallery, fetchAssets, fetchCollections, currentPage]);
104
- async function refetchQueryGalleryCreation({ galleryId, }) {
100
+ async function refetchQueryGalleryCreation({ galleryId }) {
105
101
  await refetch({ galleryId });
106
102
  }
107
103
  function loadMore() {
@@ -1,11 +1,10 @@
1
- import { IQueryFetchUserFavoritesV2Args } from '@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema';
2
- import CollectionCreationEntity from '../../../dto/Collection/CollectionCreationEntity';
3
- import CreationEntity from '../../../dto/CreationEntity';
4
- import GalleryEntityV2 from '../../../dto/GalleryEntityV2';
5
- declare const useGetUserFevoritesCreations: ({ userId, pageSize, pageToken, }: IQueryFetchUserFavoritesV2Args) => {
6
- favorites: GalleryEntityV2[];
7
- assets: CreationEntity[] | null;
8
- collections: CollectionCreationEntity[] | null;
1
+ import { TCreation } from '../../../entities/creation/types';
2
+ import { TGallery } from '../../../entities/gallery/types';
3
+ import { IQueryFetchUserFavoritesV2Args } from "@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema";
4
+ declare const useGetUserFevoritesCreations: ({ userId, pageSize, pageToken }: IQueryFetchUserFavoritesV2Args) => {
5
+ favorites: TGallery[];
6
+ assets: TCreation[] | null;
7
+ collections: TCreation[] | null;
9
8
  loading: boolean;
10
9
  loadingAssets: boolean;
11
10
  loadingFavorites: boolean;
@@ -18,7 +17,7 @@ declare const useGetUserFevoritesCreations: ({ userId, pageSize, pageToken, }: I
18
17
  isNextLoading: boolean;
19
18
  };
20
19
  export { useGetUserFevoritesCreations };
21
- export declare function getMediaForGallery(favorites: GalleryEntityV2[], takeFirstFour: boolean, pageNumber?: number, totalLength?: number | null): {
20
+ export declare function getMediaForGallery(favorites: TGallery[], takeFirstFour: boolean, pageNumber?: number, totalLength?: number | null): {
22
21
  assetArray: unknown[];
23
22
  collectionsArray: unknown[];
24
23
  };
@@ -1,22 +1,19 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.useGetUserFevoritesCreations = void 0;
7
4
  exports.getMediaForGallery = getMediaForGallery;
8
- const react_1 = require("react");
5
+ const builder_1 = require("../../../entities/creation/builder");
6
+ const collectionCreationBuilder_1 = require("../../../entities/creation/collectionCreationBuilder");
7
+ const builder_2 = require("../../../entities/gallery/builder");
8
+ const ui_1 = require("../../../store/ui");
9
9
  const client_1 = require("@apollo/client");
10
10
  const api_1 = require("@ludo.ninja/api");
11
11
  const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema");
12
12
  const schema_2 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
13
13
  const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
14
- const ui_1 = require("../../../store/ui");
15
- const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
16
- const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
17
- const GalleryEntityV2_1 = __importDefault(require("../../../dto/GalleryEntityV2"));
14
+ const react_1 = require("react");
18
15
  const maxUserFavoritesLength = 1000;
19
- const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
16
+ const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken }) => {
20
17
  const [assets, setAsset] = (0, react_1.useState)(null);
21
18
  const [collections, setCollections] = (0, react_1.useState)(null);
22
19
  const [favorites, setFavorites] = (0, react_1.useState)([]);
@@ -29,17 +26,17 @@ const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
29
26
  const { loading: favoritesLoading, error: favoritesError, refetch, fetchMore, } = (0, client_1.useQuery)(schema_1.FetchUserFavoritesV2Document, {
30
27
  context: { uri: api_1.hosts.galleriesHost }, //todo : update variables to object page
31
28
  variables: { pageSize, userId, pageToken },
32
- fetchPolicy: 'no-cache',
33
- onCompleted: ({ fetchUserFavoritesV2: { galleries, nextPageToken: token }, }) => {
29
+ fetchPolicy: "no-cache",
30
+ onCompleted: ({ fetchUserFavoritesV2: { galleries, nextPageToken: token } }) => {
34
31
  // nextPageToken.current = nextPage.nextPage?.token || null;
35
32
  nextPageToken.current = token || null;
36
- setFavorites(galleries.map((gallery) => new GalleryEntityV2_1.default(gallery)));
33
+ setFavorites(galleries.map((gallery) => (0, builder_2.buildGallery)(gallery)));
37
34
  setLoading(false);
38
35
  },
39
36
  onError: () => {
40
37
  openAlert({
41
38
  type: type_1.alertVariants.error,
42
- caption: 'Oops, something went wrong while fetching favorites.',
39
+ caption: "Oops, something went wrong while fetching favorites.",
43
40
  });
44
41
  setFavorites([]);
45
42
  setLoading(false);
@@ -47,11 +44,11 @@ const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
47
44
  });
48
45
  const [fetchAssets, { loading: assetsLoading, error: assetsError }] = (0, client_1.useLazyQuery)(schema_2.FetchAssetsDocument, {
49
46
  context: { uri: api_1.hosts.searchHost },
50
- fetchPolicy: 'no-cache',
47
+ fetchPolicy: "no-cache",
51
48
  onCompleted: ({ fetchAssets: data }) => {
52
- setAsset(data.map((asset) => new CreationEntity_1.default({
49
+ setAsset(data.map((asset) => (0, builder_1.buildCreation)({
53
50
  ...asset,
54
- itemType: 'asset',
51
+ itemType: "asset",
55
52
  itemId: asset.assetId,
56
53
  })));
57
54
  setLoading(false);
@@ -59,23 +56,23 @@ const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
59
56
  onError: () => {
60
57
  openAlert({
61
58
  type: type_1.alertVariants.error,
62
- caption: 'Oops, something went wrong.',
59
+ caption: "Oops, something went wrong.",
63
60
  });
64
61
  setAsset(null);
65
62
  setLoading(false);
66
63
  },
67
64
  });
68
- const [fetchCollections, { loading: collectionsLoading, error: collectionsError },] = (0, client_1.useLazyQuery)(schema_2.FetchCollectionsByIdsDocument, {
65
+ const [fetchCollections, { loading: collectionsLoading, error: collectionsError }] = (0, client_1.useLazyQuery)(schema_2.FetchCollectionsByIdsDocument, {
69
66
  context: { uri: api_1.hosts.searchHost },
70
- fetchPolicy: 'no-cache',
67
+ fetchPolicy: "no-cache",
71
68
  onCompleted: ({ fetchCollectionsByIds: data }) => {
72
- setCollections(data.map((collection) => new CollectionCreationEntity_1.default(collection)));
69
+ setCollections(data.map((collection) => (0, collectionCreationBuilder_1.buildCollectionCreation)(collection)));
73
70
  setLoading(false);
74
71
  },
75
72
  onError: () => {
76
73
  openAlert({
77
74
  type: type_1.alertVariants.error,
78
- caption: 'Oops, something went wrong.',
75
+ caption: "Oops, something went wrong.",
79
76
  });
80
77
  setCollections(null);
81
78
  setLoading(false);
@@ -96,9 +93,7 @@ const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
96
93
  await refetch();
97
94
  }
98
95
  async function loadMoreFavoritesList() {
99
- if (!nextPageToken.current ||
100
- !isHaveNextPage ||
101
- favorites.length >= maxUserFavoritesLength)
96
+ if (!nextPageToken.current || !isHaveNextPage || favorites.length >= maxUserFavoritesLength)
102
97
  return;
103
98
  setIsNextLoading(true);
104
99
  try {
@@ -109,7 +104,7 @@ const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
109
104
  return prev;
110
105
  const { nextPageToken: token, favorites: nextFavorites } = fetchMoreResult.fetchMyFavoritesV2;
111
106
  nextPageToken.current = token || null;
112
- if (prev !== null && prev.hasOwnProperty('fetchMyFavoritesV2')) {
107
+ if (prev !== null && prev.hasOwnProperty("fetchMyFavoritesV2")) {
113
108
  const { favorites: prevFavorites } = prev.fetchMyFavoritesV2;
114
109
  return {
115
110
  fetchMyFavorites: {
@@ -160,26 +155,18 @@ function getMediaForGallery(favorites, takeFirstFour, pageNumber = 1, totalLengt
160
155
  const assetArray = [];
161
156
  const collectionsArray = [];
162
157
  favorites.forEach((fav) => {
163
- const creationIds = takeFirstFour
164
- ? fav.getGalleryCreationIds().slice(0, 4)
165
- : fav.getGalleryCreationIds();
158
+ const creationIds = takeFirstFour ? fav.creationIds.slice(0, 4) : fav.creationIds;
166
159
  if (!creationIds || creationIds.length === 0)
167
160
  return;
168
161
  const startIndex = (pageNumber - 1) * itemsPerPage;
169
162
  const endIndex = totalLength ? totalLength : startIndex + itemsPerPage;
170
163
  for (let i = startIndex; i < endIndex && i < creationIds.length; i++) {
171
- if (creationIds[i].split('.')[0] === 'asset') {
172
- const assetId = creationIds[i]
173
- .split('.')
174
- .splice(1, creationIds[i].length)
175
- .join('.');
164
+ if (creationIds[i].split(".")[0] === "asset") {
165
+ const assetId = creationIds[i].split(".").splice(1, creationIds[i].length).join(".");
176
166
  assetArray.push(assetId);
177
167
  }
178
- else if (creationIds[i].split('.')[0] === 'collection') {
179
- const collectionId = creationIds[i]
180
- .split('.')
181
- .splice(1, creationIds[i].length)
182
- .join('.');
168
+ else if (creationIds[i].split(".")[0] === "collection") {
169
+ const collectionId = creationIds[i].split(".").splice(1, creationIds[i].length).join(".");
183
170
  collectionsArray.push(collectionId);
184
171
  }
185
172
  }
@@ -1,11 +1,10 @@
1
- import { IQueryFetchUserGalleriesV2Args } from '@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema';
2
- import CollectionCreationEntity from '../../../dto/Collection/CollectionCreationEntity';
3
- import CreationEntity from '../../../dto/CreationEntity';
4
- import GalleryEntityV2 from '../../../dto/GalleryEntityV2';
5
- declare const useGetUserGalleriesCreations: ({ userId, pageSize, pageToken, }: IQueryFetchUserGalleriesV2Args) => {
6
- galleries: GalleryEntityV2[];
7
- assets: CreationEntity[] | null;
8
- collections: CollectionCreationEntity[] | null;
1
+ import { TCreation } from '../../../entities/creation/types';
2
+ import { TGallery } from '../../../entities/gallery/types';
3
+ import { IQueryFetchUserGalleriesV2Args } from "@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema";
4
+ declare const useGetUserGalleriesCreations: ({ userId, pageSize, pageToken }: IQueryFetchUserGalleriesV2Args) => {
5
+ galleries: TGallery[];
6
+ assets: TCreation[] | null;
7
+ collections: TCreation[] | null;
9
8
  loading: boolean;
10
9
  loadingAssets: boolean;
11
10
  loadingFavorites: boolean;
@@ -18,7 +17,7 @@ declare const useGetUserGalleriesCreations: ({ userId, pageSize, pageToken, }: I
18
17
  isNextLoading: boolean;
19
18
  };
20
19
  export { useGetUserGalleriesCreations };
21
- export declare function getMediaForGallery(favorites: GalleryEntityV2[], takeFirstFour: boolean): {
20
+ export declare function getMediaForGallery(favorites: TGallery[], takeFirstFour: boolean): {
22
21
  assetArray: unknown[];
23
22
  collectionsArray: unknown[];
24
23
  };