@ludo.ninja/components 2.4.36 → 2.4.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.
- package/build/api/server-opportunities/queries/useGetOpportunities.d.ts +1 -1
- package/build/components/headers/components/headerExperienceLabel/index.js +4 -2
- package/build/components/sidebar/sidebarInviteCodeLabel/index.js +4 -2
- package/build/modules/opportunity/type.d.ts +1 -1
- package/build/modules/user/profileData/profileDataInitialization.js +3 -1
- package/build/modules/user/store.d.ts +3 -0
- package/build/modules/user/store.js +7 -0
- package/build/system/Labels/CreditsLabel/CreditsLabel.test.d.ts +1 -0
- package/build/system/Labels/CreditsLabel/CreditsLabel.test.js +44 -0
- package/build/system/Labels/CreditsLabel/index.d.ts +6 -0
- package/build/system/Labels/CreditsLabel/index.js +57 -0
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const useGetOpportunities: (availableProfileId: string) => {
|
|
2
|
-
opportunities: import("@ludo.ninja/api/build/graphql_tools/__generated__/opportunitiesHost/schema").Maybe<Pick<import("@ludo.ninja/api/build/graphql_tools/__generated__/opportunitiesHost/schema").IOpportunityV2, "views" | "createdAt" | "shareLink" | "blockchain" | "name" | "description" | "collection" | "liked" | "opportunityId" | "projectId" | "categoryId" | "opportunityStatus" | "opportunityType" | "notificationType" | "projectBlockchain" | "projectContract" | "projectName" | "projectSlug" | "categoryName" | "ludoUrl" | "projectUrl" | "activeFrom" | "activeUntil" | "
|
|
2
|
+
opportunities: import("@ludo.ninja/api/build/graphql_tools/__generated__/opportunitiesHost/schema").Maybe<Pick<import("@ludo.ninja/api/build/graphql_tools/__generated__/opportunitiesHost/schema").IOpportunityV2, "views" | "createdAt" | "shareLink" | "blockchain" | "name" | "description" | "collection" | "liked" | "opportunityId" | "projectId" | "categoryId" | "opportunityStatus" | "opportunityType" | "notificationType" | "projectBlockchain" | "projectContract" | "projectName" | "projectSlug" | "categoryName" | "ludoUrl" | "projectUrl" | "activeFrom" | "activeUntil" | "minRank" | "maxRank" | "media" | "reportLink" | "clicks" | "blockchains" | "minWalletValue" | "maxWalletValue" | "geolocations" | "subscribed" | "participantsLimit" | "availablePlacesForAirdrop" | "slug">>[];
|
|
3
3
|
isLoadingOpportunities: boolean;
|
|
4
4
|
};
|
|
@@ -11,6 +11,7 @@ const ScreenWidth_1 = require("../../../../styles/ScreenWidth");
|
|
|
11
11
|
const ExperienceLabel_1 = __importDefault(require("../../../../system/Labels/ExperienceLabel"));
|
|
12
12
|
const env_1 = require("../../../../store/env");
|
|
13
13
|
const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
|
|
14
|
+
const CreditsLabel_1 = __importDefault(require("../../../../system/Labels/CreditsLabel"));
|
|
14
15
|
// Styles
|
|
15
16
|
const StyledHeaderExperienceLabel = styled_components_1.default.div `
|
|
16
17
|
margin-right: 20px;
|
|
@@ -21,14 +22,15 @@ const StyledHeaderExperienceLabel = styled_components_1.default.div `
|
|
|
21
22
|
// Component
|
|
22
23
|
const HeaderExperienceLabel = ({ userId }) => {
|
|
23
24
|
const NEXT_PUBLIC_ENV_VALUE = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_ENV_VALUE);
|
|
24
|
-
const { userExp, isLoadingExp, errorExp } = (0, store_1.useUserStore)((state) => ({
|
|
25
|
+
const { userCredits, userExp, isLoadingExp, errorExp } = (0, store_1.useUserStore)((state) => ({
|
|
26
|
+
userCredits: state.userCredits,
|
|
25
27
|
userExp: state.userExp,
|
|
26
28
|
isLoadingExp: state.isLoadingExp,
|
|
27
29
|
errorExp: state.errorExp,
|
|
28
30
|
}));
|
|
29
31
|
if (!userId)
|
|
30
32
|
return null;
|
|
31
|
-
return ((0, jsx_runtime_1.jsx)(StyledHeaderExperienceLabel, { children: (0, jsx_runtime_1.jsx)(ExperienceLabel_1.default, { value: userExp.xps, link: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["app"]}/rewards/${userId}`, loading: isLoadingExp || !!errorExp }) }));
|
|
33
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(StyledHeaderExperienceLabel, { children: (0, jsx_runtime_1.jsx)(CreditsLabel_1.default, { value: userCredits, link: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["app"]}/rewards/${userId}`, loading: isLoadingExp || !!errorExp }) }), (0, jsx_runtime_1.jsx)(StyledHeaderExperienceLabel, { children: (0, jsx_runtime_1.jsx)(ExperienceLabel_1.default, { value: userExp.xps, link: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["app"]}/rewards/${userId}`, loading: isLoadingExp || !!errorExp }) })] }));
|
|
32
34
|
};
|
|
33
35
|
// Export
|
|
34
36
|
exports.default = HeaderExperienceLabel;
|
|
@@ -37,6 +37,7 @@ const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
|
|
|
37
37
|
const typography_1 = require("@ludo.ninja/ui/build/styles/typography");
|
|
38
38
|
const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
|
|
39
39
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
40
|
+
const CreditsLabel_1 = __importDefault(require("../../../system/Labels/CreditsLabel"));
|
|
40
41
|
// import UserStreak from "@/components/base/UserStreak";
|
|
41
42
|
// Styles
|
|
42
43
|
const StyledSidebarInviteCodeLabel = styled_components_1.default.div `
|
|
@@ -67,8 +68,9 @@ const SidebarBoostBadge = (0, styled_components_1.default)(boostBadge_1.default)
|
|
|
67
68
|
`;
|
|
68
69
|
// Component
|
|
69
70
|
const SidebarInviteCodeLabel = () => {
|
|
70
|
-
const { getUser, userExp, isLoadingExp, errorExp, isLoadingProfileData, inviteCodes } = (0, store_1.useUserStore)((state) => ({
|
|
71
|
+
const { getUser, userCredits, userExp, isLoadingExp, errorExp, isLoadingProfileData, inviteCodes } = (0, store_1.useUserStore)((state) => ({
|
|
71
72
|
getUser: state.user,
|
|
73
|
+
userCredits: state.userCredits,
|
|
72
74
|
userExp: state.userExp,
|
|
73
75
|
isLoadingExp: state.isLoadingExp,
|
|
74
76
|
errorExp: state.errorExp,
|
|
@@ -79,7 +81,7 @@ const SidebarInviteCodeLabel = () => {
|
|
|
79
81
|
const isProd = (0, env_1.useEnvStore)((state) => state.isProd);
|
|
80
82
|
const unUsedInviteCodes = inviteCodes?.filter((code) => !code.isUsed);
|
|
81
83
|
const profileData = (0, store_1.useUserStore)((state) => state.profileData);
|
|
82
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(StyledSidebarInviteCodeLabel, { children: [(0, jsx_runtime_1.jsx)(ExperienceLabel_1.default, { value: userExp.xps, link: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["app"]}/rewards/${getUser?.userId}`, loading: isLoadingExp || !!errorExp }), (0, jsx_runtime_1.jsx)(
|
|
84
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(StyledSidebarInviteCodeLabel, { children: [(0, jsx_runtime_1.jsx)(SidebarBoostBadge, { boostType: profileData?.getBoost(), previousBoostType: profileData?.getPreviousBoost(), backgroundColor: '#ffffff' }), (0, jsx_runtime_1.jsx)(ExperienceLabel_1.default, { value: userExp.xps, link: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["app"]}/rewards/${getUser?.userId}`, loading: isLoadingExp || !!errorExp }), (0, jsx_runtime_1.jsx)(CreditsLabel_1.default, { value: userCredits, link: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["app"]}/rewards/${getUser?.userId}`, loading: isLoadingExp || !!errorExp }), !!unUsedInviteCodes && !isProd() && ((0, jsx_runtime_1.jsx)(InviteLabel_1.default, { value: unUsedInviteCodes.length, link: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["app"]}/invite-codes`, loading: isLoadingProfileData }))] }) }));
|
|
83
85
|
};
|
|
84
86
|
// Export
|
|
85
87
|
exports.default = SidebarInviteCodeLabel;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { opportunitiesSchema } from '@ludo.ninja/api';
|
|
2
|
-
export type TOpportunity = Pick<opportunitiesSchema.IOpportunityV2, 'opportunityId' | 'projectId' | 'categoryId' | 'opportunityStatus' | 'opportunityType' | 'notificationType' | 'name' | 'description' | 'projectBlockchain' | 'projectContract' | 'projectName' | 'projectSlug' | 'categoryName' | 'ludoUrl' | 'projectUrl' | 'activeFrom' | 'activeUntil' | '
|
|
2
|
+
export type TOpportunity = Pick<opportunitiesSchema.IOpportunityV2, 'opportunityId' | 'projectId' | 'categoryId' | 'opportunityStatus' | 'opportunityType' | 'notificationType' | 'name' | 'description' | 'projectBlockchain' | 'projectContract' | 'projectName' | 'projectSlug' | 'categoryName' | 'ludoUrl' | 'projectUrl' | 'activeFrom' | 'activeUntil' | 'minRank' | 'maxRank' | 'media' | 'reportLink' | 'clicks' | 'views' | 'blockchain' | 'collection' | 'createdAt' | 'minWalletValue' | 'maxWalletValue' | 'shareLink' | 'liked' | 'participantsLimit' | 'availablePlacesForAirdrop' | 'subscribed' | 'slug'>;
|
|
@@ -12,13 +12,14 @@ const FetcherMyProfile = ( /*{ userId }: { userId: string }*/) => {
|
|
|
12
12
|
const openAlert = (0, ui_1.useUiStore)((state) => state.openAlert);
|
|
13
13
|
const { setIsLoadingProfileData, setProfileData,
|
|
14
14
|
// profileData,
|
|
15
|
-
setUserExp, setInviteCodes, setMyShareLink, } = (0, store_1.useUserStore)((state) => ({
|
|
15
|
+
setUserExp, setInviteCodes, setMyShareLink, setUserCredits, } = (0, store_1.useUserStore)((state) => ({
|
|
16
16
|
setIsLoadingProfileData: state.setIsLoadingProfileData,
|
|
17
17
|
setProfileData: state.setProfileData,
|
|
18
18
|
profileData: state.profileData,
|
|
19
19
|
setUserExp: state.setUserExp,
|
|
20
20
|
setInviteCodes: state.setInviteCodes,
|
|
21
21
|
setMyShareLink: state.setMyShareLink,
|
|
22
|
+
setUserCredits: state.setUserCredits,
|
|
22
23
|
}));
|
|
23
24
|
// console.log('profileData', profileData);
|
|
24
25
|
api_2.identitySchema.useFetchMyProfileV2Query({
|
|
@@ -29,6 +30,7 @@ const FetcherMyProfile = ( /*{ userId }: { userId: string }*/) => {
|
|
|
29
30
|
onCompleted: ({ fetchMyProfileV2: fetchMyProfile }) => {
|
|
30
31
|
// console.log('fetchMyProfile', fetchMyProfile);
|
|
31
32
|
setProfileData(fetchMyProfile);
|
|
33
|
+
setUserCredits(fetchMyProfile.credits || 0);
|
|
32
34
|
if (fetchMyProfile.shareLink) {
|
|
33
35
|
setMyShareLink(fetchMyProfile.shareLink);
|
|
34
36
|
}
|
|
@@ -12,6 +12,9 @@ export interface IUserStore {
|
|
|
12
12
|
user: IUser | null;
|
|
13
13
|
setUser: (user: IUser | null) => void;
|
|
14
14
|
isSignedIn: boolean;
|
|
15
|
+
userCredits: number;
|
|
16
|
+
setUserCredits: (userCredits: number) => void;
|
|
17
|
+
resetUserCredits: () => void;
|
|
15
18
|
userExp: UserXp;
|
|
16
19
|
setUserExp: (userExp: UserXp) => void;
|
|
17
20
|
resetUserExp: () => void;
|
|
@@ -21,6 +21,13 @@ const creators = (0, next_zustand_1.createProvider)()((setState) => ({
|
|
|
21
21
|
setUser: (user) => {
|
|
22
22
|
setState({ user, isSignedIn: !!user });
|
|
23
23
|
},
|
|
24
|
+
userCredits: 0,
|
|
25
|
+
setUserCredits: (userCredits) => {
|
|
26
|
+
setState({ userCredits });
|
|
27
|
+
},
|
|
28
|
+
resetUserCredits: () => {
|
|
29
|
+
setState({ userCredits: 0 });
|
|
30
|
+
},
|
|
24
31
|
userExp: initialUserExp,
|
|
25
32
|
setUserExp: (userExp) => {
|
|
26
33
|
setState({ userExp });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
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 jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_1 = require("@testing-library/react");
|
|
8
|
+
const index_1 = __importDefault(require("./index"));
|
|
9
|
+
describe('CreditsLabel Component', () => {
|
|
10
|
+
test('renders with value and link', () => {
|
|
11
|
+
const props = {
|
|
12
|
+
value: 50,
|
|
13
|
+
link: '/profile/123',
|
|
14
|
+
loading: false,
|
|
15
|
+
};
|
|
16
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(index_1.default, { ...props }));
|
|
17
|
+
const inviteText = react_1.screen.getByText('50 credits');
|
|
18
|
+
expect(inviteText).toBeInTheDocument();
|
|
19
|
+
const linkElement = react_1.screen.getByRole('link', { name: /50 profile/i });
|
|
20
|
+
expect(linkElement).toHaveAttribute('href', '/profile/123');
|
|
21
|
+
});
|
|
22
|
+
test('renders loading skeleton', () => {
|
|
23
|
+
const props = {
|
|
24
|
+
value: 0,
|
|
25
|
+
link: '/profile/123',
|
|
26
|
+
loading: true,
|
|
27
|
+
};
|
|
28
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)("div", { "data-testid": 'test_container', children: (0, jsx_runtime_1.jsx)(index_1.default, { ...props }) }));
|
|
29
|
+
const skeletonElement = react_1.screen
|
|
30
|
+
.getByTestId('test_container')
|
|
31
|
+
.querySelector('.react-loading-skeleton');
|
|
32
|
+
expect(skeletonElement).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
test('does not render when value is falsy', () => {
|
|
35
|
+
const props = {
|
|
36
|
+
value: 0,
|
|
37
|
+
link: '/profile/123',
|
|
38
|
+
loading: false,
|
|
39
|
+
};
|
|
40
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(index_1.default, { ...props }));
|
|
41
|
+
const inviteText = react_1.screen.queryByText('0 credits');
|
|
42
|
+
expect(inviteText).not.toBeInTheDocument();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
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 jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const vars_1 = require("../../../fonts/vars");
|
|
8
|
+
const ScreenWidth_1 = require("../../../styles/ScreenWidth");
|
|
9
|
+
const boxShadow_1 = __importDefault(require("../../../styles/mixins/boxShadow"));
|
|
10
|
+
const boxTransform_1 = __importDefault(require("../../../styles/mixins/boxTransform"));
|
|
11
|
+
const SkeletonLabel_1 = __importDefault(require("../SkeletonLabel"));
|
|
12
|
+
const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
|
|
13
|
+
const link_1 = __importDefault(require("next/link"));
|
|
14
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
15
|
+
// Styles
|
|
16
|
+
const StyledExpTab = (0, styled_components_1.default)(link_1.default) `
|
|
17
|
+
${boxTransform_1.default};
|
|
18
|
+
${boxShadow_1.default};
|
|
19
|
+
display: flex;
|
|
20
|
+
gap: 8px;
|
|
21
|
+
user-select: none;
|
|
22
|
+
justify-content: flex-start;
|
|
23
|
+
align-items: center;
|
|
24
|
+
padding: 5px 16px;
|
|
25
|
+
max-width: max-content;
|
|
26
|
+
min-width: 80px;
|
|
27
|
+
min-height: 32px;
|
|
28
|
+
border-radius: 24px;
|
|
29
|
+
background: ${({ theme }) => theme.colors?.inviteCodesGradientLabel?.gradient};
|
|
30
|
+
|
|
31
|
+
.value {
|
|
32
|
+
font-family: ${vars_1.poppinsFontVarCss.css};
|
|
33
|
+
font-size: 1.6em;
|
|
34
|
+
font-weight: 600;
|
|
35
|
+
line-height: 1.3;
|
|
36
|
+
color: ${({ theme }) => theme.colors?.inviteCodesGradientLabel?.color};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
${ScreenWidth_1.mediaQuery.minWidthFourK} {
|
|
40
|
+
gap: ${(0, _4k_1.adaptiveValueCalc)(8)};
|
|
41
|
+
padding: ${(0, _4k_1.adaptiveValueCalc)(5)} ${(0, _4k_1.adaptiveValueCalc)(16)};
|
|
42
|
+
min-width: ${(0, _4k_1.adaptiveValueCalc)(80)};
|
|
43
|
+
min-height: ${(0, _4k_1.adaptiveValueCalc)(32)};
|
|
44
|
+
border-radius: ${(0, _4k_1.adaptiveValueCalc)(24)};
|
|
45
|
+
|
|
46
|
+
.value {
|
|
47
|
+
font-size: ${(0, _4k_1.adaptiveValueCalc)(16)};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
//Component
|
|
52
|
+
const CreditsLabel = ({ value = 0, link, loading }) => {
|
|
53
|
+
if (loading)
|
|
54
|
+
return (0, jsx_runtime_1.jsx)(SkeletonLabel_1.default, {});
|
|
55
|
+
return ((0, jsx_runtime_1.jsx)(StyledExpTab, { href: link, children: (0, jsx_runtime_1.jsx)("p", { className: `value `, children: `${value} credits` }) }));
|
|
56
|
+
};
|
|
57
|
+
exports.default = CreditsLabel;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ludo.ninja/components",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.38",
|
|
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": "^3.2.
|
|
26
|
+
"@ludo.ninja/api": "^3.2.60",
|
|
27
27
|
"@marker.io/browser": "^0.19.0",
|
|
28
28
|
"@next/third-parties": "^15.3.4",
|
|
29
29
|
"@react-three/drei": "^9.68.3",
|