@ludo.ninja/components 2.4.8 → 2.4.10

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 (24) hide show
  1. package/build/api/discord/useCheckDiscordFollow.d.ts +8 -0
  2. package/build/api/discord/useCheckDiscordFollow.js +43 -0
  3. package/build/api/server-identities/mutations/useRefCodeMutation/index.d.ts +7 -0
  4. package/build/api/server-identities/mutations/useRefCodeMutation/index.js +31 -0
  5. package/build/api/server-identities/mutations/useSetEducatorBoost/index.d.ts +7 -0
  6. package/build/api/server-identities/mutations/useSetEducatorBoost/index.js +39 -0
  7. package/build/api/server-identities/mutations/useSetShootingStarBoost/index.d.ts +7 -0
  8. package/build/api/server-identities/mutations/useSetShootingStarBoost/index.js +39 -0
  9. package/build/api/twitter/useCheckFollow.d.ts +8 -0
  10. package/build/api/twitter/useCheckFollow.js +56 -0
  11. package/build/components/ludoEducatorModal/CheckListItem.d.ts +8 -0
  12. package/build/components/ludoEducatorModal/CheckListItem.js +18 -0
  13. package/build/components/ludoEducatorModal/Congratulations.d.ts +4 -0
  14. package/build/components/ludoEducatorModal/Congratulations.js +87 -0
  15. package/build/components/ludoEducatorModal/confetti/index.d.ts +2 -0
  16. package/build/components/ludoEducatorModal/confetti/index.js +43 -0
  17. package/build/components/ludoEducatorModal/index.d.ts +13 -0
  18. package/build/components/ludoEducatorModal/index.js +175 -0
  19. package/build/hooks/refCode/useRefCode/index.js +3 -3
  20. package/build/system/Modals/ModalSidebar/CreatorModalSidebarPortal.js +3 -2
  21. package/build/system/Modals/ModalSidebar/ModalSidebarPortal.d.ts +3 -2
  22. package/build/system/Modals/ModalSidebar/ModalSidebarPortal.js +1 -1
  23. package/build/system/Modals/ModalSidebar/index.js +4 -2
  24. package/package.json +4 -2
@@ -0,0 +1,8 @@
1
+ export type FollowStatus = {
2
+ following: boolean;
3
+ };
4
+ export declare function useCheckDiscordFollow(discordUserId: string | undefined | null, guildId?: string): {
5
+ followDiscordStatus: FollowStatus | null;
6
+ followDiscordStatusLoading: boolean;
7
+ followDiscordStatusError: string | null;
8
+ };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCheckDiscordFollow = useCheckDiscordFollow;
4
+ const react_1 = require("react");
5
+ const PUBLIC_BOT_TOKEN = 'MTQyNTUxNzk0NzkyNDkwNTk5Ng.Gw3gFJ.RqMrnFGVC3yuyB13oCh2m0GDUYpeSRzfMnEXfc';
6
+ function useCheckDiscordFollow(discordUserId, guildId = '854266585862504459') {
7
+ const [status, setStatus] = (0, react_1.useState)(null);
8
+ const [loading, setLoading] = (0, react_1.useState)(false);
9
+ const [error, setError] = (0, react_1.useState)(null);
10
+ (0, react_1.useEffect)(() => {
11
+ if (!discordUserId)
12
+ return;
13
+ async function checkFollow() {
14
+ setLoading(true);
15
+ setError(null);
16
+ try {
17
+ const urlGetUserDiscordId = `https://discord.com/api/guilds/${guildId}/members/${discordUserId}`;
18
+ const followRes = await fetch(urlGetUserDiscordId, {
19
+ headers: {
20
+ Authorization: `Bot ${PUBLIC_BOT_TOKEN}`,
21
+ },
22
+ });
23
+ const followData = await followRes.json();
24
+ setStatus({
25
+ following: followData?.user?.id || false,
26
+ });
27
+ }
28
+ catch (err) {
29
+ setError(err.message || 'Error discord check follow');
30
+ setStatus({ following: false });
31
+ }
32
+ finally {
33
+ setLoading(false);
34
+ }
35
+ }
36
+ // checkFollow();
37
+ }, [discordUserId, guildId]);
38
+ return {
39
+ followDiscordStatus: status,
40
+ followDiscordStatusLoading: loading,
41
+ followDiscordStatusError: error,
42
+ };
43
+ }
@@ -0,0 +1,7 @@
1
+ import { identitySchema as schema } from '@ludo.ninja/api';
2
+ declare const useRefCodeMutation: () => {
3
+ activateRefCode: ({ refcode, }: schema.IUseRefcodeMutationVariables) => Promise<import("@apollo/client").FetchResult<schema.IUseRefcodeMutation>>;
4
+ error: import("@apollo/client").ApolloError | undefined;
5
+ loading: boolean;
6
+ };
7
+ export default useRefCodeMutation;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const api_1 = require("@ludo.ninja/api");
4
+ const data_1 = require("@ludo.ninja/ui/build/system/Alert/data");
5
+ const ui_1 = require("../../../../store/ui");
6
+ const getErrorAlertProps_1 = require("../../../../utils/getErrorAlertProps");
7
+ const useRefCodeMutation = () => {
8
+ const openAlert = (0, ui_1.useUiStore)((state) => state.openAlert);
9
+ const [mutate, { error, loading }] = api_1.identitySchema.useUseRefcodeMutation({
10
+ context: {
11
+ uri: api_1.hosts.identityHost,
12
+ },
13
+ onCompleted: () => {
14
+ openAlert({
15
+ ...data_1.alertSuccess,
16
+ caption: 'Success!',
17
+ text: 'Referral code applied',
18
+ });
19
+ },
20
+ onError: (err) => {
21
+ openAlert((0, getErrorAlertProps_1.getErrorAlertProps)(err));
22
+ },
23
+ });
24
+ return { activateRefCode, error, loading };
25
+ async function activateRefCode({ refcode, }) {
26
+ return mutate({
27
+ variables: { refcode },
28
+ });
29
+ }
30
+ };
31
+ exports.default = useRefCodeMutation;
@@ -0,0 +1,7 @@
1
+ declare const useSetEducatorBoost: () => {
2
+ isSetEducatorBoost: boolean;
3
+ errorSetEducatorBoost: import("@apollo/client").ApolloError | undefined;
4
+ loadingSetEducatorBoost: boolean;
5
+ setEducatorBoost: () => Promise<void>;
6
+ };
7
+ export default useSetEducatorBoost;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ui_1 = require("../../../../store/ui");
4
+ const getErrorAlertProps_1 = require("../../../../utils/getErrorAlertProps");
5
+ const api_1 = require("@ludo.ninja/api");
6
+ const react_1 = require("react");
7
+ const useSetEducatorBoost = () => {
8
+ const [isSetEducatorBoost, setSetEducatorBoost] = (0, react_1.useState)(false);
9
+ const openAlert = (0, ui_1.useUiStore)((state) => state.openAlert);
10
+ const [mutate, { error, loading }] = api_1.identitySchema.useSetEducatorBoostMutation({
11
+ context: {
12
+ uri: api_1.hosts.identityHost,
13
+ },
14
+ fetchPolicy: "no-cache",
15
+ refetchQueries: [api_1.identitySchema.FetchProfileDocument],
16
+ onCompleted: (data) => {
17
+ setSetEducatorBoost(data.setEducatorBoost);
18
+ },
19
+ onError: (err) => {
20
+ setSetEducatorBoost(false);
21
+ openAlert((0, getErrorAlertProps_1.getErrorAlertProps)(err));
22
+ },
23
+ });
24
+ return {
25
+ isSetEducatorBoost,
26
+ errorSetEducatorBoost: error,
27
+ loadingSetEducatorBoost: loading,
28
+ setEducatorBoost,
29
+ };
30
+ async function setEducatorBoost() {
31
+ try {
32
+ await mutate();
33
+ }
34
+ catch (err) {
35
+ throw new Error(err);
36
+ }
37
+ }
38
+ };
39
+ exports.default = useSetEducatorBoost;
@@ -0,0 +1,7 @@
1
+ declare const useSetShootingStarBoost: () => {
2
+ isSetShootingStarBoost: boolean;
3
+ errorSetShootingStarBoost: import("@apollo/client").ApolloError | undefined;
4
+ loadingSetShootingStarBoost: boolean;
5
+ setShootingStarBoost: () => Promise<void>;
6
+ };
7
+ export default useSetShootingStarBoost;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ui_1 = require("../../../../store/ui");
4
+ const getErrorAlertProps_1 = require("../../../../utils/getErrorAlertProps");
5
+ const api_1 = require("@ludo.ninja/api");
6
+ const react_1 = require("react");
7
+ const useSetShootingStarBoost = () => {
8
+ const [isSetShootingStarBoost, setSetShootingStarBoost] = (0, react_1.useState)(false);
9
+ const openAlert = (0, ui_1.useUiStore)((state) => state.openAlert);
10
+ const [mutate, { error, loading }] = api_1.identitySchema.useSetEducatorBoostMutation({
11
+ context: {
12
+ uri: api_1.hosts.identityHost,
13
+ },
14
+ fetchPolicy: "no-cache",
15
+ refetchQueries: [api_1.identitySchema.FetchProfileDocument],
16
+ onCompleted: (data) => {
17
+ setSetShootingStarBoost(data.setEducatorBoost);
18
+ },
19
+ onError: (err) => {
20
+ setSetShootingStarBoost(false);
21
+ openAlert((0, getErrorAlertProps_1.getErrorAlertProps)(err));
22
+ },
23
+ });
24
+ return {
25
+ isSetShootingStarBoost,
26
+ errorSetShootingStarBoost: error,
27
+ loadingSetShootingStarBoost: loading,
28
+ setShootingStarBoost,
29
+ };
30
+ async function setShootingStarBoost() {
31
+ try {
32
+ await mutate();
33
+ }
34
+ catch (err) {
35
+ throw new Error(err);
36
+ }
37
+ }
38
+ };
39
+ exports.default = useSetShootingStarBoost;
@@ -0,0 +1,8 @@
1
+ export type FollowStatus = {
2
+ following: boolean;
3
+ };
4
+ export declare function useCheckFollow(twitterUserName: string, targetId?: string): {
5
+ followStatus: FollowStatus | null;
6
+ followStatusLoading: boolean;
7
+ followStatusError: string | null;
8
+ };
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCheckFollow = useCheckFollow;
4
+ const react_1 = require("react");
5
+ const PUBLIC_RAPIDAPI_KEY = '008878bf3fmsh433e12023d252b1p1a9c62jsn174299b26b6a';
6
+ function useCheckFollow(twitterUserName, targetId = '1566713352138760197') {
7
+ const [status, setStatus] = (0, react_1.useState)(null);
8
+ const [loading, setLoading] = (0, react_1.useState)(false);
9
+ const [error, setError] = (0, react_1.useState)(null);
10
+ (0, react_1.useEffect)(() => {
11
+ if (!twitterUserName)
12
+ return;
13
+ async function checkFollow() {
14
+ setLoading(true);
15
+ setError(null);
16
+ try {
17
+ const urlGetUserTwitterId = `https://twitter-api47.p.rapidapi.com/v2/user/by-username?username=${twitterUserName}`;
18
+ const userRes = await fetch(urlGetUserTwitterId, {
19
+ headers: {
20
+ 'x-rapidapi-host': 'twitter-api47.p.rapidapi.com',
21
+ 'x-rapidapi-key': PUBLIC_RAPIDAPI_KEY,
22
+ },
23
+ });
24
+ const userData = await userRes.json();
25
+ const twitterUserId = userData?.rest_id;
26
+ if (!twitterUserId) {
27
+ throw new Error('Error loading twitter user ID');
28
+ }
29
+ const urlCheckFollow = `https://twitter-api47.p.rapidapi.com/v2/user/friendship?subjectId=${twitterUserId}&targetId=${targetId}`;
30
+ const followRes = await fetch(urlCheckFollow, {
31
+ headers: {
32
+ 'x-rapidapi-host': 'twitter-api47.p.rapidapi.com',
33
+ 'x-rapidapi-key': PUBLIC_RAPIDAPI_KEY
34
+ },
35
+ });
36
+ const followData = await followRes.json();
37
+ setStatus({
38
+ following: followData?.relationship?.source?.following || false,
39
+ });
40
+ }
41
+ catch (err) {
42
+ setError(err.message || 'Error twitter check follow');
43
+ setStatus(null);
44
+ }
45
+ finally {
46
+ setLoading(false);
47
+ }
48
+ }
49
+ checkFollow();
50
+ }, [twitterUserName, targetId]);
51
+ return {
52
+ followStatus: status,
53
+ followStatusLoading: loading,
54
+ followStatusError: error,
55
+ };
56
+ }
@@ -0,0 +1,8 @@
1
+ import React, { FC } from 'react';
2
+ type Props = {
3
+ title: string | React.ReactNode;
4
+ isDone: boolean;
5
+ withoutIcon?: boolean;
6
+ };
7
+ declare const CheckListItem: FC<Props>;
8
+ export default CheckListItem;
@@ -0,0 +1,18 @@
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 styled_components_1 = __importDefault(require("styled-components"));
8
+ const index_1 = require("../../system/index");
9
+ const Wrapper = styled_components_1.default.div `
10
+ display: flex;
11
+ gap: 8px;
12
+ align-items: center;
13
+ `;
14
+ const CheckListItem = ({ title, isDone, withoutIcon }) => {
15
+ return ((0, jsx_runtime_1.jsxs)(Wrapper, { children: [!withoutIcon &&
16
+ (isDone ? ((0, jsx_runtime_1.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: [(0, jsx_runtime_1.jsx)("circle", { cx: "10", cy: "10", r: "8", fill: "#6048FF" }), (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M13.7906 7.2286C14.0698 7.53339 14.0698 8.02757 13.7906 8.33236L9.72351 12.7714C9.44426 13.0762 8.99149 13.0762 8.71224 12.7714L6.20944 10.0397C5.93019 9.73489 5.93019 9.24072 6.20944 8.93592C6.4887 8.63112 6.94146 8.63112 7.22071 8.93592L9.21788 11.1158L12.7793 7.2286C13.0585 6.9238 13.5113 6.9238 13.7906 7.2286Z", fill: "white" })] })) : ((0, jsx_runtime_1.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: [(0, jsx_runtime_1.jsx)("circle", { cx: "10", cy: "10", r: "8", fill: "#F94C66" }), (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M6.92584 6.92063C7.23688 6.58312 7.75169 6.57217 8.0757 6.89617L10.0035 8.82388L11.9314 6.896C12.2555 6.572 12.7703 6.58296 13.0813 6.92047C13.3923 7.25798 13.3818 7.79424 13.0578 8.11824L11.1778 9.99818L13.0578 11.8783C13.3818 12.2023 13.3923 12.7386 13.0813 13.0761C12.7702 13.4136 12.2554 13.4245 11.9314 13.1005L10.0035 11.1725L8.07574 13.1005C7.75176 13.4245 7.23695 13.4136 6.92589 13.0761C6.61483 12.7386 6.6253 12.2024 6.94928 11.8783L8.82919 9.9982L6.94933 8.11839C6.62532 7.7944 6.6148 7.25814 6.92584 6.92063Z", fill: "white" })] }))), (0, jsx_runtime_1.jsx)(index_1.H6, { children: title })] }));
17
+ };
18
+ exports.default = CheckListItem;
@@ -0,0 +1,4 @@
1
+ declare const Congratulations: ({ message, }: {
2
+ message?: string;
3
+ }) => import("react/jsx-runtime").JSX.Element;
4
+ export default Congratulations;
@@ -0,0 +1,87 @@
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 confetti_1 = __importDefault(require("./confetti"));
8
+ const arrow_svg_1 = __importDefault(require("./icons/arrow.svg"));
9
+ const confetti_svg_1 = __importDefault(require("./icons/confetti.svg"));
10
+ const index_1 = require("./index");
11
+ const store_1 = require("../../modules/user/store");
12
+ const env_1 = require("../../store/env");
13
+ const ScreenWidth_1 = require("../../styles/ScreenWidth");
14
+ const colors_1 = require("../../styles/colors");
15
+ const MainButton_1 = __importDefault(require("../../system/Buttons/MainButton"));
16
+ const index_2 = require("../../system/index");
17
+ const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
18
+ const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
19
+ const router_1 = require("next/router");
20
+ const react_1 = require("react");
21
+ const styled_components_1 = __importDefault(require("styled-components"));
22
+ const Title = styled_components_1.default.div `
23
+ display: flex;
24
+ gap: 8px;
25
+ align-items: center;
26
+ justify-content: center;
27
+
28
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
29
+ gap: ${(0, _4k_1.adaptiveValueCalc)(8)};
30
+ }
31
+ `;
32
+ const Description = (0, styled_components_1.default)(index_2.H6) `
33
+ padding: 17px 0 36px;
34
+
35
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
36
+ padding: ${(0, _4k_1.adaptiveValueCalc)(17)} 0 ${(0, _4k_1.adaptiveValueCalc)(36)};
37
+ }
38
+ `;
39
+ const StyledButton = (0, styled_components_1.default)(MainButton_1.default) `
40
+ width: 100%;
41
+ background: rgba(234, 237, 252, 0.5);
42
+ border: 1px solid #eaedfc;
43
+
44
+ > div {
45
+ justify-content: center;
46
+ }
47
+
48
+ &:hover {
49
+ background: rgba(234, 237, 252, 0.5);
50
+ border: 1px solid #eaedfc;
51
+ }
52
+ `;
53
+ const ButtonText = styled_components_1.default.div `
54
+ display: flex;
55
+ gap: 8px;
56
+ align-items: center;
57
+ color: ${colors_1.AccentColor};
58
+
59
+ svg {
60
+ path {
61
+ stroke: ${colors_1.AccentColor};
62
+ }
63
+ }
64
+ `;
65
+ const ModalBackground = styled_components_1.default.div `
66
+ position: absolute;
67
+ inset: 0;
68
+ border-radius: 8px;
69
+ background: linear-gradient(128deg, #86f48f 10.96%, #84c1f3 89.56%);
70
+ z-index: -1;
71
+ `;
72
+ const Congratulations = ({ message = "You are now a Ludo Educator! Check how you can take advantage of it and start earning with our platform.", }) => {
73
+ (0, react_1.useEffect)(() => {
74
+ (0, confetti_1.default)();
75
+ }, []);
76
+ const router = (0, router_1.useRouter)();
77
+ const NEXT_PUBLIC_ENV_VALUE = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_ENV_VALUE);
78
+ const { user } = (0, store_1.useUserStore)((state) => ({
79
+ user: state.user,
80
+ }));
81
+ const userId = user?.userId || "";
82
+ const handleRedirectToRewards = () => {
83
+ router.push(`${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["app"]}/rewards/${userId}`);
84
+ };
85
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(index_1.Wrapper, { children: [(0, jsx_runtime_1.jsxs)(Title, { children: [(0, jsx_runtime_1.jsx)(confetti_svg_1.default, {}), (0, jsx_runtime_1.jsx)(index_2.H3, { children: "Congratulations!" })] }), (0, jsx_runtime_1.jsx)(Description, { children: message }), (0, jsx_runtime_1.jsx)(StyledButton, { variant: "outline", onClick: handleRedirectToRewards, text: (0, jsx_runtime_1.jsxs)(ButtonText, { children: [(0, jsx_runtime_1.jsx)(index_2.H5, { children: "Explore Benefits" }), (0, jsx_runtime_1.jsx)(arrow_svg_1.default, {})] }) })] }), (0, jsx_runtime_1.jsx)(ModalBackground, {})] }));
86
+ };
87
+ exports.default = Congratulations;
@@ -0,0 +1,2 @@
1
+ declare const claimConfetti: () => void;
2
+ export default claimConfetti;
@@ -0,0 +1,43 @@
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 canvas_confetti_1 = __importDefault(require("canvas-confetti"));
7
+ const count = 400;
8
+ const defaults = {
9
+ origin: { y: 0.5 },
10
+ };
11
+ function fire(particleRatio, opts) {
12
+ (0, canvas_confetti_1.default)({
13
+ ...defaults,
14
+ ...opts,
15
+ zIndex: 9999,
16
+ particleCount: Math.floor(count * particleRatio),
17
+ });
18
+ }
19
+ const claimConfetti = () => {
20
+ fire(0.25, {
21
+ spread: 26,
22
+ startVelocity: 75,
23
+ });
24
+ fire(0.2, {
25
+ spread: 60,
26
+ });
27
+ fire(0.35, {
28
+ spread: 100,
29
+ decay: 0.91,
30
+ scalar: 0.8,
31
+ });
32
+ fire(0.1, {
33
+ spread: 120,
34
+ startVelocity: 45,
35
+ decay: 0.92,
36
+ scalar: 1.2,
37
+ });
38
+ fire(0.1, {
39
+ spread: 120,
40
+ startVelocity: 65,
41
+ });
42
+ };
43
+ exports.default = claimConfetti;
@@ -0,0 +1,13 @@
1
+ import { ApolloQueryResult, OperationVariables } from "@apollo/client";
2
+ import { identitySchema as schema } from "@ludo.ninja/api";
3
+ import { IBoostType } from "@ludo.ninja/api/build/graphql_tools/__generated__/identityHost/schema";
4
+ import React, { FC } from "react";
5
+ export declare const Wrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
6
+ type Props = Pick<schema.IProfile, "social"> & {
7
+ refetchProfile: (variables?: Partial<OperationVariables> | undefined) => Promise<ApolloQueryResult<any>>;
8
+ boostType: IBoostType;
9
+ className?: string;
10
+ style?: React.CSSProperties;
11
+ };
12
+ declare const LudoEducatorModal: FC<Props>;
13
+ export default LudoEducatorModal;
@@ -0,0 +1,175 @@
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
+ exports.Wrapper = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const CheckListItem_1 = __importDefault(require("./CheckListItem"));
9
+ const Congratulations_1 = __importDefault(require("./Congratulations"));
10
+ const arrow_svg_1 = __importDefault(require("./icons/arrow.svg"));
11
+ const useCheckDiscordFollow_1 = require("../../api/discord/useCheckDiscordFollow");
12
+ const useSetEducatorBoost_1 = __importDefault(require("../../api/server-identities/mutations/useSetEducatorBoost"));
13
+ const useSetShootingStarBoost_1 = __importDefault(require("../../api/server-identities/mutations/useSetShootingStarBoost"));
14
+ const useCheckFollow_1 = require("../../api/twitter/useCheckFollow");
15
+ const env_1 = require("../../store/env");
16
+ const ui_1 = require("../../store/ui");
17
+ const ScreenWidth_1 = require("../../styles/ScreenWidth");
18
+ const colors_1 = require("../../styles/colors");
19
+ const MainButton_1 = __importDefault(require("../../system/Buttons/MainButton"));
20
+ const index_1 = require("../../system/index");
21
+ const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/identityHost/schema");
22
+ const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
23
+ const ui_2 = require("@ludo.ninja/ui");
24
+ const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
25
+ const utils_1 = require("@ludo.ninja/utils");
26
+ const link_1 = __importDefault(require("next/link"));
27
+ const rc_tooltip_1 = __importDefault(require("rc-tooltip"));
28
+ const react_1 = require("react");
29
+ const react_loading_skeleton_1 = __importDefault(require("react-loading-skeleton"));
30
+ const styled_components_1 = __importDefault(require("styled-components"));
31
+ exports.Wrapper = styled_components_1.default.div `
32
+ width: 272px;
33
+ margin-top: -18px;
34
+ text-align: center;
35
+
36
+ ${ScreenWidth_1.mediaQuery.mobile} {
37
+ margin: 0 auto;
38
+ }
39
+
40
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
41
+ width: ${(0, _4k_1.adaptiveValueCalc)(272)};
42
+ margin-top: ${(0, _4k_1.adaptiveValueCalc)(-18)};
43
+ }
44
+ `;
45
+ const CheckList = styled_components_1.default.div `
46
+ display: inline-flex;
47
+ align-items: start;
48
+ flex-direction: column;
49
+ gap: 12px;
50
+ padding: 24px 0 10px;
51
+
52
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
53
+ gap: ${(0, _4k_1.adaptiveValueCalc)(12)};
54
+ padding: ${(0, _4k_1.adaptiveValueCalc)(24)} 0 ${(0, _4k_1.adaptiveValueCalc)(10)};
55
+ }
56
+ `;
57
+ const StyledLink = (0, styled_components_1.default)(link_1.default) `
58
+ display: flex;
59
+ gap: 8px;
60
+ align-items: center;
61
+ color: ${colors_1.BlackColor};
62
+ cursor: pointer;
63
+
64
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
65
+ gap: ${(0, _4k_1.adaptiveValueCalc)(8)};
66
+ }
67
+
68
+ svg {
69
+ path {
70
+ stroke: #6048ff;
71
+ }
72
+ }
73
+ `;
74
+ const FollowLink = styled_components_1.default.a `
75
+ display: flex;
76
+ gap: 8px;
77
+ align-items: center;
78
+ color: ${colors_1.BlackColor};
79
+ cursor: pointer;
80
+
81
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
82
+ gap: ${(0, _4k_1.adaptiveValueCalc)(8)};
83
+ }
84
+
85
+ svg {
86
+ path {
87
+ stroke: #6048ff;
88
+ }
89
+ }
90
+ `;
91
+ const StyledSkeleton = (0, styled_components_1.default)(react_loading_skeleton_1.default) `
92
+ height: 20px;
93
+ width: 154px;
94
+
95
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
96
+ height: ${(0, _4k_1.adaptiveValueCalc)(20)};
97
+ width: ${(0, _4k_1.adaptiveValueCalc)(154)};
98
+ }
99
+ `;
100
+ const ActionButton = (0, styled_components_1.default)(MainButton_1.default) `
101
+ margin-top: 26px;
102
+
103
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
104
+ margin-top: ${(0, _4k_1.adaptiveValueCalc)(26)};
105
+ }
106
+ `;
107
+ const LudoEducatorModal = ({ social, refetchProfile, boostType, className, style }) => {
108
+ const twitterUserName = social?.twitter?.split("https://x.com/")?.[1] || "";
109
+ const { followStatus, followStatusLoading } = (0, useCheckFollow_1.useCheckFollow)(twitterUserName);
110
+ const { followDiscordStatus, followDiscordStatusLoading } = (0, useCheckDiscordFollow_1.useCheckDiscordFollow)(social?.discordId);
111
+ const { setEducatorBoost, loadingSetEducatorBoost } = (0, useSetEducatorBoost_1.default)();
112
+ const { setShootingStarBoost, loadingSetShootingStarBoost } = (0, useSetShootingStarBoost_1.default)();
113
+ const isSocialsConnected = social?.twitter && social?.telegramLink;
114
+ const isCheckListDone = followStatus?.following && isSocialsConnected && social?.telegramId;
115
+ const isShootingStarCheckListDone = isCheckListDone && followDiscordStatus?.following && social?.discordId;
116
+ const NEXT_PUBLIC_ENV_VALUE = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_ENV_VALUE);
117
+ const openModalSidebarPortal = (0, ui_1.useUiStore)((state) => state.openModalSidebarPortal);
118
+ const closeModalSidebarPortal = (0, ui_1.useUiStore)((state) => state.closeModalSidebarPortal);
119
+ const handleBecomeLudoEducator = () => {
120
+ setEducatorBoost().then(() => {
121
+ refetchProfile && refetchProfile();
122
+ closeModalSidebarPortal();
123
+ openModalSidebarPortal((0, jsx_runtime_1.jsx)(Congratulations_1.default, {}));
124
+ });
125
+ };
126
+ const handleBecomeLudoShootingStar = () => {
127
+ setShootingStarBoost().then(() => {
128
+ refetchProfile && refetchProfile();
129
+ closeModalSidebarPortal();
130
+ openModalSidebarPortal((0, jsx_runtime_1.jsx)(Congratulations_1.default, { message: "You are now a Ludo Shooting Star! Check how you can take advantage of it." }));
131
+ });
132
+ };
133
+ const handleSubmit = () => {
134
+ switch (boostType) {
135
+ case schema_1.IBoostType.Educator:
136
+ handleBecomeLudoEducator();
137
+ return;
138
+ case schema_1.IBoostType.Ambassador:
139
+ handleBecomeLudoShootingStar();
140
+ return;
141
+ }
142
+ };
143
+ const getSubmitButtonLabel = () => {
144
+ switch (boostType) {
145
+ case schema_1.IBoostType.Educator:
146
+ return "Become Ludo Educator";
147
+ case schema_1.IBoostType.Ambassador:
148
+ return "Become Shooting Star";
149
+ }
150
+ };
151
+ const getSubmitButtonDisabled = () => {
152
+ switch (boostType) {
153
+ case schema_1.IBoostType.Educator:
154
+ return !isCheckListDone || loadingSetEducatorBoost;
155
+ case schema_1.IBoostType.Ambassador:
156
+ return !isShootingStarCheckListDone || loadingSetShootingStarBoost;
157
+ }
158
+ };
159
+ (0, react_1.useEffect)(() => {
160
+ refetchProfile && refetchProfile();
161
+ }, []);
162
+ return ((0, jsx_runtime_1.jsxs)(exports.Wrapper, { className: className, style: style, children: [(0, jsx_runtime_1.jsx)(ui_2.H3, { children: "Join Ludo Educators" }), (0, jsx_runtime_1.jsxs)(CheckList, { children: [(0, jsx_runtime_1.jsx)(CheckListItem_1.default, { isDone: !!social?.twitter, title: social?.twitter ? ("Connect Twitter") : ((0, jsx_runtime_1.jsxs)(StyledLink, { href: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["account"]}/settings`, children: [(0, jsx_runtime_1.jsx)(index_1.H6, { children: "Connect Twitter" }), (0, jsx_runtime_1.jsx)(arrow_svg_1.default, {})] })) }), (0, jsx_runtime_1.jsx)(CheckListItem_1.default, { isDone: !!social?.telegramLink, title: social?.telegramLink ? ("Connect Telegram") : ((0, jsx_runtime_1.jsxs)(StyledLink, { href: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["account"]}/settings`, children: [(0, jsx_runtime_1.jsx)(index_1.H6, { children: "Connect Telegram" }), (0, jsx_runtime_1.jsx)(arrow_svg_1.default, {})] })) }), followStatusLoading ? ((0, jsx_runtime_1.jsx)(StyledSkeleton, {})) : ((0, jsx_runtime_1.jsx)(CheckListItem_1.default, { isDone: Boolean(followStatus?.following), title: (0, jsx_runtime_1.jsx)(rc_tooltip_1.default, { placement: "top", trigger: ["hover", "click", "focus"], showArrow: false, styles: {
163
+ root: {
164
+ backgroundColor: "#ffffff",
165
+ opacity: 1,
166
+ boxShadow: " 0px 4px 16px -2px rgba(0, 0, 0, 0.14)",
167
+ borderRadius: "12px",
168
+ },
169
+ body: {
170
+ borderRadius: "12px",
171
+ border: "none",
172
+ },
173
+ }, overlay: (0, jsx_runtime_1.jsx)(index_1.H6, { style: { fontWeight: 500 }, children: "You have to connect the same X account to proceed" }), children: (0, jsx_runtime_1.jsxs)(FollowLink, { onClick: () => closeModalSidebarPortal(), target: "_blank", href: (0, utils_1.appendUtmParam)("https://x.com/LudoHQ"), children: [(0, jsx_runtime_1.jsx)(index_1.H6, { children: "Follow @LudoHQ" }), (0, jsx_runtime_1.jsx)(arrow_svg_1.default, {})] }) }) })), (0, jsx_runtime_1.jsx)(CheckListItem_1.default, { isDone: Boolean(social?.telegramId), title: (0, jsx_runtime_1.jsxs)(FollowLink, { onClick: () => closeModalSidebarPortal(), target: "_blank", href: (0, utils_1.appendUtmParam)("https://t.me/LudoAppBot"), children: [(0, jsx_runtime_1.jsx)(index_1.H6, { children: "Subscribe to @LudoAppBot" }), (0, jsx_runtime_1.jsx)(arrow_svg_1.default, {})] }) }), boostType === schema_1.IBoostType.Ambassador && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(CheckListItem_1.default, { isDone: !!social?.discordId, title: social?.discordId ? ("Connect Discord") : ((0, jsx_runtime_1.jsxs)(StyledLink, { href: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["account"]}/settings`, children: [(0, jsx_runtime_1.jsx)(index_1.H6, { children: "Connect Discord" }), (0, jsx_runtime_1.jsx)(arrow_svg_1.default, {})] })) }), followDiscordStatusLoading ? ((0, jsx_runtime_1.jsx)(StyledSkeleton, {})) : ((0, jsx_runtime_1.jsx)(CheckListItem_1.default, { isDone: Boolean(followDiscordStatus?.following), title: (0, jsx_runtime_1.jsxs)(FollowLink, { onClick: () => closeModalSidebarPortal(), target: "_blank", href: (0, utils_1.appendUtmParam)("https://discord.gg/m2bjPqGbyj"), children: [(0, jsx_runtime_1.jsx)(index_1.H6, { children: "Join Ludo server" }), (0, jsx_runtime_1.jsx)(arrow_svg_1.default, {})] }) }))] }))] }), isSocialsConnected && ((0, jsx_runtime_1.jsx)(ActionButton, { className: "modal-action-btn", variant: "primaryM", text: getSubmitButtonLabel(), disabled: getSubmitButtonDisabled(), onClick: handleSubmit }))] }));
174
+ };
175
+ exports.default = LudoEducatorModal;
@@ -8,12 +8,12 @@ const react_1 = require("react");
8
8
  const router_1 = require("next/router");
9
9
  const nookies_1 = require("nookies");
10
10
  const store_1 = require("../../../modules/user/store");
11
- const useInviteCode_1 = __importDefault(require("../../../api/server-identities/mutations/useInviteCode"));
12
11
  const env_1 = require("../../../store/env");
12
+ const useRefCodeMutation_1 = __importDefault(require("../../../api/server-identities/mutations/useRefCodeMutation"));
13
13
  const useRefCode = () => {
14
14
  const newUser = (0, store_1.useUserStore)((state) => state.user?.newUser);
15
15
  const router = (0, router_1.useRouter)();
16
- const { activateInviteCode } = (0, useInviteCode_1.default)();
16
+ const { activateRefCode } = (0, useRefCodeMutation_1.default)();
17
17
  const isSignedIn = (0, store_1.useUserStore)((state) => state.isSignedIn);
18
18
  const NEXT_PUBLIC_ENV_DOMAIN = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_ENV_DOMAIN);
19
19
  (0, react_1.useEffect)(() => {
@@ -21,7 +21,7 @@ const useRefCode = () => {
21
21
  if (isSignedIn && newUser) {
22
22
  const { refcode } = (0, nookies_1.parseCookies)();
23
23
  if (refcode) {
24
- await activateInviteCode({ inviteCode: refcode });
24
+ await activateRefCode({ refcode });
25
25
  (0, nookies_1.destroyCookie)(null, 'refcode', {
26
26
  path: '/',
27
27
  });
@@ -34,15 +34,16 @@ const ui_1 = require("../../../store/ui");
34
34
  const ModalSidebarPortal = (0, dynamic_1.default)(() => Promise.resolve().then(() => __importStar(require('./ModalSidebarPortal'))).then((_) => _.ModalSidebarPortal));
35
35
  // minimize dom tree for optimize virtualization
36
36
  const CreatorModalSidebarPortal = () => {
37
- const { isOpenModalSidebarPortal, closeModalSidebarPortal, contentModals, withoutCloseIcon } = (0, ui_1.useUiStore)((state) => ({
37
+ const { isOpenModalSidebarPortal, closeModalSidebarPortal, contentModals, withoutCloseIcon, stylesModals } = (0, ui_1.useUiStore)((state) => ({
38
38
  isOpenModalSidebarPortal: state.isOpenModalSidebarPortal,
39
39
  closeModalSidebarPortal: state.closeModalSidebarPortal,
40
40
  contentModals: state.contentModals,
41
41
  withoutCloseIcon: state.modalWithoutCloseIcon,
42
+ stylesModals: state.stylesModals,
42
43
  }));
43
44
  if (!isOpenModalSidebarPortal) {
44
45
  return null;
45
46
  }
46
- return ((0, jsx_runtime_1.jsx)(ModalSidebarPortal, { closeModal: closeModalSidebarPortal, component: contentModals, withoutCloseIcon: withoutCloseIcon }));
47
+ return ((0, jsx_runtime_1.jsx)(ModalSidebarPortal, { closeModal: closeModalSidebarPortal, component: contentModals, withoutCloseIcon: withoutCloseIcon, style: stylesModals ?? undefined }));
47
48
  };
48
49
  exports.CreatorModalSidebarPortal = CreatorModalSidebarPortal;
@@ -1,6 +1,7 @@
1
- import { ReactNode } from "react";
2
- export declare const ModalSidebarPortal: ({ component, closeModal, withoutCloseIcon, }: {
1
+ import { CSSProperties, ReactNode } from "react";
2
+ export declare const ModalSidebarPortal: ({ component, closeModal, withoutCloseIcon, style }: {
3
3
  component: ReactNode;
4
4
  closeModal: () => void;
5
5
  withoutCloseIcon?: boolean;
6
+ style?: CSSProperties;
6
7
  }) => import("react/jsx-runtime").JSX.Element;
@@ -6,5 +6,5 @@ const index_1 = require("./index");
6
6
  const constants_1 = require("@ludo.ninja/core/build/constants");
7
7
  const utils_1 = require("@ludo.ninja/utils");
8
8
  // minimize dom tree for optimize virtualization
9
- const ModalSidebarPortal = ({ component, closeModal, withoutCloseIcon, }) => ((0, jsx_runtime_1.jsx)(utils_1.PortalCreator, { children: (0, jsx_runtime_1.jsxs)(index_1.StyledModalSidebar, { withoutCloseIcon: withoutCloseIcon, children: [(0, jsx_runtime_1.jsx)("img", { src: `${constants_1.staticLink}/public/modal/close.svg`, alt: "close", width: 24, height: 24, className: "modalCloseIcon", onClick: closeModal }), (0, jsx_runtime_1.jsx)("div", { className: "modalContent", children: component })] }) }));
9
+ const ModalSidebarPortal = ({ component, closeModal, withoutCloseIcon, style }) => ((0, jsx_runtime_1.jsx)(utils_1.PortalCreator, { children: (0, jsx_runtime_1.jsxs)(index_1.StyledModalSidebar, { withoutCloseIcon: withoutCloseIcon, style: style, children: [(0, jsx_runtime_1.jsx)("img", { src: `${constants_1.staticLink}/public/modal/close.svg`, alt: "close", width: 24, height: 24, className: "modalCloseIcon", onClick: closeModal }), (0, jsx_runtime_1.jsx)("div", { className: "modalContent", children: component })] }) }));
10
10
  exports.ModalSidebarPortal = ModalSidebarPortal;
@@ -70,14 +70,16 @@ exports.StyledModalSidebar = styled_components_1.default.div `
70
70
  }
71
71
  `;
72
72
  const ModalSidebar = () => {
73
- const { contentModals, isModalSidebarOpen, closeModalSidebar, withoutCloseIcon } = (0, ui_1.useUiStore)((state) => ({
73
+ const { contentModals, isModalSidebarOpen, closeModalSidebar, withoutCloseIcon, stylesModals } = (0, ui_1.useUiStore)((state) => ({
74
74
  contentModals: state.contentModals,
75
75
  isModalSidebarOpen: state.isModalSidebarOpen,
76
76
  closeModalSidebar: state.closeModalSidebar,
77
77
  withoutCloseIcon: state.modalWithoutCloseIcon,
78
+ stylesModals: state.stylesModals,
78
79
  }));
79
80
  if (!isModalSidebarOpen)
80
81
  return null;
81
- return ((0, jsx_runtime_1.jsxs)(exports.StyledModalSidebar, { withoutCloseIcon: withoutCloseIcon, children: [(0, jsx_runtime_1.jsx)("img", { src: `${constants_1.staticLink}/public/modal/close.svg`, alt: "close", width: 24, height: 24, className: "modalCloseIcon", onClick: closeModalSidebar }), (0, jsx_runtime_1.jsx)("div", { className: "modalContent", children: contentModals })] }));
82
+ console.log({ stylesModals });
83
+ return ((0, jsx_runtime_1.jsxs)(exports.StyledModalSidebar, { withoutCloseIcon: withoutCloseIcon, style: stylesModals ? stylesModals : undefined, children: [(0, jsx_runtime_1.jsx)("img", { src: `${constants_1.staticLink}/public/modal/close.svg`, alt: "close", width: 24, height: 24, className: "modalCloseIcon", onClick: closeModalSidebar }), (0, jsx_runtime_1.jsx)("div", { className: "modalContent", children: contentModals })] }));
82
84
  };
83
85
  exports.default = ModalSidebar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ludo.ninja/components",
3
- "version": "2.4.8",
3
+ "version": "2.4.10",
4
4
  "private": false,
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -23,10 +23,11 @@
23
23
  "publish": "npm publish --access public -workspace @ludo.ninja/components"
24
24
  },
25
25
  "dependencies": {
26
- "@ludo.ninja/api": "^3.2.47",
26
+ "@ludo.ninja/api": "^3.2.48",
27
27
  "@next/third-parties": "^15.3.4",
28
28
  "@react-three/drei": "^9.68.3",
29
29
  "@react-three/fiber": "^8.13.0",
30
+ "canvas-confetti": "^1.9.3",
30
31
  "chart.js": "^4.4.3",
31
32
  "framer-motion": "^10.16.16",
32
33
  "glob": "^11.0.0",
@@ -76,6 +77,7 @@
76
77
  "@testing-library/jest-dom": "^5.16.5",
77
78
  "@testing-library/react": "^15.0.6",
78
79
  "@trivago/prettier-plugin-sort-imports": "^4.3.0",
80
+ "@types/canvas-confetti": "^1.6.4",
79
81
  "@types/chrome": "^0.0.260",
80
82
  "@types/lodash.debounce": "^4.0.7",
81
83
  "@types/lodash.remove": "^4.7.7",