@ludo.ninja/components 2.2.36 → 2.2.37

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 (56) 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/components/assetPage/assetLikes/index.js +7 -7
  10. package/build/components/search/searchSuggestions/index.js +2 -2
  11. package/build/dto/AssetEntity/index.d.ts +3 -3
  12. package/build/dto/AssetEntity/index.js +16 -33
  13. package/build/dto/AssetSearchEntity/index.d.ts +2 -2
  14. package/build/dto/AssetSearchEntity/index.js +12 -29
  15. package/build/dto/Collection/CollectionCreationEntity/index.d.ts +3 -3
  16. package/build/dto/Collection/CollectionCreationEntity/index.js +13 -13
  17. package/build/dto/Collection/CollectionCreationEntity/interface.d.ts +2 -2
  18. package/build/dto/Collection/CollectionEntity/index.d.ts +2 -2
  19. package/build/dto/Collection/CollectionEntity/index.js +1 -1
  20. package/build/dto/CreationEntity/index.d.ts +3 -3
  21. package/build/dto/CreationEntity/index.js +9 -9
  22. package/build/dto/GalleryEntityV2/index.d.ts +4 -4
  23. package/build/dto/GalleryEntityV2/index.js +6 -8
  24. package/build/dto/common/ItemType/data.d.ts +1 -1
  25. package/build/dto/common/ItemType/data.js +25 -25
  26. package/build/entities/gallery/builder.js +1 -1
  27. package/build/hooks/favorites/useGetFavoriteGallaryCreations/index.d.ts +4 -4
  28. package/build/hooks/favorites/useGetFavoriteGallaryCreations/index.js +17 -19
  29. package/build/hooks/favorites/useGetUserFevoritesCreations/index.d.ts +5 -5
  30. package/build/hooks/favorites/useGetUserFevoritesCreations/index.js +23 -33
  31. package/build/hooks/galleries/useGetUserGalleriesCreations/index.d.ts +5 -5
  32. package/build/hooks/galleries/useGetUserGalleriesCreations/index.js +23 -33
  33. package/build/hooks/likes/dynamic/useGetMixedLikesFavoriteList.d.ts +1 -1
  34. package/build/hooks/likes/index.d.ts +1 -1
  35. package/build/hooks/likes/index.js +12 -12
  36. package/build/modules/gallery/api/useGetAssetsAndCollectionForFavorite.d.ts +4 -4
  37. package/build/modules/gallery/api/useGetAssetsAndCollectionForFavorite.js +35 -40
  38. package/build/modules/gallery/store.d.ts +3 -3
  39. package/build/modules/gallery/store.js +7 -11
  40. package/build/modules/gallery/ui/EditGallery.d.ts +2 -2
  41. package/build/modules/gallery/ui/EditGallery.js +11 -11
  42. package/build/modules/gallery/ui/chooseGalleryItems/chooseGalleryItem/index.d.ts +3 -3
  43. package/build/modules/gallery/ui/chooseGalleryItems/chooseGalleryItem/index.js +1 -1
  44. package/build/modules/gallery/ui/chooseGalleryItems/index.d.ts +1 -1
  45. package/build/modules/gallery/ui/chooseGalleryItems/index.js +19 -20
  46. package/build/modules/opportunity/OpportunityCard.js +25 -27
  47. package/build/system/Cards/CardContent/CardCategory/CardCategory.test.d.ts +1 -1
  48. package/build/system/Cards/CardContent/CardCategory/CardCategory.test.js +9 -9
  49. package/build/system/Cards/CardContent/CardCategory/index.d.ts +1 -1
  50. package/build/system/Cards/CardContent/CardCategory/index.js +3 -3
  51. package/build/system/Cards/CreationCard/CardHead.js +16 -21
  52. package/build/system/Cards/CreationCard/index.d.ts +2 -2
  53. package/build/system/Cards/CreationCard/index.js +5 -5
  54. package/build/system/Cards/MultiMediaCard/index.d.ts +2 -2
  55. package/build/system/Cards/MultiMediaCard/index.js +3 -3
  56. package/package.json +1 -1
@@ -5,18 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.useGetUserGalleriesCreations = void 0;
7
7
  exports.getMediaForGallery = getMediaForGallery;
8
- const react_1 = require("react");
8
+ const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
9
+ const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
10
+ const builder_1 = require("../../../entities/gallery/builder");
11
+ const ui_1 = require("../../../store/ui");
9
12
  const client_1 = require("@apollo/client");
10
13
  const api_1 = require("@ludo.ninja/api");
11
14
  const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema");
12
15
  const schema_2 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
13
16
  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"));
17
+ const react_1 = require("react");
18
18
  const maxUserFavoritesLength = 1000;
19
- const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
19
+ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken }) => {
20
20
  const [assets, setAsset] = (0, react_1.useState)(null);
21
21
  const [collections, setCollections] = (0, react_1.useState)(null);
22
22
  const [galleries, setGalleries] = (0, react_1.useState)([]);
@@ -29,17 +29,17 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
29
29
  const { loading: favoritesLoading, error: galleriesError, refetch, fetchMore, } = (0, client_1.useQuery)(schema_1.FetchUserGalleriesV2Document, {
30
30
  context: { uri: api_1.hosts.galleriesHost },
31
31
  variables: { pageSize, userId, pageToken },
32
- fetchPolicy: 'no-cache',
33
- onCompleted: ({ fetchUserGalleriesV2: { galleries, nextPageToken: token }, }) => {
32
+ fetchPolicy: "no-cache",
33
+ onCompleted: ({ fetchUserGalleriesV2: { galleries, nextPageToken: token } }) => {
34
34
  // nextPageToken.current = nextPage.nextPage?.token || null;
35
35
  nextPageToken.current = token || null;
36
- setGalleries(galleries.map((gallery) => new GalleryEntityV2_1.default(gallery)));
36
+ setGalleries(galleries.map((gallery) => (0, builder_1.buildGallery)(gallery)));
37
37
  setLoading(false);
38
38
  },
39
39
  onError: () => {
40
40
  openAlert({
41
41
  type: type_1.alertVariants.error,
42
- caption: 'Oops, something went wrong while fetching galleries.',
42
+ caption: "Oops, something went wrong while fetching galleries.",
43
43
  });
44
44
  setGalleries([]);
45
45
  setLoading(false);
@@ -47,11 +47,11 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
47
47
  });
48
48
  const [fetchAssets, { loading: assetsLoading, error: assetsError }] = (0, client_1.useLazyQuery)(schema_2.FetchAssetsDocument, {
49
49
  context: { uri: api_1.hosts.searchHost },
50
- fetchPolicy: 'no-cache',
50
+ fetchPolicy: "no-cache",
51
51
  onCompleted: ({ fetchAssets: data }) => {
52
52
  setAsset(data.map((asset) => new CreationEntity_1.default({
53
53
  ...asset,
54
- itemType: 'asset',
54
+ itemType: "asset",
55
55
  itemId: asset.assetId,
56
56
  })));
57
57
  setLoading(false);
@@ -59,15 +59,15 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
59
59
  onError: () => {
60
60
  openAlert({
61
61
  type: type_1.alertVariants.error,
62
- caption: 'Oops, something went wrong.',
62
+ caption: "Oops, something went wrong.",
63
63
  });
64
64
  setAsset(null);
65
65
  setLoading(false);
66
66
  },
67
67
  });
68
- const [fetchCollections, { loading: collectionsLoading, error: collectionsError },] = (0, client_1.useLazyQuery)(schema_2.FetchCollectionsByIdsDocument, {
68
+ const [fetchCollections, { loading: collectionsLoading, error: collectionsError }] = (0, client_1.useLazyQuery)(schema_2.FetchCollectionsByIdsDocument, {
69
69
  context: { uri: api_1.hosts.searchHost },
70
- fetchPolicy: 'no-cache',
70
+ fetchPolicy: "no-cache",
71
71
  onCompleted: ({ fetchCollectionsByIds: data }) => {
72
72
  setCollections(data.map((collection) => new CollectionCreationEntity_1.default(collection)));
73
73
  setLoading(false);
@@ -75,7 +75,7 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
75
75
  onError: () => {
76
76
  openAlert({
77
77
  type: type_1.alertVariants.error,
78
- caption: 'Oops, something went wrong.',
78
+ caption: "Oops, something went wrong.",
79
79
  });
80
80
  setCollections(null);
81
81
  setLoading(false);
@@ -96,9 +96,7 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
96
96
  await refetch();
97
97
  }
98
98
  async function loadMoreGalleriesList() {
99
- if (!nextPageToken.current ||
100
- !isHaveNextPage ||
101
- galleries.length >= maxUserFavoritesLength)
99
+ if (!nextPageToken.current || !isHaveNextPage || galleries.length >= maxUserFavoritesLength)
102
100
  return;
103
101
  setIsNextLoading(true);
104
102
  await fetchMore({
@@ -108,7 +106,7 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
108
106
  return prev;
109
107
  const { nextPageToken: token, galleries: nextGalleries } = fetchMoreResult.fetchMyFavoritesV2;
110
108
  nextPageToken.current = token || null;
111
- if (prev !== null && prev.hasOwnProperty('fetchMyGalleriesV2')) {
109
+ if (prev !== null && prev.hasOwnProperty("fetchMyGalleriesV2")) {
112
110
  const { galleries: prevGalleries } = prev.fetchMyGalleriesV2;
113
111
  return {
114
112
  fetchMyGalleriesV2: {
@@ -151,24 +149,16 @@ function getMediaForGallery(favorites, takeFirstFour) {
151
149
  const assetArray = [];
152
150
  const collectionsArray = [];
153
151
  favorites.forEach((fav) => {
154
- const creationIds = takeFirstFour
155
- ? fav.getGalleryCreationIds().slice(0, 4)
156
- : fav.getGalleryCreationIds();
152
+ const creationIds = takeFirstFour ? fav.creationIds.slice(0, 4) : fav.creationIds;
157
153
  if (!creationIds || creationIds.length === 0)
158
154
  return;
159
155
  for (let i = 0; i < creationIds.length; i++) {
160
- if (creationIds[i].split('.')[0] === 'asset') {
161
- const assetId = creationIds[i]
162
- .split('.')
163
- .splice(1, creationIds[i].length)
164
- .join('.');
156
+ if (creationIds[i].split(".")[0] === "asset") {
157
+ const assetId = creationIds[i].split(".").splice(1, creationIds[i].length).join(".");
165
158
  assetArray.push(assetId);
166
159
  }
167
- else if (creationIds[i].split('.')[0] === 'collection') {
168
- const collectionId = creationIds[i]
169
- .split('.')
170
- .splice(1, creationIds[i].length)
171
- .join('.');
160
+ else if (creationIds[i].split(".")[0] === "collection") {
161
+ const collectionId = creationIds[i].split(".").splice(1, creationIds[i].length).join(".");
172
162
  collectionsArray.push(collectionId);
173
163
  }
174
164
  }
@@ -5,7 +5,7 @@ declare const useGetMixedLikesFavoriteList: ({ galleryId, itemsCount, }: {
5
5
  galleryId: string;
6
6
  itemsCount: number | null;
7
7
  }) => {
8
- gallery: import("../../../dto/GalleryEntityV2").default[] | null;
8
+ gallery: import("../../../entities/gallery/types").TGallery[] | null;
9
9
  creationsList: [] | (CreationEntity | CollectionCreationEntity)[];
10
10
  likes: (schema.IDynamicAssetData | schema.IDynamicCollectionData)[];
11
11
  allResults: number | null;
@@ -1,5 +1,5 @@
1
+ import { LabelKeys } from '../../entities/labelCreationType/types';
1
2
  import { RemoveToolsType } from '../../system/Cards/CreationCard';
2
- import { LabelKeys } from '../../dto/common/ItemType';
3
3
  export type LikesType = {
4
4
  likesCount: number;
5
5
  isLiked: boolean;
@@ -3,16 +3,16 @@ 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 react_1 = require("react");
7
- const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
8
- const ui_1 = require("../../store/ui");
9
6
  const useDislikeAsset_1 = __importDefault(require("../../api/server-assets/mutations/useDislikeAsset"));
10
7
  const useLikeAsset_1 = __importDefault(require("../../api/server-assets/mutations/useLikeAsset"));
11
8
  const useDislikeCollection_1 = __importDefault(require("../../api/server-collection/mutations/useDislikeCollection"));
12
9
  const useLikeCollection_1 = __importDefault(require("../../api/server-collection/mutations/useLikeCollection"));
13
10
  const useRemoveAssetFromGallery_1 = require("../../api/server-galleries/mutations/useRemoveAssetFromGallery");
14
11
  const useRemoveCollectionFromGallery_1 = require("../../api/server-galleries/mutations/useRemoveCollectionFromGallery");
15
- const ItemType_1 = require("../../dto/common/ItemType");
12
+ const types_1 = require("../../entities/labelCreationType/types");
13
+ const ui_1 = require("../../store/ui");
14
+ const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
15
+ const react_1 = require("react");
16
16
  // Component
17
17
  const useLikes = ({ defaultLikesCount, defaultIsLiked, itemType, removeOnDislike, isLoadingLikes, }) => {
18
18
  const [likes, setLikes] = (0, react_1.useState)({
@@ -44,8 +44,8 @@ const useLikes = ({ defaultLikesCount, defaultIsLiked, itemType, removeOnDislike
44
44
  errorRemoveCollection) {
45
45
  openAlert({
46
46
  type: type_1.alertVariants.error,
47
- caption: 'Oops, something went wrong.',
48
- text: 'Please try another NFT',
47
+ caption: "Oops, something went wrong.",
48
+ text: "Please try another NFT",
49
49
  });
50
50
  setLikes({
51
51
  likesCount: defaultLikesCount,
@@ -63,10 +63,10 @@ const useLikes = ({ defaultLikesCount, defaultIsLiked, itemType, removeOnDislike
63
63
  ]);
64
64
  const addLike = async (id) => {
65
65
  setIsLoading(true);
66
- if (itemType === ItemType_1.LabelKeys.asset) {
66
+ if (itemType === types_1.LabelKeys.asset) {
67
67
  await likeAsset({ assetId: id });
68
68
  }
69
- else if (itemType === ItemType_1.LabelKeys.collection) {
69
+ else if (itemType === types_1.LabelKeys.collection) {
70
70
  await likeCollection({ collectionId: id });
71
71
  }
72
72
  if (!errorLikeAsset || !errorLikeCollection) {
@@ -79,21 +79,21 @@ const useLikes = ({ defaultLikesCount, defaultIsLiked, itemType, removeOnDislike
79
79
  };
80
80
  const deleteLike = async (id) => {
81
81
  setIsLoading(true);
82
- if (itemType === ItemType_1.LabelKeys.asset) {
82
+ if (itemType === types_1.LabelKeys.asset) {
83
83
  await dislikeAsset({ assetId: id });
84
84
  if (removeOnDislike && removeOnDislike.gallery) {
85
85
  await removeAssetFromGallery({
86
- galleryId: removeOnDislike.gallery.getGalleryId(),
86
+ galleryId: removeOnDislike.gallery.galleryId,
87
87
  assetId: id,
88
88
  });
89
89
  removeOnDislike?.removeFn(itemType);
90
90
  }
91
91
  }
92
- else if (itemType === ItemType_1.LabelKeys.collection) {
92
+ else if (itemType === types_1.LabelKeys.collection) {
93
93
  await dislikeCollection({ collectionId: id });
94
94
  if (removeOnDislike && removeOnDislike.gallery) {
95
95
  await removeCollectionFromGallery({
96
- galleryId: removeOnDislike.gallery.getGalleryId(),
96
+ galleryId: removeOnDislike.gallery.galleryId,
97
97
  collectionId: id,
98
98
  });
99
99
  removeOnDislike?.removeFn(itemType);
@@ -1,11 +1,11 @@
1
- import GalleryEntityV2 from '../../../dto/GalleryEntityV2';
2
- import { TCreationAndCollection } from '../../virtuoso/types';
3
- import { TActiveTab } from '../../../system/Tabs/TabsNav/type';
1
+ import { TGallery } from '../../../entities/gallery/types';
4
2
  import { TCurrentItemType } from '../../../hooks/likes/useGetLikesAsset';
5
3
  import { TOpportunity } from '../../opportunity/type';
4
+ import { TCreationAndCollection } from '../../virtuoso/types';
5
+ import { TActiveTab } from '../../../system/Tabs/TabsNav/type';
6
6
  export type TCreationWithOpportunity = TCreationAndCollection | TOpportunity;
7
7
  export declare const useGetAssetsAndCollectionForFavorite: <TCreations>({ gallery, activeTab, fetchLikes, }: {
8
- gallery: GalleryEntityV2;
8
+ gallery: TGallery;
9
9
  activeTab: TActiveTab;
10
10
  fetchLikes?: (itemsIdsArray: string[], currentItemType: TCurrentItemType) => Promise<void>;
11
11
  }) => {
@@ -4,17 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.useGetAssetsAndCollectionForFavorite = void 0;
7
- const react_1 = require("react");
8
- const client_1 = require("@apollo/client");
9
- const api_1 = require("@ludo.ninja/api");
10
- const api_2 = require("@ludo.ninja/api");
11
- const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
12
7
  const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
13
8
  const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
9
+ const store_1 = require("../store");
14
10
  const ui_1 = require("../../../store/ui");
15
11
  const extractItemIds_1 = require("../../../utils/extractItemIds");
16
12
  const getPageSizeAssets_1 = require("../../../utils/getPageSizeAssets");
17
- const store_1 = require("../store");
13
+ const client_1 = require("@apollo/client");
14
+ const api_1 = require("@ludo.ninja/api");
15
+ const api_2 = require("@ludo.ninja/api");
16
+ const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
17
+ const react_1 = require("react");
18
18
  const limit = 40;
19
19
  const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes, }) => {
20
20
  const [assets, setAssets] = (0, react_1.useState)([]);
@@ -36,25 +36,23 @@ const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes,
36
36
  })
37
37
  : limit;
38
38
  const totalLength = size !== limit ? size : false;
39
- const creationIds = gallery.getGalleryCreationIds();
39
+ const creationIds = gallery.creationIds;
40
40
  const startIndex = (currentPageRef.current - 1) * limit;
41
41
  const endIndex = totalLength ? totalLength : startIndex + limit;
42
42
  for (let i = startIndex; i < endIndex && i < creationIds.length; i++) {
43
- const elements = creationIds[i].split('.');
44
- const id = elements.splice(1, creationIds[i].length).join('.');
45
- if (elements[0] === 'asset') {
43
+ const elements = creationIds[i].split(".");
44
+ const id = elements.splice(1, creationIds[i].length).join(".");
45
+ if (elements[0] === "asset") {
46
46
  assetArray.push(id);
47
47
  }
48
- else if (elements[0] === 'collection') {
48
+ else if (elements[0] === "collection") {
49
49
  collectionsArray.push(id);
50
50
  }
51
- else if (elements[0] === 'opportunity') {
51
+ else if (elements[0] === "opportunity") {
52
52
  opportunitiesArray.push(id);
53
53
  }
54
54
  }
55
- const assetPromise = assetArray.length > 0
56
- ? fetchAssets({ variables: { assetIds: assetArray } })
57
- : Promise.resolve();
55
+ const assetPromise = assetArray.length > 0 ? fetchAssets({ variables: { assetIds: assetArray } }) : Promise.resolve();
58
56
  const collectionsPromise = collectionsArray.length > 0
59
57
  ? fetchCollections({ variables: { collectionIds: collectionsArray } })
60
58
  : Promise.resolve();
@@ -81,7 +79,7 @@ const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes,
81
79
  };
82
80
  const [fetchAssets, { error: assetsError, refetch: refetchAssets }] = (0, client_1.useLazyQuery)(api_2.searchSchema.FetchAssetsDocument, {
83
81
  context: { uri: api_1.hosts.searchHost },
84
- fetchPolicy: 'no-cache',
82
+ fetchPolicy: "no-cache",
85
83
  onCompleted: ({ fetchAssets: data }) => {
86
84
  setAssets((prevAssets) => {
87
85
  const results = [
@@ -90,63 +88,60 @@ const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes,
90
88
  asset.assetId,
91
89
  new CreationEntity_1.default({
92
90
  ...asset,
93
- itemType: 'asset',
91
+ itemType: "asset",
94
92
  itemId: asset.assetId,
95
93
  }),
96
94
  ]),
97
95
  ];
98
- getLikesForAllCreations(results.map((el) => el[1]), 'asset');
96
+ getLikesForAllCreations(results.map((el) => el[1]), "asset");
99
97
  return results;
100
98
  });
101
99
  },
102
100
  onError: () => {
103
101
  openAlert({
104
102
  type: type_1.alertVariants.error,
105
- caption: 'Oops, something went wrong.',
103
+ caption: "Oops, something went wrong.",
106
104
  });
107
105
  setAssets([]);
108
106
  },
109
107
  });
110
- const [fetchCollections, { error: collectionsError, refetch: refetchCollections },] = (0, client_1.useLazyQuery)(api_2.searchSchema.FetchCollectionsByIdsDocument, {
108
+ const [fetchCollections, { error: collectionsError, refetch: refetchCollections }] = (0, client_1.useLazyQuery)(api_2.searchSchema.FetchCollectionsByIdsDocument, {
111
109
  context: { uri: api_1.hosts.searchHost },
112
- fetchPolicy: 'no-cache',
110
+ fetchPolicy: "no-cache",
113
111
  onCompleted: ({ fetchCollectionsByIds: data }) => {
114
112
  setCollections((prevCollections) => {
115
113
  const results = [
116
114
  ...(prevCollections || []),
117
115
  ...data.map((collection) => [
118
116
  collection.collectionId,
119
- new CollectionCreationEntity_1.default(collection, 'collection'),
117
+ new CollectionCreationEntity_1.default(collection, "collection"),
120
118
  ]),
121
119
  ];
122
- getLikesForAllCreations(results.map((el) => el[1]), 'collection');
120
+ getLikesForAllCreations(results.map((el) => el[1]), "collection");
123
121
  return results;
124
122
  });
125
123
  },
126
124
  onError: () => {
127
125
  openAlert({
128
126
  type: type_1.alertVariants.error,
129
- caption: 'Oops, something went wrong.',
127
+ caption: "Oops, something went wrong.",
130
128
  });
131
129
  setCollections([]);
132
130
  },
133
131
  });
134
- const [fetchOpportunities, { error: opportunitiesError, refetch: refetchOpportunities },] = api_1.opportunitiesSchema.useFetchOpportunitiesByIdsLazyQuery({
132
+ const [fetchOpportunities, { error: opportunitiesError, refetch: refetchOpportunities }] = api_1.opportunitiesSchema.useFetchOpportunitiesByIdsLazyQuery({
135
133
  context: { uri: api_1.hosts.opportunitiesHost },
136
- fetchPolicy: 'no-cache',
134
+ fetchPolicy: "no-cache",
137
135
  onCompleted: ({ fetchOpportunitiesByIds: data }) => {
138
136
  setOpportunities((prev) => [
139
137
  ...(prev || []),
140
- ...data.map((opportunity) => [
141
- opportunity.opportunityId,
142
- opportunity,
143
- ]),
138
+ ...data.map((opportunity) => [opportunity.opportunityId, opportunity]),
144
139
  ]);
145
140
  },
146
141
  onError: () => {
147
142
  openAlert({
148
143
  type: type_1.alertVariants.error,
149
- caption: 'Oops, something went wrong.',
144
+ caption: "Oops, something went wrong.",
150
145
  });
151
146
  setOpportunities([]);
152
147
  },
@@ -166,22 +161,22 @@ const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes,
166
161
  });
167
162
  };
168
163
  const creations = (0, react_1.useMemo)(() => {
169
- const creationIds = gallery.getGalleryCreationIds();
164
+ const creationIds = gallery.creationIds;
170
165
  const mapAssets = new Map(assets);
171
166
  const collectionAssets = new Map(collections);
172
167
  const opportunityAssets = new Map(opportunities);
173
168
  return creationIds
174
169
  .map((id) => {
175
- const idSplit = id.split('.');
170
+ const idSplit = id.split(".");
176
171
  const idType = idSplit[0];
177
- const idElement = idSplit.slice(1).join('.');
178
- if (idType === 'asset') {
172
+ const idElement = idSplit.slice(1).join(".");
173
+ if (idType === "asset") {
179
174
  return mapAssets.get(idElement);
180
175
  }
181
- if (idType === 'collection') {
176
+ if (idType === "collection") {
182
177
  return collectionAssets.get(idElement);
183
178
  }
184
- if (idType === 'opportunity') {
179
+ if (idType === "opportunity") {
185
180
  return opportunityAssets.get(idElement);
186
181
  }
187
182
  })
@@ -206,13 +201,13 @@ const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes,
206
201
  }
207
202
  },
208
203
  removeCreation: (creationIdToRemove, itemType) => {
209
- if (itemType === 'asset') {
204
+ if (itemType === "asset") {
210
205
  setAssets((items) => items.filter((item) => item[0] !== creationIdToRemove));
211
206
  }
212
- if (itemType === 'collection') {
207
+ if (itemType === "collection") {
213
208
  setCollections((items) => items.filter((item) => item[0] !== creationIdToRemove));
214
209
  }
215
- if (itemType === 'opportunity') {
210
+ if (itemType === "opportunity") {
216
211
  setOpportunities((items) => items.filter((item) => item[0] !== creationIdToRemove));
217
212
  }
218
213
  },
@@ -1,5 +1,5 @@
1
- import { galleriesSchema as schema } from '@ludo.ninja/api';
2
- import GalleryEntityV2 from '../../dto/GalleryEntityV2';
1
+ import { TGallery } from '../../entities/gallery/types';
2
+ import { galleriesSchema as schema } from "@ludo.ninja/api";
3
3
  type UserFields = {
4
4
  galleryName: string;
5
5
  galleryDescription: string;
@@ -9,7 +9,7 @@ export interface HTMLInputEvent extends Event {
9
9
  }
10
10
  interface IFavoriteStore {
11
11
  fetchGalleryV2: schema.IGalleryV2 | null;
12
- gallery: GalleryEntityV2 | null;
12
+ gallery: TGallery | null;
13
13
  setGallery: (gallery: schema.IGalleryV2 | null) => void;
14
14
  updateGalleryInfo: (data: UserFields) => void;
15
15
  updateGalleryBanner: (banner: string | null) => void;
@@ -1,13 +1,10 @@
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.useGalleryStore = void 0;
4
+ const builder_1 = require("../../entities/gallery/builder");
7
5
  const getDimensionsImage_1 = require("../../utils/getDimensionsImage");
8
6
  const shallow_1 = require("zustand/shallow");
9
7
  const traditional_1 = require("zustand/traditional");
10
- const GalleryEntityV2_1 = __importDefault(require("../../dto/GalleryEntityV2"));
11
8
  const initialState = {
12
9
  gallery: null,
13
10
  fetchGalleryV2: null,
@@ -20,7 +17,7 @@ exports.useGalleryStore = (0, traditional_1.createWithEqualityFn)()((setState, g
20
17
  setGallery: (gallery) => {
21
18
  if (gallery) {
22
19
  setState({
23
- gallery: new GalleryEntityV2_1.default(gallery),
20
+ gallery: (0, builder_1.buildGallery)(gallery),
24
21
  fetchGalleryV2: gallery,
25
22
  });
26
23
  }
@@ -37,7 +34,7 @@ exports.useGalleryStore = (0, traditional_1.createWithEqualityFn)()((setState, g
37
34
  };
38
35
  return {
39
36
  fetchGalleryV2: newGallery,
40
- gallery: new GalleryEntityV2_1.default(newGallery),
37
+ gallery: (0, builder_1.buildGallery)(newGallery),
41
38
  };
42
39
  });
43
40
  },
@@ -49,11 +46,11 @@ exports.useGalleryStore = (0, traditional_1.createWithEqualityFn)()((setState, g
49
46
  };
50
47
  return {
51
48
  fetchGalleryV2: newGallery,
52
- gallery: new GalleryEntityV2_1.default(newGallery),
49
+ gallery: (0, builder_1.buildGallery)(newGallery),
53
50
  };
54
51
  });
55
52
  },
56
- fileGallery: '',
53
+ fileGallery: "",
57
54
  isErrorFileGallery: initialState.isErrorFileGallery,
58
55
  addFileGalleryWithValidation: async (e) => {
59
56
  const fileTarget = e.target.files?.[0];
@@ -68,8 +65,7 @@ exports.useGalleryStore = (0, traditional_1.createWithEqualityFn)()((setState, g
68
65
  }
69
66
  else {
70
67
  const dimensions = await (0, getDimensionsImage_1.getDimensionsImage)(fileTarget);
71
- const isErrorNew = !!(dimensions &&
72
- (dimensions.width > 1200 || dimensions.height > 1200));
68
+ const isErrorNew = !!(dimensions && (dimensions.width > 1200 || dimensions.height > 1200));
73
69
  setState({ isErrorFileGallery: isErrorNew });
74
70
  if (isErrorNew) {
75
71
  return;
@@ -84,7 +80,7 @@ exports.useGalleryStore = (0, traditional_1.createWithEqualityFn)()((setState, g
84
80
  const fileGallery = getState().fileGallery;
85
81
  if (fileGallery) {
86
82
  URL.revokeObjectURL(fileGallery);
87
- setState({ fileGallery: '' });
83
+ setState({ fileGallery: "" });
88
84
  }
89
85
  },
90
86
  allResults: initialState.allResults,
@@ -1,6 +1,6 @@
1
- import GalleryEntityV2 from '../../../dto/GalleryEntityV2';
1
+ import { TGallery } from '../../../entities/gallery/types';
2
2
  export declare const EditGallery: ({ galleryId, handleRemoveAsset, gallery, titleAssets, titleForm, inputPlaceHolderText, }: {
3
- gallery: GalleryEntityV2;
3
+ gallery: TGallery;
4
4
  galleryId: string;
5
5
  handleRemoveAsset: (creationIdToRemove: string) => (itemType: "asset" | "collection") => void;
6
6
  titleAssets: string;
@@ -5,13 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.EditGallery = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
- const styled_components_1 = __importDefault(require("styled-components"));
8
+ const editGalleryForm_1 = __importDefault(require("./editGalleryForm"));
9
+ const useRemoveAssetFromGallery_1 = require("../../../api/server-galleries/mutations/useRemoveAssetFromGallery");
10
+ const useRemoveCollectionFromGallery_1 = require("../../../api/server-galleries/mutations/useRemoveCollectionFromGallery");
9
11
  const useGetAssetsAndCollectionForFavorite_1 = require("../api/useGetAssetsAndCollectionForFavorite");
10
12
  const store_1 = require("../store");
11
13
  const itemsPreview_1 = __importDefault(require("./itemsPreview"));
12
- const useRemoveAssetFromGallery_1 = require("../../../api/server-galleries/mutations/useRemoveAssetFromGallery");
13
- const useRemoveCollectionFromGallery_1 = require("../../../api/server-galleries/mutations/useRemoveCollectionFromGallery");
14
- const editGalleryForm_1 = __importDefault(require("./editGalleryForm"));
14
+ const styled_components_1 = __importDefault(require("styled-components"));
15
15
  const StyledAddFavlist = styled_components_1.default.div `
16
16
  display: flex;
17
17
 
@@ -27,25 +27,25 @@ const EditGallery = ({ galleryId, handleRemoveAsset, gallery, titleAssets, title
27
27
  const { removeAssetFromGallery } = (0, useRemoveAssetFromGallery_1.useRemoveAssetFromGalleryV2)();
28
28
  const { removeCollectionFromGallery } = (0, useRemoveCollectionFromGallery_1.useRemoveCollectionFromGalleryV2)();
29
29
  const handleDeleteCreation = async (itemId) => {
30
- const id = itemId.split('.').splice(1).join('.');
31
- if (itemId.split('.')[0] === 'collection') {
30
+ const id = itemId.split(".").splice(1).join(".");
31
+ if (itemId.split(".")[0] === "collection") {
32
32
  await removeCollectionFromGallery({
33
33
  galleryId,
34
34
  collectionId: id,
35
35
  });
36
- handleRemoveAsset(id)('collection');
37
- removeCreation(id, 'collection');
36
+ handleRemoveAsset(id)("collection");
37
+ removeCreation(id, "collection");
38
38
  }
39
39
  else {
40
40
  await removeAssetFromGallery({
41
41
  galleryId,
42
42
  assetId: id,
43
43
  });
44
- handleRemoveAsset(id)('asset');
45
- removeCreation(id, 'asset');
44
+ handleRemoveAsset(id)("asset");
45
+ removeCreation(id, "asset");
46
46
  }
47
47
  };
48
48
  const allResults = (0, store_1.useGalleryStore)((state) => state.allResults);
49
- return ((0, jsx_runtime_1.jsxs)(StyledAddFavlist, { children: [(0, jsx_runtime_1.jsx)(itemsPreview_1.default, { creations: creationsList, title: titleAssets, deleteMethod: handleDeleteCreation, isLoading: isLoading, loadMore: loadMore, isNextLoading: isNextLoading, allCount: allResults }), (0, jsx_runtime_1.jsx)(editGalleryForm_1.default, { name: gallery.getGalleryName(), description: gallery.getGalleryDescription(), title: titleForm, inputPlaceHolderText: inputPlaceHolderText, galleryId: galleryId })] }));
49
+ return ((0, jsx_runtime_1.jsxs)(StyledAddFavlist, { children: [(0, jsx_runtime_1.jsx)(itemsPreview_1.default, { creations: creationsList, title: titleAssets, deleteMethod: handleDeleteCreation, isLoading: isLoading, loadMore: loadMore, isNextLoading: isNextLoading, allCount: allResults }), (0, jsx_runtime_1.jsx)(editGalleryForm_1.default, { name: gallery.name, description: gallery.description, title: titleForm, inputPlaceHolderText: inputPlaceHolderText, galleryId: galleryId })] }));
50
50
  };
51
51
  exports.EditGallery = EditGallery;
@@ -1,7 +1,7 @@
1
- import GalleryEntityV2 from '../../../../../dto/GalleryEntityV2';
1
+ import { TGallery } from '../../../../../entities/gallery/types';
2
2
  declare const ChooseItem: ({ galleryItem, handleIsSelected, isSelected, }: {
3
- galleryItem: GalleryEntityV2;
4
- handleIsSelected: (arg: GalleryEntityV2) => void;
3
+ galleryItem: TGallery;
4
+ handleIsSelected: (arg: TGallery) => void;
5
5
  isSelected: boolean;
6
6
  }) => import("react/jsx-runtime").JSX.Element;
7
7
  export default ChooseItem;
@@ -92,6 +92,6 @@ const StyledChooseItem = styled_components_1.default.div `
92
92
  }
93
93
  `;
94
94
  // Component
95
- const ChooseItem = ({ galleryItem, handleIsSelected, isSelected, }) => ((0, jsx_runtime_1.jsx)(StyledChooseItem, { isSelected: isSelected, onClick: () => handleIsSelected(galleryItem), children: (0, jsx_runtime_1.jsxs)("div", { className: "content-item-wrapper", children: [(0, jsx_runtime_1.jsx)("div", { className: "content-item-gallery-pic-default", children: (0, jsx_runtime_1.jsx)("div", { className: "image" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "content-item-gallery-name", children: [(0, jsx_runtime_1.jsx)("p", { className: "name", children: galleryItem.getGalleryName() }), (0, jsx_runtime_1.jsx)("span", { className: `items-count`, children: galleryItem.getGalleryItemsCount() })] })] }) }));
95
+ const ChooseItem = ({ galleryItem, handleIsSelected, isSelected, }) => ((0, jsx_runtime_1.jsx)(StyledChooseItem, { isSelected: isSelected, onClick: () => handleIsSelected(galleryItem), children: (0, jsx_runtime_1.jsxs)("div", { className: "content-item-wrapper", children: [(0, jsx_runtime_1.jsx)("div", { className: "content-item-gallery-pic-default", children: (0, jsx_runtime_1.jsx)("div", { className: "image" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "content-item-gallery-name", children: [(0, jsx_runtime_1.jsx)("p", { className: "name", children: galleryItem.name }), (0, jsx_runtime_1.jsx)("span", { className: `items-count`, children: galleryItem.itemsCount })] })] }) }));
96
96
  // Export
97
97
  exports.default = ChooseItem;
@@ -1,4 +1,4 @@
1
- import { ApolloError } from '@apollo/client';
1
+ import { ApolloError } from "@apollo/client";
2
2
  interface IGalleryItems {
3
3
  setAddGallery: (value: boolean) => void;
4
4
  addMethod: (galleryId: string, ids: string[]) => void;