@ludo.ninja/components 2.2.37 → 2.2.39
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.
- package/build/api/server-search/queries/useFetchAllCreations/index.d.ts +7 -7
- package/build/api/server-search/queries/useFetchAllCreations/index.js +7 -10
- package/build/api/server-search/queries/useFetchCollections/index.d.ts +6 -6
- package/build/api/server-search/queries/useFetchCollections/index.js +10 -12
- package/build/api/server-search/queries/useFetchDynamicCollectionData/index.d.ts +4 -4
- package/build/api/server-search/queries/useFetchDynamicCollectionData/index.js +8 -11
- package/build/api/server-search/queries/useFindCreations/index.d.ts +7 -7
- package/build/api/server-search/queries/useFindCreations/index.js +9 -12
- package/build/api/server-search/queries/useFindUserCreations/index.d.ts +3 -3
- package/build/api/server-search/queries/useFindUserCreations/index.js +7 -10
- package/build/api/server-search/queries/useFindUserLudoCreations/index.d.ts +3 -3
- package/build/api/server-search/queries/useFindUserLudoCreations/index.js +7 -10
- package/build/components/gallery/add/addCreationToGallery/index.js +7 -7
- package/build/components/search/SearchInputContainer.d.ts +1 -1
- package/build/components/search/SearchInputContainer.js +14 -17
- package/build/entities/creation/collectionCreationBuilder.d.ts +2 -2
- package/build/entities/creation/collectionCreationBuilder.js +4 -3
- package/build/hooks/favorites/useGetFavoriteGallaryCreations/index.d.ts +2 -3
- package/build/hooks/favorites/useGetFavoriteGallaryCreations/index.js +7 -9
- package/build/hooks/favorites/useGetUserFevoritesCreations/index.d.ts +3 -4
- package/build/hooks/favorites/useGetUserFevoritesCreations/index.js +6 -9
- package/build/hooks/galleries/useGetUserGalleriesCreations/index.d.ts +3 -4
- package/build/hooks/galleries/useGetUserGalleriesCreations/index.js +6 -9
- package/build/hooks/likes/dynamic/useFindCollectionsAndLikes.d.ts +6 -6
- package/build/hooks/likes/dynamic/useFindCollectionsAndLikes.js +15 -17
- package/build/hooks/likes/dynamic/useFindCreationsAndLikes.d.ts +4 -4
- package/build/hooks/likes/dynamic/useFindCreationsAndLikes.js +12 -15
- package/build/hooks/likes/dynamic/useGetCollectionInfoAndLikes.d.ts +4 -4
- package/build/hooks/likes/dynamic/useGetCollectionInfoAndLikes.js +11 -18
- package/build/hooks/likes/dynamic/useGetCreationsAndLikes.d.ts +4 -5
- package/build/hooks/likes/dynamic/useGetCreationsAndLikes.js +12 -17
- package/build/hooks/likes/dynamic/useGetCreationsAndLikesByType.d.ts +4 -4
- package/build/hooks/likes/dynamic/useGetCreationsAndLikesByType.js +16 -19
- package/build/hooks/likes/dynamic/useGetMixedLikesFavoriteList.d.ts +4 -5
- package/build/hooks/likes/dynamic/useGetMixedLikesFavoriteList.js +9 -10
- package/build/hooks/likes/dynamic/useGetTableLikes.d.ts +4 -5
- package/build/hooks/likes/dynamic/useGetTableLikes.js +14 -21
- package/build/modules/gallery/api/useGetAssetsAndCollectionForFavorite.d.ts +2 -2
- package/build/modules/gallery/api/useGetAssetsAndCollectionForFavorite.js +7 -10
- package/build/modules/gallery/ui/itemsPreview/index.d.ts +2 -3
- package/build/modules/gallery/ui/itemsPreview/index.js +9 -4
- package/build/modules/gallery/useToGalleryAsset.d.ts +5 -5
- package/build/modules/gallery/useToGalleryAsset.js +7 -7
- package/build/modules/virtuoso/types.d.ts +0 -3
- package/build/system/Cards/CreationCard/CardHead.d.ts +2 -3
- package/build/system/Cards/CreationCard/CardHead.js +5 -14
- package/build/system/Cards/CreationCard/index.d.ts +2 -2
- package/build/system/Cards/CreationCard/index.js +7 -6
- package/build/system/Cards/MultiMediaCard/index.d.ts +3 -4
- package/build/system/Cards/MultiMediaCard/index.js +5 -4
- package/build/utils/extractItemIds.d.ts +2 -2
- package/build/utils/extractItemIds.js +1 -7
- package/package.json +1 -1
|
@@ -1,18 +1,15 @@
|
|
|
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.useGetCreationsAndLikes = void 0;
|
|
7
4
|
exports.extractItemIds = extractItemIds;
|
|
8
|
-
const
|
|
5
|
+
const builder_1 = require("../../../entities/creation/builder");
|
|
6
|
+
const types_1 = require("../../../entities/labelCreationType/types");
|
|
7
|
+
const ui_1 = require("../../../store/ui");
|
|
9
8
|
const client_1 = require("@apollo/client");
|
|
10
9
|
const api_1 = require("@ludo.ninja/api");
|
|
11
10
|
const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
|
|
12
11
|
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
13
|
-
const
|
|
14
|
-
const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
|
|
15
|
-
const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
|
|
12
|
+
const react_1 = require("react");
|
|
16
13
|
const maxCreationLength = 1000;
|
|
17
14
|
const useGetCreationsAndLikes = ({ page }) => {
|
|
18
15
|
const [allCreations, setCreations] = (0, react_1.useState)([]);
|
|
@@ -29,7 +26,7 @@ const useGetCreationsAndLikes = ({ page }) => {
|
|
|
29
26
|
uri: api_1.hosts.searchHost,
|
|
30
27
|
},
|
|
31
28
|
onCompleted: ({ fetchAllCreations: { creations, ...nextPage } }) => {
|
|
32
|
-
setCreations(creations.map((creation) =>
|
|
29
|
+
setCreations(creations.map((creation) => (0, builder_1.buildCreation)(creation)));
|
|
33
30
|
setNextPageToken(nextPage.nextPage?.token || null);
|
|
34
31
|
},
|
|
35
32
|
onError: () => {
|
|
@@ -49,7 +46,7 @@ const useGetCreationsAndLikes = ({ page }) => {
|
|
|
49
46
|
onError: () => {
|
|
50
47
|
openAlert({
|
|
51
48
|
type: type_1.alertVariants.error,
|
|
52
|
-
caption:
|
|
49
|
+
caption: "Oops, something went wrong when fetch assets likes.",
|
|
53
50
|
});
|
|
54
51
|
setAssetsLikes([]);
|
|
55
52
|
setLoading(false);
|
|
@@ -64,7 +61,7 @@ const useGetCreationsAndLikes = ({ page }) => {
|
|
|
64
61
|
onError: () => {
|
|
65
62
|
openAlert({
|
|
66
63
|
type: type_1.alertVariants.error,
|
|
67
|
-
caption:
|
|
64
|
+
caption: "Oops, something went wrong when fetch collections likes.",
|
|
68
65
|
});
|
|
69
66
|
setCollectionsLikes([]);
|
|
70
67
|
setLoading(false);
|
|
@@ -74,10 +71,10 @@ const useGetCreationsAndLikes = ({ page }) => {
|
|
|
74
71
|
if (allCreations.length > 0) {
|
|
75
72
|
const itemsIdsArray = extractItemIds(allCreations);
|
|
76
73
|
if (itemsIdsArray.length > 0) {
|
|
77
|
-
if (allCreations[0].
|
|
74
|
+
if (allCreations[0].itemType === types_1.LabelKeys.asset) {
|
|
78
75
|
fetchAssetsLikes({ variables: { assetIds: itemsIdsArray } });
|
|
79
76
|
}
|
|
80
|
-
else if (allCreations[0].
|
|
77
|
+
else if (allCreations[0].itemType === types_1.LabelKeys.collection) {
|
|
81
78
|
fetchCollectionsLikes({
|
|
82
79
|
variables: {
|
|
83
80
|
input: itemsIdsArray.map((collectionId) => {
|
|
@@ -115,14 +112,14 @@ const useGetCreationsAndLikes = ({ page }) => {
|
|
|
115
112
|
variables: {
|
|
116
113
|
page: {
|
|
117
114
|
token: pageToken,
|
|
118
|
-
...(page &&
|
|
115
|
+
...(page && "size" in page ? { size: page.size } : {}),
|
|
119
116
|
},
|
|
120
117
|
},
|
|
121
118
|
});
|
|
122
119
|
const { creations: nextCreations, ...nextPage } = data.fetchAllCreations;
|
|
123
120
|
setCreations((prevCreations) => [
|
|
124
121
|
...prevCreations,
|
|
125
|
-
...nextCreations.map((creation) =>
|
|
122
|
+
...nextCreations.map((creation) => (0, builder_1.buildCreation)(creation)),
|
|
126
123
|
]);
|
|
127
124
|
setNextPageToken(nextPage.nextPage?.token || null);
|
|
128
125
|
}
|
|
@@ -133,7 +130,5 @@ const useGetCreationsAndLikes = ({ page }) => {
|
|
|
133
130
|
};
|
|
134
131
|
exports.useGetCreationsAndLikes = useGetCreationsAndLikes;
|
|
135
132
|
function extractItemIds(creations) {
|
|
136
|
-
return creations.map((creation) => creation
|
|
137
|
-
? creation.getCreationId()
|
|
138
|
-
: creation.getItemId());
|
|
133
|
+
return creations.map((creation) => creation.itemId);
|
|
139
134
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
declare const useGetCreationsAndLikesByType: ({ itemType, page
|
|
1
|
+
import { TCreation } from '../../../entities/creation/types';
|
|
2
|
+
import { IDynamicAssetData, IDynamicCollectionData, IQueryFetchCreationsByTypeArgs } from "@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema";
|
|
3
|
+
declare const useGetCreationsAndLikesByType: ({ itemType, page }: IQueryFetchCreationsByTypeArgs) => {
|
|
4
4
|
loading: boolean;
|
|
5
5
|
assetsLikesLoading: boolean;
|
|
6
6
|
collectionsLikesLoading: boolean;
|
|
7
7
|
creationsLoading: boolean;
|
|
8
8
|
error: import("@apollo/client").ApolloError | undefined;
|
|
9
|
-
allCreations:
|
|
9
|
+
allCreations: TCreation[];
|
|
10
10
|
assetsLikes: [] | IDynamicAssetData[];
|
|
11
11
|
collectionsLikes: [] | IDynamicCollectionData[];
|
|
12
12
|
nextPageToken: string | null;
|
|
@@ -1,19 +1,16 @@
|
|
|
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.useGetCreationsAndLikesByType = void 0;
|
|
7
|
-
const
|
|
4
|
+
const useGetCreationsAndLikes_1 = require("./useGetCreationsAndLikes");
|
|
5
|
+
const builder_1 = require("../../../entities/creation/builder");
|
|
6
|
+
const ui_1 = require("../../../store/ui");
|
|
8
7
|
const client_1 = require("@apollo/client");
|
|
9
8
|
const api_1 = require("@ludo.ninja/api");
|
|
10
9
|
const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
|
|
11
10
|
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
12
|
-
const
|
|
13
|
-
const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
|
|
14
|
-
const useGetCreationsAndLikes_1 = require("./useGetCreationsAndLikes");
|
|
11
|
+
const react_1 = require("react");
|
|
15
12
|
const maxCreationLength = 1000;
|
|
16
|
-
const useGetCreationsAndLikesByType = ({ itemType, page
|
|
13
|
+
const useGetCreationsAndLikesByType = ({ itemType, page }) => {
|
|
17
14
|
const [allCreations, setAllCreations] = (0, react_1.useState)([]);
|
|
18
15
|
const [nextPageToken, setNextPageToken] = (0, react_1.useState)(null);
|
|
19
16
|
const [assetsLikes, setAssetsLikes] = (0, react_1.useState)([]);
|
|
@@ -29,16 +26,16 @@ const useGetCreationsAndLikesByType = ({ itemType, page, }) => {
|
|
|
29
26
|
context: {
|
|
30
27
|
uri: api_1.hosts.searchHost,
|
|
31
28
|
},
|
|
32
|
-
fetchPolicy:
|
|
29
|
+
fetchPolicy: "no-cache",
|
|
33
30
|
onCompleted: ({ fetchCreationsByType: { creations, ...data } }) => {
|
|
34
|
-
setAllCreations(creations.map((creation) =>
|
|
31
|
+
setAllCreations(creations.map((creation) => (0, builder_1.buildCreation)(creation)));
|
|
35
32
|
setNextPageToken(data.nextPage?.token || null);
|
|
36
33
|
setLoading(false);
|
|
37
34
|
},
|
|
38
35
|
onError: () => {
|
|
39
36
|
openAlert({
|
|
40
37
|
type: type_1.alertVariants.error,
|
|
41
|
-
caption:
|
|
38
|
+
caption: "Oops, something went wrong.",
|
|
42
39
|
});
|
|
43
40
|
setAllCreations([]);
|
|
44
41
|
setNextPageToken(null);
|
|
@@ -49,7 +46,7 @@ const useGetCreationsAndLikesByType = ({ itemType, page, }) => {
|
|
|
49
46
|
context: {
|
|
50
47
|
uri: api_1.hosts.searchHost,
|
|
51
48
|
},
|
|
52
|
-
fetchPolicy:
|
|
49
|
+
fetchPolicy: "no-cache",
|
|
53
50
|
onCompleted: ({ fetchDynamicAssetsData }) => {
|
|
54
51
|
setAssetsLikes(fetchDynamicAssetsData);
|
|
55
52
|
setLoading(false);
|
|
@@ -57,7 +54,7 @@ const useGetCreationsAndLikesByType = ({ itemType, page, }) => {
|
|
|
57
54
|
onError: () => {
|
|
58
55
|
openAlert({
|
|
59
56
|
type: type_1.alertVariants.error,
|
|
60
|
-
caption:
|
|
57
|
+
caption: "Oops, something went wrong when fetch assets likes.",
|
|
61
58
|
});
|
|
62
59
|
setAssetsLikes([]);
|
|
63
60
|
setLoading(false);
|
|
@@ -69,11 +66,11 @@ const useGetCreationsAndLikesByType = ({ itemType, page, }) => {
|
|
|
69
66
|
setCollectionsLikes(fetchDynamicCollectionsData);
|
|
70
67
|
setLoading(false);
|
|
71
68
|
},
|
|
72
|
-
fetchPolicy:
|
|
69
|
+
fetchPolicy: "no-cache",
|
|
73
70
|
onError: () => {
|
|
74
71
|
openAlert({
|
|
75
72
|
type: type_1.alertVariants.error,
|
|
76
|
-
caption:
|
|
73
|
+
caption: "Oops, something wrong with collections likes.",
|
|
77
74
|
});
|
|
78
75
|
setCollectionsLikes([]);
|
|
79
76
|
setLoading(false);
|
|
@@ -83,10 +80,10 @@ const useGetCreationsAndLikesByType = ({ itemType, page, }) => {
|
|
|
83
80
|
if (allCreations.length > 0) {
|
|
84
81
|
const itemsIdsArray = (0, useGetCreationsAndLikes_1.extractItemIds)(allCreations);
|
|
85
82
|
if (itemsIdsArray.length > 0) {
|
|
86
|
-
if (currentItemType ===
|
|
83
|
+
if (currentItemType === "asset") {
|
|
87
84
|
fetchAssetsLikes({ variables: { assetIds: itemsIdsArray } });
|
|
88
85
|
}
|
|
89
|
-
else if (currentItemType ===
|
|
86
|
+
else if (currentItemType === "collection") {
|
|
90
87
|
fetchCollectionsLikes({
|
|
91
88
|
variables: {
|
|
92
89
|
input: itemsIdsArray.map((collectionId) => {
|
|
@@ -132,7 +129,7 @@ const useGetCreationsAndLikesByType = ({ itemType, page, }) => {
|
|
|
132
129
|
itemType,
|
|
133
130
|
page: {
|
|
134
131
|
token: pageToken,
|
|
135
|
-
...(page &&
|
|
132
|
+
...(page && "size" in page ? { size: page.size } : {}),
|
|
136
133
|
},
|
|
137
134
|
},
|
|
138
135
|
updateQuery: (previousQueryResult) => {
|
|
@@ -142,7 +139,7 @@ const useGetCreationsAndLikesByType = ({ itemType, page, }) => {
|
|
|
142
139
|
const { creations: nextCreations, ...token } = data.fetchCreationsByType;
|
|
143
140
|
setAllCreations((prevCreations) => [
|
|
144
141
|
...prevCreations,
|
|
145
|
-
...nextCreations.map((creation) =>
|
|
142
|
+
...nextCreations.map((creation) => (0, builder_1.buildCreation)(creation)),
|
|
146
143
|
]);
|
|
147
144
|
setNextPageToken(token.nextPage?.token || null);
|
|
148
145
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
declare const useGetMixedLikesFavoriteList: ({ galleryId, itemsCount, }: {
|
|
1
|
+
import { TCreation } from '../../../entities/creation/types';
|
|
2
|
+
import { searchSchema as schema } from "@ludo.ninja/api";
|
|
3
|
+
declare const useGetMixedLikesFavoriteList: ({ galleryId, itemsCount }: {
|
|
5
4
|
galleryId: string;
|
|
6
5
|
itemsCount: number | null;
|
|
7
6
|
}) => {
|
|
8
7
|
gallery: import("../../../entities/gallery/types").TGallery[] | null;
|
|
9
|
-
creationsList: []
|
|
8
|
+
creationsList: TCreation[];
|
|
10
9
|
likes: (schema.IDynamicAssetData | schema.IDynamicCollectionData)[];
|
|
11
10
|
allResults: number | null;
|
|
12
11
|
loading: boolean;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const react_1 = require("react");
|
|
4
|
-
const useGetFavoriteGallaryCreations_1 = require("../../favorites/useGetFavoriteGallaryCreations");
|
|
5
3
|
const useGetTableLikes_1 = require("./useGetTableLikes");
|
|
6
|
-
const
|
|
4
|
+
const types_1 = require("../../../entities/labelCreationType/types");
|
|
5
|
+
const useGetFavoriteGallaryCreations_1 = require("../../favorites/useGetFavoriteGallaryCreations");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const useGetMixedLikesFavoriteList = ({ galleryId, itemsCount }) => {
|
|
7
8
|
const [likes, setLikes] = (0, react_1.useState)([]);
|
|
8
9
|
const [creationsList, setCreationsList] = (0, react_1.useState)([]);
|
|
9
10
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
@@ -17,20 +18,18 @@ const useGetMixedLikesFavoriteList = ({ galleryId, itemsCount, }) => {
|
|
|
17
18
|
if (!creationsLoading && !loadingLikes) {
|
|
18
19
|
const combinedLikes = [];
|
|
19
20
|
fetchedCreationsList.forEach((item) => {
|
|
20
|
-
if (item.
|
|
21
|
-
combinedLikes.push(...assetsLikes.filter((like) => like.assetId === item.
|
|
21
|
+
if (item.itemType === types_1.LabelKeys.asset) {
|
|
22
|
+
combinedLikes.push(...assetsLikes.filter((like) => like.assetId === item.itemId));
|
|
22
23
|
}
|
|
23
24
|
else {
|
|
24
|
-
combinedLikes.push(...collectionsLikes.filter((like) => like.collectionId === item.
|
|
25
|
+
combinedLikes.push(...collectionsLikes.filter((like) => like.collectionId === item.creationId));
|
|
25
26
|
}
|
|
26
27
|
});
|
|
27
28
|
creationsList.length !== combinedLikes.length &&
|
|
28
29
|
setLikes(combinedLikes);
|
|
29
|
-
creationsList.length !== combinedLikes.length &&
|
|
30
|
-
setCreationsList(fetchedCreationsList);
|
|
30
|
+
creationsList.length !== combinedLikes.length && setCreationsList(fetchedCreationsList);
|
|
31
31
|
fetchedCreationsList.length === combinedLikes.length && setLoading(false);
|
|
32
|
-
creationsList.length === fetchedCreationsList.length &&
|
|
33
|
-
setAllItemsFetched(true);
|
|
32
|
+
creationsList.length === fetchedCreationsList.length && setAllItemsFetched(true);
|
|
34
33
|
}
|
|
35
34
|
}, [creationsLoading, JSON.stringify(fetchedCreationsList), loadingLikes]);
|
|
36
35
|
return {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
allItems: Array<CreationEntity | CollectionCreationEntity>;
|
|
1
|
+
import { TCreation } from '../../../entities/creation/types';
|
|
2
|
+
import { searchSchema as schema } from "@ludo.ninja/api";
|
|
3
|
+
declare const useGetTableLikes: ({ allItems }: {
|
|
4
|
+
allItems: Array<TCreation>;
|
|
6
5
|
}) => {
|
|
7
6
|
fetchAssetsLikes: import("@apollo/client").LazyQueryExecFunction<any, import("@apollo/client").OperationVariables>;
|
|
8
7
|
fetchCollectionsLikes: import("@apollo/client").LazyQueryExecFunction<any, import("@apollo/client").OperationVariables>;
|
|
@@ -1,17 +1,13 @@
|
|
|
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.useGetTableLikes = void 0;
|
|
7
|
-
const
|
|
4
|
+
const types_1 = require("../../../entities/labelCreationType/types");
|
|
5
|
+
const ui_1 = require("../../../store/ui");
|
|
8
6
|
const client_1 = require("@apollo/client");
|
|
9
7
|
const api_1 = require("@ludo.ninja/api");
|
|
10
8
|
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
|
|
14
|
-
const useGetTableLikes = ({ allItems, }) => {
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const useGetTableLikes = ({ allItems }) => {
|
|
15
11
|
const [assetsLikes, setAssetsLikes] = (0, react_1.useState)([]);
|
|
16
12
|
const [collectionsLikes, setCollectionsLikes] = (0, react_1.useState)([]);
|
|
17
13
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
@@ -25,7 +21,7 @@ const useGetTableLikes = ({ allItems, }) => {
|
|
|
25
21
|
context: {
|
|
26
22
|
uri: api_1.hosts.searchHost,
|
|
27
23
|
},
|
|
28
|
-
fetchPolicy:
|
|
24
|
+
fetchPolicy: "no-cache",
|
|
29
25
|
onCompleted: ({ fetchDynamicAssetsData }) => {
|
|
30
26
|
setAssetsLikes(fetchDynamicAssetsData);
|
|
31
27
|
activeRequestsCount.current -= 1;
|
|
@@ -34,7 +30,7 @@ const useGetTableLikes = ({ allItems, }) => {
|
|
|
34
30
|
onError: () => {
|
|
35
31
|
openAlert({
|
|
36
32
|
type: type_1.alertVariants.error,
|
|
37
|
-
caption:
|
|
33
|
+
caption: "Oops, something went wrong.",
|
|
38
34
|
});
|
|
39
35
|
setAssetsLikes([]);
|
|
40
36
|
activeRequestsCount.current -= 1;
|
|
@@ -45,7 +41,7 @@ const useGetTableLikes = ({ allItems, }) => {
|
|
|
45
41
|
// loading: collectionsLoading
|
|
46
42
|
},] = (0, client_1.useLazyQuery)(api_1.searchSchema.FetchDynamicCollectionsDataDocument, {
|
|
47
43
|
context: { uri: api_1.hosts.searchHost },
|
|
48
|
-
fetchPolicy:
|
|
44
|
+
fetchPolicy: "no-cache",
|
|
49
45
|
onCompleted: ({ fetchDynamicCollectionsData }) => {
|
|
50
46
|
setCollectionsLikes(fetchDynamicCollectionsData);
|
|
51
47
|
activeRequestsCount.current -= 1;
|
|
@@ -54,7 +50,7 @@ const useGetTableLikes = ({ allItems, }) => {
|
|
|
54
50
|
onError: () => {
|
|
55
51
|
openAlert({
|
|
56
52
|
type: type_1.alertVariants.error,
|
|
57
|
-
caption:
|
|
53
|
+
caption: "Oops, something went wrong.",
|
|
58
54
|
});
|
|
59
55
|
setCollectionsLikes([]);
|
|
60
56
|
activeRequestsCount.current -= 1;
|
|
@@ -71,23 +67,20 @@ const useGetTableLikes = ({ allItems, }) => {
|
|
|
71
67
|
const assetIds = [];
|
|
72
68
|
const collectionIds = [];
|
|
73
69
|
allItems.forEach((item) => {
|
|
74
|
-
if (item
|
|
75
|
-
assetIds.push(item.
|
|
70
|
+
if (item.itemType === types_1.LabelKeys.asset) {
|
|
71
|
+
assetIds.push(item.itemId);
|
|
76
72
|
}
|
|
77
|
-
else if (item
|
|
78
|
-
collectionIds.push(item.
|
|
73
|
+
else if (item.itemType === types_1.LabelKeys.collection) {
|
|
74
|
+
collectionIds.push(item.creationId);
|
|
79
75
|
}
|
|
80
76
|
});
|
|
81
|
-
if (assetIds.length > 0 &&
|
|
82
|
-
JSON.stringify(assetIds) !== JSON.stringify(prevAssetsIds.current)) {
|
|
77
|
+
if (assetIds.length > 0 && JSON.stringify(assetIds) !== JSON.stringify(prevAssetsIds.current)) {
|
|
83
78
|
prevAssetsIds.current = assetIds;
|
|
84
79
|
activeRequestsCount.current += 1;
|
|
85
80
|
!loading && setLoading(true);
|
|
86
81
|
fetchAssetsLikes({ variables: { assetIds } });
|
|
87
82
|
}
|
|
88
|
-
if (collectionIds.length > 0 &&
|
|
89
|
-
JSON.stringify(collectionIds) !==
|
|
90
|
-
JSON.stringify(prevCollectionsIds.current)) {
|
|
83
|
+
if (collectionIds.length > 0 && JSON.stringify(collectionIds) !== JSON.stringify(prevCollectionsIds.current)) {
|
|
91
84
|
prevCollectionsIds.current = collectionIds;
|
|
92
85
|
activeRequestsCount.current += 1;
|
|
93
86
|
!loading && setLoading(true);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { TCreation } from '../../../entities/creation/types';
|
|
1
2
|
import { TGallery } from '../../../entities/gallery/types';
|
|
2
3
|
import { TCurrentItemType } from '../../../hooks/likes/useGetLikesAsset';
|
|
3
4
|
import { TOpportunity } from '../../opportunity/type';
|
|
4
|
-
import { TCreationAndCollection } from '../../virtuoso/types';
|
|
5
5
|
import { TActiveTab } from '../../../system/Tabs/TabsNav/type';
|
|
6
|
-
export type TCreationWithOpportunity =
|
|
6
|
+
export type TCreationWithOpportunity = TCreation | TOpportunity;
|
|
7
7
|
export declare const useGetAssetsAndCollectionForFavorite: <TCreations>({ gallery, activeTab, fetchLikes, }: {
|
|
8
8
|
gallery: TGallery;
|
|
9
9
|
activeTab: TActiveTab;
|
|
@@ -1,18 +1,15 @@
|
|
|
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.useGetAssetsAndCollectionForFavorite = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
const builder_1 = require("../../../entities/creation/builder");
|
|
5
|
+
const collectionCreationBuilder_1 = require("../../../entities/creation/collectionCreationBuilder");
|
|
6
|
+
const types_1 = require("../../../entities/labelCreationType/types");
|
|
9
7
|
const store_1 = require("../store");
|
|
10
8
|
const ui_1 = require("../../../store/ui");
|
|
11
9
|
const extractItemIds_1 = require("../../../utils/extractItemIds");
|
|
12
10
|
const getPageSizeAssets_1 = require("../../../utils/getPageSizeAssets");
|
|
13
11
|
const client_1 = require("@apollo/client");
|
|
14
12
|
const api_1 = require("@ludo.ninja/api");
|
|
15
|
-
const api_2 = require("@ludo.ninja/api");
|
|
16
13
|
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
17
14
|
const react_1 = require("react");
|
|
18
15
|
const limit = 40;
|
|
@@ -77,7 +74,7 @@ const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes,
|
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
76
|
};
|
|
80
|
-
const [fetchAssets, { error: assetsError, refetch: refetchAssets }] = (0, client_1.useLazyQuery)(
|
|
77
|
+
const [fetchAssets, { error: assetsError, refetch: refetchAssets }] = (0, client_1.useLazyQuery)(api_1.searchSchema.FetchAssetsDocument, {
|
|
81
78
|
context: { uri: api_1.hosts.searchHost },
|
|
82
79
|
fetchPolicy: "no-cache",
|
|
83
80
|
onCompleted: ({ fetchAssets: data }) => {
|
|
@@ -86,7 +83,7 @@ const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes,
|
|
|
86
83
|
...(prevAssets || []),
|
|
87
84
|
...data.map((asset) => [
|
|
88
85
|
asset.assetId,
|
|
89
|
-
|
|
86
|
+
(0, builder_1.buildCreation)({
|
|
90
87
|
...asset,
|
|
91
88
|
itemType: "asset",
|
|
92
89
|
itemId: asset.assetId,
|
|
@@ -105,7 +102,7 @@ const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes,
|
|
|
105
102
|
setAssets([]);
|
|
106
103
|
},
|
|
107
104
|
});
|
|
108
|
-
const [fetchCollections, { error: collectionsError, refetch: refetchCollections }] = (0, client_1.useLazyQuery)(
|
|
105
|
+
const [fetchCollections, { error: collectionsError, refetch: refetchCollections }] = (0, client_1.useLazyQuery)(api_1.searchSchema.FetchCollectionsByIdsDocument, {
|
|
109
106
|
context: { uri: api_1.hosts.searchHost },
|
|
110
107
|
fetchPolicy: "no-cache",
|
|
111
108
|
onCompleted: ({ fetchCollectionsByIds: data }) => {
|
|
@@ -114,7 +111,7 @@ const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes,
|
|
|
114
111
|
...(prevCollections || []),
|
|
115
112
|
...data.map((collection) => [
|
|
116
113
|
collection.collectionId,
|
|
117
|
-
|
|
114
|
+
(0, collectionCreationBuilder_1.buildCollectionCreation)(collection, types_1.LabelKeys.collection),
|
|
118
115
|
]),
|
|
119
116
|
];
|
|
120
117
|
getLikesForAllCreations(results.map((el) => el[1]), "collection");
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import CreationEntity from '../../../../dto/CreationEntity';
|
|
1
|
+
import { TCreation } from '../../../../entities/creation/types';
|
|
3
2
|
import { TVirtuosoData } from '../../../virtuoso/types';
|
|
4
3
|
export declare const useVirtuosoData: <TData>({ creations, isMobile }: {
|
|
5
4
|
isMobile: boolean;
|
|
@@ -9,7 +8,7 @@ export declare const useVirtuosoData: <TData>({ creations, isMobile }: {
|
|
|
9
8
|
placeholderData: number[][];
|
|
10
9
|
};
|
|
11
10
|
declare const ItemsPreview: ({ creations, deleteMethod, title, loadMore, isLoading, isNextLoading, allCount, }: {
|
|
12
|
-
creations:
|
|
11
|
+
creations: TCreation[];
|
|
13
12
|
deleteMethod: (itemId: string) => void;
|
|
14
13
|
title: string;
|
|
15
14
|
loadMore?: () => void;
|
|
@@ -5,7 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useVirtuosoData = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const
|
|
8
|
+
const CreationMediaView_1 = require("../../../../entities/creation/CreationMediaView");
|
|
9
|
+
const types_1 = require("../../../../entities/labelCreationType/types");
|
|
9
10
|
const ScreenWidth_1 = require("../../../../styles/ScreenWidth");
|
|
10
11
|
const colors_1 = require("../../../../styles/colors");
|
|
11
12
|
const typography_1 = require("../../../../styles/typography");
|
|
@@ -239,9 +240,13 @@ const ItemsPreview = ({ creations, deleteMethod, title, loadMore, isLoading, isN
|
|
|
239
240
|
}
|
|
240
241
|
return getGapCards();
|
|
241
242
|
})(),
|
|
242
|
-
}, children: data.map((creation) => ((0, jsx_runtime_1.jsxs)("div", { className: "content-item", children: [creation
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
}, children: data.map((creation) => ((0, jsx_runtime_1.jsxs)("div", { className: "content-item", children: [creation.itemType === types_1.LabelKeys.collection ? ((0, jsx_runtime_1.jsx)(CardImage_1.default, { alt: `${creation.name} ${creation.address || ""}`, imgSrc: creation.originalUrls?.[0] ?? "", errorImg: `${constants_1.staticLink}/public/noContent/noContent.svg` })) : ((0, jsx_runtime_1.jsx)(CreationMediaView_1.CreationMediaView, { media: creation.media })), (0, jsx_runtime_1.jsx)("img", { src: `${constants_1.staticLink}/public/gallery/delete.svg`, alt: "delete", width: 24, height: 24, className: "content-item-gallery-deleteIcon", onClick: () =>
|
|
244
|
+
// deleteMethod(
|
|
245
|
+
// creation instanceof CollectionCreationEntity
|
|
246
|
+
// ? `${creation.getItemType() + "." + creation.getCreationId()}`
|
|
247
|
+
// : creation.getCreationId(),
|
|
248
|
+
// )
|
|
249
|
+
deleteMethod(creation.creationId) })] }, creation.creationId))) }));
|
|
245
250
|
},
|
|
246
251
|
};
|
|
247
252
|
})();
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TCreation } from '../../entities/creation/types';
|
|
2
2
|
interface IGalleryAsset {
|
|
3
3
|
isActiveGalleryMode: boolean;
|
|
4
4
|
activateGalleryMode: () => void;
|
|
5
5
|
disableGalleryMode: () => void;
|
|
6
|
-
creationsToGallery:
|
|
7
|
-
toggleCreationToGallery: (creation:
|
|
8
|
-
addCreationToGallery: (creation:
|
|
6
|
+
creationsToGallery: TCreation[];
|
|
7
|
+
toggleCreationToGallery: (creation: TCreation) => void;
|
|
8
|
+
addCreationToGallery: (creation: TCreation) => void;
|
|
9
9
|
removeCreationFromGallery: (itemId: string) => void;
|
|
10
10
|
removeCreationFromGalleryWithCallback: (itemId: string, closeCallback: () => void) => void;
|
|
11
11
|
resetCreationsInGallery: () => void;
|
|
12
12
|
}
|
|
13
|
-
export declare const getIsActiveCreation: (creations:
|
|
13
|
+
export declare const getIsActiveCreation: (creations: TCreation[], creation: TCreation) => boolean;
|
|
14
14
|
export declare const useToGalleryStore: import("zustand/traditional").UseBoundStoreWithEqualityFn<import("zustand").StoreApi<IGalleryAsset>>;
|
|
15
15
|
export declare const useInitializeToGalleryAsset: () => {
|
|
16
16
|
handleAddToGallery: () => void;
|
|
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useInitializeToGalleryAsset = exports.useToGalleryStore = exports.getIsActiveCreation = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const addCreationToGallery_1 = __importDefault(require("../../components/gallery/add/addCreationToGallery"));
|
|
9
|
+
const ui_1 = require("../../store/ui");
|
|
8
10
|
const react_1 = require("react");
|
|
9
11
|
const shallow_1 = require("zustand/shallow");
|
|
10
12
|
const traditional_1 = require("zustand/traditional");
|
|
11
|
-
const
|
|
12
|
-
const ui_1 = require("../../store/ui");
|
|
13
|
-
const getIsActiveCreation = (creations, creation) => !!creations.find((gCreation) => gCreation.getCreationId() === creation.getCreationId());
|
|
13
|
+
const getIsActiveCreation = (creations, creation) => !!creations.find((gCreation) => gCreation.creationId === creation.creationId);
|
|
14
14
|
exports.getIsActiveCreation = getIsActiveCreation;
|
|
15
15
|
exports.useToGalleryStore = (0, traditional_1.createWithEqualityFn)()((setState, getState) => ({
|
|
16
16
|
isActiveGalleryMode: false,
|
|
@@ -34,12 +34,12 @@ exports.useToGalleryStore = (0, traditional_1.createWithEqualityFn)()((setState,
|
|
|
34
34
|
removeCreationFromGallery: (itemId) => {
|
|
35
35
|
setState((prev) => ({
|
|
36
36
|
...prev,
|
|
37
|
-
creationsToGallery: prev.creationsToGallery.filter((pCreation) => pCreation.
|
|
37
|
+
creationsToGallery: prev.creationsToGallery.filter((pCreation) => pCreation.creationId !== itemId),
|
|
38
38
|
}));
|
|
39
39
|
},
|
|
40
40
|
removeCreationFromGalleryWithCallback: (itemId, closeCallback) => {
|
|
41
41
|
setState((prev) => {
|
|
42
|
-
const newCreations = prev.creationsToGallery.filter((pCreation) => pCreation.
|
|
42
|
+
const newCreations = prev.creationsToGallery.filter((pCreation) => pCreation.creationId !== itemId);
|
|
43
43
|
if (!newCreations.length) {
|
|
44
44
|
closeCallback();
|
|
45
45
|
return {
|
|
@@ -53,9 +53,9 @@ exports.useToGalleryStore = (0, traditional_1.createWithEqualityFn)()((setState,
|
|
|
53
53
|
});
|
|
54
54
|
},
|
|
55
55
|
toggleCreationToGallery: (creation) => {
|
|
56
|
-
const { removeCreationFromGallery, addCreationToGallery, creationsToGallery
|
|
56
|
+
const { removeCreationFromGallery, addCreationToGallery, creationsToGallery } = getState();
|
|
57
57
|
if ((0, exports.getIsActiveCreation)(creationsToGallery, creation)) {
|
|
58
|
-
removeCreationFromGallery(creation.
|
|
58
|
+
removeCreationFromGallery(creation.creationId);
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
61
|
addCreationToGallery(creation);
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import CollectionCreationEntity from '../../dto/Collection/CollectionCreationEntity';
|
|
2
|
-
import CreationEntity from '../../dto/CreationEntity';
|
|
3
|
-
export type TCreationAndCollection = CreationEntity | CollectionCreationEntity;
|
|
4
1
|
export type TVirtuosoData<TData> = {
|
|
5
2
|
creationPacks: TData[][];
|
|
6
3
|
creations: TData[];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import CreationEntity from '../../../dto/CreationEntity';
|
|
1
|
+
import { TCreation } from '../../../entities/creation/types';
|
|
3
2
|
export declare const CardHead: ({ creation, isRegularCard, isIconLiked, addLikeToCard, deleteLikeFromCard, isUserProfile, isDisabled, isShowCheckbox, currentMyGalleryId, }: {
|
|
4
|
-
creation:
|
|
3
|
+
creation: TCreation;
|
|
5
4
|
isRegularCard: boolean;
|
|
6
5
|
isIconLiked: boolean;
|
|
7
6
|
addLikeToCard: (id: string) => void;
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.CardHead = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const addCreationToFavoriteList_1 = __importDefault(require("../../../components/favoriteList/add/addCreationToFavoriteList"));
|
|
9
|
-
const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
|
|
10
9
|
const types_1 = require("../../../entities/labelCreationType/types");
|
|
11
10
|
const store_1 = require("../../../modules/user/store");
|
|
12
11
|
const addToFavListIcon_svg_1 = __importDefault(require("../../../public/cards/addToFavListIcon"));
|
|
@@ -38,27 +37,19 @@ const CardHead = ({ creation, isRegularCard, isIconLiked, addLikeToCard, deleteL
|
|
|
38
37
|
redirectToLoginWindow();
|
|
39
38
|
}
|
|
40
39
|
else if (type === "fav-list") {
|
|
41
|
-
openModalSidebarPortal((0, jsx_runtime_1.jsx)(addCreationToFavoriteList_1.default, { ids: [
|
|
42
|
-
creation instanceof CollectionCreationEntity_1.default
|
|
43
|
-
? `${creation.getItemType() + "." + creation.getCreationId()}`
|
|
44
|
-
: creation.getCreationId(),
|
|
45
|
-
], currentMyGalleryId: currentMyGalleryId }));
|
|
40
|
+
openModalSidebarPortal((0, jsx_runtime_1.jsx)(addCreationToFavoriteList_1.default, { ids: [creation.creationId], currentMyGalleryId: currentMyGalleryId }));
|
|
46
41
|
}
|
|
47
42
|
else if (type === "likes") {
|
|
48
43
|
if (!isLicked) {
|
|
49
|
-
await addLikeToCard(creation
|
|
50
|
-
? creation.getCollectionCreationId()
|
|
51
|
-
: creation.getItemId());
|
|
44
|
+
await addLikeToCard(creation.itemId);
|
|
52
45
|
}
|
|
53
46
|
else {
|
|
54
|
-
await deleteLikeFromCard(creation
|
|
55
|
-
? creation.getCollectionCreationId()
|
|
56
|
-
: creation.getItemId());
|
|
47
|
+
await deleteLikeFromCard(creation.itemId);
|
|
57
48
|
}
|
|
58
49
|
}
|
|
59
50
|
};
|
|
60
51
|
const renderLikeButton = () => {
|
|
61
|
-
if ([types_1.LabelKeys.asset, types_1.LabelKeys.collection].includes(creation.
|
|
52
|
+
if ([types_1.LabelKeys.asset, types_1.LabelKeys.collection].includes(creation.itemType)) {
|
|
62
53
|
return ((0, jsx_runtime_1.jsx)("div", { className: `icon like ${isLicked ? "liked" : ""}`, onClick: (e) => handleClick(e, "likes"), children: (0, jsx_runtime_1.jsx)(heart_svg_1.default, {}) }));
|
|
63
54
|
}
|
|
64
55
|
};
|
|
@@ -66,6 +57,6 @@ const CardHead = ({ creation, isRegularCard, isIconLiked, addLikeToCard, deleteL
|
|
|
66
57
|
? {
|
|
67
58
|
pointerEvents: "none",
|
|
68
59
|
}
|
|
69
|
-
: {}, children: [(0, jsx_runtime_1.jsx)("div", { className: "rank", children: (0, jsx_runtime_1.jsx)(CardRank_1.default, { rank: creation.
|
|
60
|
+
: {}, children: [(0, jsx_runtime_1.jsx)("div", { className: "rank", children: (0, jsx_runtime_1.jsx)(CardRank_1.default, { rank: creation.rank }) }), !isProd() && !isShowCheckbox && ((0, jsx_runtime_1.jsxs)("div", { className: "icons", children: [(0, jsx_runtime_1.jsx)("div", { className: "icon", onClick: (e) => handleClick(e, isRegularCard || !isUserProfile || isGallery ? "fav-list" : "gallery"), children: isRegularCard || !isUserProfile || isGallery ? (0, jsx_runtime_1.jsx)(addToFavListIcon_svg_1.default, {}) : (0, jsx_runtime_1.jsx)(addToGalleryIcon_svg_1.default, {}) }), renderLikeButton()] }))] }));
|
|
70
61
|
};
|
|
71
62
|
exports.CardHead = CardHead;
|