@ludo.ninja/components 2.2.17 → 2.2.19
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.
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { searchSchema as schema } from '@ludo.ninja/api';
|
|
2
|
+
import CreationEntity from '../../../../dto/CreationEntity';
|
|
3
|
+
declare const useFindUserLudoCreations: ({ ownerId, scrollTab, }: {
|
|
4
|
+
scrollTab: string | undefined;
|
|
5
|
+
ownerId: schema.IQueryFindUserLudoCreationsArgs["ownerId"];
|
|
6
|
+
}) => {
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
error: import("@apollo/client").ApolloError | undefined;
|
|
9
|
+
totalResults: number;
|
|
10
|
+
creations: CreationEntity[];
|
|
11
|
+
refetchQuery: () => Promise<void>;
|
|
12
|
+
loadMore: () => Promise<void>;
|
|
13
|
+
isNextLoading: boolean;
|
|
14
|
+
};
|
|
15
|
+
export default useFindUserLudoCreations;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const api_1 = require("@ludo.ninja/api");
|
|
8
|
+
const getPageSizeAssets_1 = require("../../../../utils/getPageSizeAssets");
|
|
9
|
+
const CreationEntity_1 = __importDefault(require("../../../../dto/CreationEntity"));
|
|
10
|
+
const limit = 20;
|
|
11
|
+
const useFindUserLudoCreations = ({ ownerId, scrollTab, }) => {
|
|
12
|
+
const [creations, setCreations] = (0, react_1.useState)([]);
|
|
13
|
+
const nextPageToken = (0, react_1.useRef)(null);
|
|
14
|
+
const [results, setResults] = (0, react_1.useState)(0);
|
|
15
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
|
|
16
|
+
const [isNextLoading, setIsNextLoading] = (0, react_1.useState)(false);
|
|
17
|
+
const isHaveNextPage = creations.length < results;
|
|
18
|
+
const [fetchLudoCreations, { error, refetch, fetchMore }] = api_1.searchSchema.useFindUserLudoCreationsLazyQuery({
|
|
19
|
+
context: {
|
|
20
|
+
uri: api_1.hosts.searchHost,
|
|
21
|
+
},
|
|
22
|
+
fetchPolicy: 'no-cache',
|
|
23
|
+
onCompleted: ({ findUserLudoCreations: { creations, ...nextPage } }) => {
|
|
24
|
+
setCreations(creations.map((creation) => new CreationEntity_1.default(creation)));
|
|
25
|
+
setResults(nextPage.nextPage?.elements || 0);
|
|
26
|
+
setIsLoading(false);
|
|
27
|
+
nextPageToken.current = nextPage.nextPage?.token || null;
|
|
28
|
+
},
|
|
29
|
+
onError: () => {
|
|
30
|
+
setCreations([]);
|
|
31
|
+
setIsLoading(false);
|
|
32
|
+
nextPageToken.current = null;
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
(0, react_1.useEffect)(() => {
|
|
36
|
+
setIsLoading(true);
|
|
37
|
+
fetchLudoCreations({
|
|
38
|
+
variables: {
|
|
39
|
+
ownerId,
|
|
40
|
+
page: {
|
|
41
|
+
size: (0, getPageSizeAssets_1.getPageSize)({
|
|
42
|
+
scrollTab,
|
|
43
|
+
limit,
|
|
44
|
+
}),
|
|
45
|
+
token: '',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}, [ownerId]);
|
|
50
|
+
async function refetchQuery() {
|
|
51
|
+
await refetch();
|
|
52
|
+
}
|
|
53
|
+
async function loadMore() {
|
|
54
|
+
if (!nextPageToken.current || !isHaveNextPage)
|
|
55
|
+
return;
|
|
56
|
+
setIsNextLoading(true);
|
|
57
|
+
try {
|
|
58
|
+
const { data } = await fetchMore({
|
|
59
|
+
variables: {
|
|
60
|
+
ownerId,
|
|
61
|
+
page: {
|
|
62
|
+
token: nextPageToken.current,
|
|
63
|
+
size: limit,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
updateQuery: (previousQueryResult) => {
|
|
67
|
+
return previousQueryResult;
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
const { creations: nextCreations, ...nextPage } = data.findUserLudoCreations;
|
|
71
|
+
setCreations((prevCreations) => [
|
|
72
|
+
...prevCreations,
|
|
73
|
+
...nextCreations.map((creation) => new CreationEntity_1.default(creation)),
|
|
74
|
+
]);
|
|
75
|
+
setResults(nextPage.nextPage?.elements || 0);
|
|
76
|
+
nextPageToken.current = nextPage.nextPage?.token || null;
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
//todo uncomment next line
|
|
80
|
+
// throw new Error(error as string);
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
setIsNextLoading(false);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
isLoading,
|
|
88
|
+
error,
|
|
89
|
+
totalResults: results,
|
|
90
|
+
creations,
|
|
91
|
+
refetchQuery,
|
|
92
|
+
loadMore,
|
|
93
|
+
isNextLoading,
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
exports.default = useFindUserLudoCreations;
|
|
@@ -78,12 +78,12 @@ const useSidebarData = () => {
|
|
|
78
78
|
icon: (0, jsx_runtime_1.jsx)(icons_1.RewardsIcon, {}),
|
|
79
79
|
isExternalUrl: false,
|
|
80
80
|
},
|
|
81
|
-
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
},
|
|
81
|
+
// {
|
|
82
|
+
// href: `${ludoDomains[NEXT_PUBLIC_ENV_VALUE as TEnvValue]["account"]}/referrals`,
|
|
83
|
+
// title: "Referral Dashboard",
|
|
84
|
+
// icon: <ReferralDashboardIcon />,
|
|
85
|
+
// isExternalUrl: false,
|
|
86
|
+
// },
|
|
87
87
|
{
|
|
88
88
|
href: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["app"]}/invite-codes`,
|
|
89
89
|
title: "My invites",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ludo.ninja/components",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.19",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"publish": "npm publish --access public -workspace @ludo.ninja/components"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@ludo.ninja/api": "^
|
|
26
|
+
"@ludo.ninja/api": "^3.0.20",
|
|
27
27
|
"@react-three/drei": "^9.68.3",
|
|
28
28
|
"@react-three/fiber": "^8.13.0",
|
|
29
29
|
"chart.js": "^4.4.3",
|