@ludo.ninja/components 2.4.7 → 2.4.9
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-identities/mutations/useRefCodeMutation/index.d.ts +7 -0
- package/build/api/server-identities/mutations/useRefCodeMutation/index.js +31 -0
- package/build/components/sidebar/sidebarInviteCodeLabel/index.js +6 -0
- package/build/components/userBadges/shootingStarBadge/index.d.ts +7 -0
- package/build/components/userBadges/shootingStarBadge/index.js +34 -0
- package/build/hooks/refCode/useRefCode/index.js +3 -3
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -37,6 +37,7 @@ const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
|
|
|
37
37
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
38
38
|
const educatorBadge_1 = __importDefault(require("../../userBadges/educatorBadge"));
|
|
39
39
|
const ambassadorBadge_1 = __importDefault(require("../../userBadges/ambassadorBadge"));
|
|
40
|
+
const shootingStarBadge_1 = __importDefault(require("../../userBadges/shootingStarBadge"));
|
|
40
41
|
const typography_1 = require("@ludo.ninja/ui/build/styles/typography");
|
|
41
42
|
// import UserStreak from "@/components/base/UserStreak";
|
|
42
43
|
// Styles
|
|
@@ -66,6 +67,9 @@ const BadgeStyles = (0, styled_components_1.css) `
|
|
|
66
67
|
const SidebarEducatorBadge = (0, styled_components_1.default)(educatorBadge_1.default) `
|
|
67
68
|
${BadgeStyles};
|
|
68
69
|
`;
|
|
70
|
+
const SidebarShootingStarBadge = (0, styled_components_1.default)(shootingStarBadge_1.default) `
|
|
71
|
+
${BadgeStyles};
|
|
72
|
+
`;
|
|
69
73
|
const SidebarAmbassadorBadge = (0, styled_components_1.default)(ambassadorBadge_1.default) `
|
|
70
74
|
${BadgeStyles};
|
|
71
75
|
`;
|
|
@@ -87,6 +91,8 @@ const SidebarInviteCodeLabel = () => {
|
|
|
87
91
|
switch (profileData?.getBoost()) {
|
|
88
92
|
case 'EDUCATOR':
|
|
89
93
|
return (0, jsx_runtime_1.jsx)(SidebarEducatorBadge, { backgroundColor: '#ffffff' });
|
|
94
|
+
case 'SHOOTING_STAR':
|
|
95
|
+
return (0, jsx_runtime_1.jsx)(SidebarShootingStarBadge, { backgroundColor: '#ffffff' });
|
|
90
96
|
case 'AMBASSADOR':
|
|
91
97
|
return (0, jsx_runtime_1.jsx)(SidebarAmbassadorBadge, { backgroundColor: '#ffffff' });
|
|
92
98
|
default:
|
|
@@ -0,0 +1,34 @@
|
|
|
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 Text_1 = require("@ludo.ninja/ui/build/system/Text");
|
|
8
|
+
const ScreenWidth_1 = require("../../../styles/ScreenWidth");
|
|
9
|
+
const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
|
|
10
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
11
|
+
const Wrapper = styled_components_1.default.div `
|
|
12
|
+
display: flex;
|
|
13
|
+
padding: 3px 11px;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
align-items: center;
|
|
16
|
+
|
|
17
|
+
border-radius: 16px;
|
|
18
|
+
border: 2px solid transparent;
|
|
19
|
+
color: #E77D03;
|
|
20
|
+
background: ${({ background }) => `linear-gradient(to right, ${background}, ${background})`},
|
|
21
|
+
linear-gradient(160deg, #FFE500 0%, #FF9419 100%);
|
|
22
|
+
background-clip: padding-box, border-box;
|
|
23
|
+
background-origin: padding-box, border-box;
|
|
24
|
+
|
|
25
|
+
${ScreenWidth_1.mediaQuery.minWidthFourK} {
|
|
26
|
+
padding: ${(0, _4k_1.adaptiveValueCalc)(3)} ${(0, _4k_1.adaptiveValueCalc)(11)};
|
|
27
|
+
border-radius: ${(0, _4k_1.adaptiveValueCalc)(16)};
|
|
28
|
+
border: ${(0, _4k_1.adaptiveValueCalc)(2)} solid transparent;
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
const ShootingStarBadge = ({ className, backgroundColor = '#f3f4f9' }) => {
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)(Wrapper, { className: className, background: backgroundColor, children: (0, jsx_runtime_1.jsx)(Text_1.H6, { children: "Shooting Star" }) }));
|
|
33
|
+
};
|
|
34
|
+
exports.default = ShootingStarBadge;
|
|
@@ -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 {
|
|
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
|
|
24
|
+
await activateRefCode({ refcode });
|
|
25
25
|
(0, nookies_1.destroyCookie)(null, 'refcode', {
|
|
26
26
|
path: '/',
|
|
27
27
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ludo.ninja/components",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.9",
|
|
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.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",
|