@ludo.ninja/components 2.4.8 → 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.
@@ -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;
@@ -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
  });
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.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.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",