@ludo.ninja/components 2.4.22 → 2.4.23

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.
@@ -7,14 +7,14 @@ const react_1 = require("react");
7
7
  const useSetShootingStarBoost = () => {
8
8
  const [isSetShootingStarBoost, setSetShootingStarBoost] = (0, react_1.useState)(false);
9
9
  const openAlert = (0, ui_1.useUiStore)((state) => state.openAlert);
10
- const [mutate, { error, loading }] = api_1.identitySchema.useSetEducatorBoostMutation({
10
+ const [mutate, { error, loading }] = api_1.identitySchema.useSetShootingStarBoostMutation({
11
11
  context: {
12
12
  uri: api_1.hosts.identityHost,
13
13
  },
14
14
  fetchPolicy: "no-cache",
15
15
  refetchQueries: [api_1.identitySchema.FetchProfileDocument],
16
16
  onCompleted: (data) => {
17
- setSetShootingStarBoost(data.setEducatorBoost);
17
+ setSetShootingStarBoost(data.setShootingStarBoost);
18
18
  },
19
19
  onError: (err) => {
20
20
  setSetShootingStarBoost(false);
@@ -0,0 +1,8 @@
1
+ export type FollowStatus = {
2
+ following: boolean;
3
+ };
4
+ export declare function useCheckDiscordFollow(): {
5
+ followDiscordStatus: FollowStatus | null;
6
+ followDiscordStatusLoading: boolean;
7
+ followDiscordStatusError: string | undefined;
8
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCheckDiscordFollow = useCheckDiscordFollow;
4
+ const ui_1 = require("../../../../store/ui");
5
+ const getErrorAlertProps_1 = require("../../../../utils/getErrorAlertProps");
6
+ const api_1 = require("@ludo.ninja/api");
7
+ const react_1 = require("react");
8
+ function useCheckDiscordFollow() {
9
+ const [status, setStatus] = (0, react_1.useState)(null);
10
+ const openAlert = (0, ui_1.useUiStore)((state) => state.openAlert);
11
+ const { error, loading, refetch } = api_1.identitySchema.useCheckDiscordSubscriptionQuery({
12
+ context: {
13
+ uri: api_1.hosts.identityHost,
14
+ },
15
+ onCompleted: ({ checkDiscordSubscription }) => {
16
+ setStatus({ following: checkDiscordSubscription });
17
+ },
18
+ onError: (err) => {
19
+ openAlert((0, getErrorAlertProps_1.getErrorAlertProps)(err));
20
+ },
21
+ });
22
+ return {
23
+ followDiscordStatus: status,
24
+ followDiscordStatusLoading: loading,
25
+ followDiscordStatusError: error?.message,
26
+ };
27
+ }
@@ -7,7 +7,7 @@ exports.Wrapper = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const CheckListItem_1 = __importDefault(require("./CheckListItem"));
9
9
  const Congratulations_1 = __importDefault(require("./Congratulations"));
10
- const useCheckDiscordFollow_1 = require("../../api/discord/useCheckDiscordFollow");
10
+ const useCheckDiscordFollow_1 = require("../../api/server-identities/queries/useCheckDiscordFollow");
11
11
  const useSetEducatorBoost_1 = __importDefault(require("../../api/server-identities/mutations/useSetEducatorBoost"));
12
12
  const useSetShootingStarBoost_1 = __importDefault(require("../../api/server-identities/mutations/useSetShootingStarBoost"));
13
13
  const useFetchProfile_1 = require("../../api/server-identities/queries/useFetchProfile");
@@ -112,7 +112,7 @@ const LudoEducatorModal = ({ userId, onBoostAdded, boostType, className, style }
112
112
  const social = clientProfileData?.getSocial();
113
113
  const twitterUserName = social?.twitter?.split("https://x.com/")?.[1] || "";
114
114
  const { followStatus, followStatusLoading } = (0, useCheckFollow_1.useCheckFollow)(twitterUserName);
115
- const { followDiscordStatus, followDiscordStatusLoading } = (0, useCheckDiscordFollow_1.useCheckDiscordFollow)(social?.discordId);
115
+ const { followDiscordStatus, followDiscordStatusLoading } = (0, useCheckDiscordFollow_1.useCheckDiscordFollow)();
116
116
  const { setEducatorBoost, loadingSetEducatorBoost } = (0, useSetEducatorBoost_1.default)();
117
117
  const { setShootingStarBoost, loadingSetShootingStarBoost } = (0, useSetShootingStarBoost_1.default)();
118
118
  const isSocialsConnected = social?.twitter && social?.telegramLink;
@@ -142,7 +142,7 @@ const LudoEducatorModal = ({ userId, onBoostAdded, boostType, className, style }
142
142
  case schema_1.IBoostType.Educator:
143
143
  handleBecomeLudoEducator();
144
144
  return;
145
- case schema_1.IBoostType.Ambassador:
145
+ case schema_1.IBoostType.ShootingStar:
146
146
  handleBecomeLudoShootingStar();
147
147
  return;
148
148
  }
@@ -151,7 +151,7 @@ const LudoEducatorModal = ({ userId, onBoostAdded, boostType, className, style }
151
151
  switch (boostType) {
152
152
  case schema_1.IBoostType.Educator:
153
153
  return "Become Ludo Educator";
154
- case schema_1.IBoostType.Ambassador:
154
+ case schema_1.IBoostType.ShootingStar:
155
155
  return "Become Shooting Star";
156
156
  }
157
157
  };
@@ -159,7 +159,7 @@ const LudoEducatorModal = ({ userId, onBoostAdded, boostType, className, style }
159
159
  switch (boostType) {
160
160
  case schema_1.IBoostType.Educator:
161
161
  return !isCheckListDone || loadingSetEducatorBoost || clientProfileLoading;
162
- case schema_1.IBoostType.Ambassador:
162
+ case schema_1.IBoostType.ShootingStar:
163
163
  return !isShootingStarCheckListDone || loadingSetShootingStarBoost || clientProfileLoading;
164
164
  }
165
165
  };
@@ -177,6 +177,6 @@ const LudoEducatorModal = ({ userId, onBoostAdded, boostType, className, style }
177
177
  borderRadius: "12px",
178
178
  border: "none",
179
179
  },
180
- }, 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)(ArrowIcon_1.default, {})] }) }) })), clientProfileLoading ? ((0, jsx_runtime_1.jsx)(StyledSkeleton, {})) : ((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?start=${userId}`), children: [(0, jsx_runtime_1.jsx)(index_1.H6, { children: "Register to LudoAppBot" }), (0, jsx_runtime_1.jsx)(ArrowIcon_1.default, {})] }) })), boostType === schema_1.IBoostType.Ambassador && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [clientProfileLoading ? ((0, jsx_runtime_1.jsx)(StyledSkeleton, {})) : ((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)(ArrowIcon_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)(ArrowIcon_1.default, {})] }) }))] }))] }), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { layout: true, children: (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: { opacity: 0, y: 20 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: 20 }, transition: { type: "spring", stiffness: 280, damping: 18 }, className: "w-full flex justify-center", children: (0, jsx_runtime_1.jsx)(ActionButton, { className: "modal-action-btn", variant: "primaryM", text: getSubmitButtonLabel(), disabled: getSubmitButtonDisabled(), onClick: handleSubmit }) }, "submit-btn") }) })] }));
180
+ }, 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)(ArrowIcon_1.default, {})] }) }) })), clientProfileLoading ? ((0, jsx_runtime_1.jsx)(StyledSkeleton, {})) : ((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?start=${userId}`), children: [(0, jsx_runtime_1.jsx)(index_1.H6, { children: "Register to LudoAppBot" }), (0, jsx_runtime_1.jsx)(ArrowIcon_1.default, {})] }) })), boostType === schema_1.IBoostType.ShootingStar && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [clientProfileLoading ? ((0, jsx_runtime_1.jsx)(StyledSkeleton, {})) : ((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)(ArrowIcon_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)(ArrowIcon_1.default, {})] }) }))] }))] }), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { layout: true, children: (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: { opacity: 0, y: 20 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: 20 }, transition: { type: "spring", stiffness: 280, damping: 18 }, className: "w-full flex justify-center", children: (0, jsx_runtime_1.jsx)(ActionButton, { className: "modal-action-btn", variant: "primaryM", text: getSubmitButtonLabel(), disabled: getSubmitButtonDisabled(), onClick: handleSubmit }) }, "submit-btn") }) })] }));
181
181
  };
182
182
  exports.default = LudoEducatorModal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ludo.ninja/components",
3
- "version": "2.4.22",
3
+ "version": "2.4.23",
4
4
  "private": false,
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -1,8 +0,0 @@
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
- };
@@ -1,43 +0,0 @@
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.GxKVUP.DlgMRxCmLVlCzmCnIm6dBgEw5g8CtciSCCpnNI';
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
- }