@ludo.ninja/components 2.2.53 → 2.2.55
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/hoc/HOCSignUpInterceptor/CircleSvg.d.ts +1 -0
- package/build/hoc/HOCSignUpInterceptor/CircleSvg.js +6 -0
- package/build/hoc/HOCSignUpInterceptor/HOCSignUpInterceptor.d.ts +2 -0
- package/build/hoc/HOCSignUpInterceptor/HOCSignUpInterceptor.js +103 -0
- package/build/layouts/AppLayout.d.ts +2 -2
- package/build/layouts/AppLayout.js +6 -4
- package/build/modules/user/auth/HOCAuthSearchParamsLocalhostInterceptor.d.ts +3 -0
- package/build/modules/user/auth/HOCAuthSearchParamsLocalhostInterceptor.js +36 -0
- package/build/utils/auth/index.js +3 -1
- package/build/utils/redirectToApp.d.ts +1 -0
- package/build/utils/redirectToApp.js +29 -0
- package/package.json +1 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export declare const HOCSignUpInterceptor: (Component: ReactNode, isAuthorized?: boolean) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<import("react").AwaitedReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
@@ -0,0 +1,103 @@
|
|
|
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.HOCSignUpInterceptor = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const CircleSvg_1 = require("./CircleSvg");
|
|
9
|
+
const LWithSearchHeader_1 = __importDefault(require("../../layouts/base/LWithSearchHeader"));
|
|
10
|
+
const store_1 = require("../../modules/user/store");
|
|
11
|
+
const redirectToApp_1 = require("../../utils/redirectToApp");
|
|
12
|
+
const ScreenWidth_1 = require("@ludo.ninja/ui/build/styles/ScreenWidth");
|
|
13
|
+
const MainButton_1 = __importDefault(require("@ludo.ninja/ui/build/system/Buttons/MainButton"));
|
|
14
|
+
const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
|
|
15
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
16
|
+
const SWrapper = styled_components_1.default.div `
|
|
17
|
+
padding-top: 132px;
|
|
18
|
+
|
|
19
|
+
${ScreenWidth_1.mediaQuery.mobile} {
|
|
20
|
+
padding-top: 82px;
|
|
21
|
+
overflow-x: hidden;
|
|
22
|
+
min-height: var(--app-height);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
${ScreenWidth_1.mediaQuery.minWidthFourK} {
|
|
26
|
+
padding-top: ${(0, _4k_1.adaptiveValueCalc)(132)};
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
const SContainer = styled_components_1.default.div `
|
|
30
|
+
position: relative;
|
|
31
|
+
display: flex;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
|
|
34
|
+
& > svg {
|
|
35
|
+
height: 570px;
|
|
36
|
+
transform: scale(1.25) translateY(24px);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
${ScreenWidth_1.mediaQuery.mobile} {
|
|
40
|
+
height: 486px;
|
|
41
|
+
|
|
42
|
+
& > svg {
|
|
43
|
+
position: absolute;
|
|
44
|
+
height: 486px;
|
|
45
|
+
transform: scale(1.25) translateY(20px);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
const SContent = styled_components_1.default.div `
|
|
50
|
+
position: absolute;
|
|
51
|
+
left: 50%;
|
|
52
|
+
top: 200px;
|
|
53
|
+
transform: translate(-50%, 0);
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
align-items: center;
|
|
57
|
+
gap: 46px;
|
|
58
|
+
|
|
59
|
+
.textLogin {
|
|
60
|
+
color: #696f90;
|
|
61
|
+
text-align: center;
|
|
62
|
+
font-size: 40px;
|
|
63
|
+
font-weight: 700;
|
|
64
|
+
line-height: 52px;
|
|
65
|
+
max-width: 500px;
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
align-items: center;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
${ScreenWidth_1.mediaQuery.mobile} {
|
|
72
|
+
top: 144px;
|
|
73
|
+
gap: 29px;
|
|
74
|
+
|
|
75
|
+
.textLogin {
|
|
76
|
+
font-size: 28px;
|
|
77
|
+
line-height: 36px;
|
|
78
|
+
max-width: 330px;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
82
|
+
const SignUpProtected = () => {
|
|
83
|
+
return ((0, jsx_runtime_1.jsx)(LWithSearchHeader_1.default, { children: (0, jsx_runtime_1.jsx)(SWrapper, { children: (0, jsx_runtime_1.jsxs)(SContainer, { children: [(0, jsx_runtime_1.jsx)(CircleSvg_1.CircleSvg, {}), (0, jsx_runtime_1.jsxs)(SContent, { children: [(0, jsx_runtime_1.jsxs)("p", { className: "textLogin", children: [(0, jsx_runtime_1.jsx)("span", { children: "Please log in" }), (0, jsx_runtime_1.jsx)("span", { children: "to proceed on this page" })] }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(MainButton_1.default, { onClick: redirectToApp_1.redirectToApp, variant: "primaryM", text: "Go to App" }) })] })] }) }) }));
|
|
84
|
+
};
|
|
85
|
+
// for initialize hoc use template :
|
|
86
|
+
// const Page = (props: any) => {
|
|
87
|
+
// return HOCSignUpInterceptor(<HomeBuildPage {...props} />);
|
|
88
|
+
// };
|
|
89
|
+
// export default Page;
|
|
90
|
+
const HOCSignUpInterceptor = (Component, isAuthorized) => {
|
|
91
|
+
const isSignedIn = (0, store_1.useUserStore)((state) => state.isSignedIn);
|
|
92
|
+
if (typeof isAuthorized !== "undefined") {
|
|
93
|
+
if (!isAuthorized) {
|
|
94
|
+
return (0, jsx_runtime_1.jsx)(SignUpProtected, {});
|
|
95
|
+
}
|
|
96
|
+
return Component;
|
|
97
|
+
}
|
|
98
|
+
if (!isSignedIn) {
|
|
99
|
+
return (0, jsx_runtime_1.jsx)(SignUpProtected, {});
|
|
100
|
+
}
|
|
101
|
+
return Component;
|
|
102
|
+
};
|
|
103
|
+
exports.HOCSignUpInterceptor = HOCSignUpInterceptor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
1
|
import { AppProps } from "next/app";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
3
|
export declare const AppLayout: ({ children, pageProps }: {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
pageProps: AppProps["pageProps"];
|
|
6
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
}) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<import("react").AwaitedReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppLayout = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const styled_components_1 = require("styled-components");
|
|
6
|
-
const ui_1 = require("../store/ui");
|
|
7
|
-
const client_1 = require("@apollo/client");
|
|
8
5
|
const apollo_1 = require("../hooks/apollo");
|
|
9
6
|
const GlobalLayout_1 = require("./GlobalLayout");
|
|
7
|
+
const HOCAuthSearchParamsLocalhostInterceptor_1 = require("../modules/user/auth/HOCAuthSearchParamsLocalhostInterceptor");
|
|
10
8
|
const store_1 = require("../modules/user/store");
|
|
11
9
|
const index_1 = require("../store/index");
|
|
12
|
-
const
|
|
10
|
+
const ui_1 = require("../store/ui");
|
|
11
|
+
const client_1 = require("@apollo/client");
|
|
12
|
+
const styled_components_1 = require("styled-components");
|
|
13
|
+
const AppLayoutProviders = ({ children, pageProps }) => {
|
|
13
14
|
const apolloClient = (0, apollo_1.useApollo)(pageProps);
|
|
14
15
|
const theme = (0, ui_1.useUiStore)((state) => state.theme);
|
|
15
16
|
return ((0, jsx_runtime_1.jsx)(index_1.SSRProvider, { initialState: {
|
|
@@ -19,4 +20,5 @@ const AppLayout = ({ children, pageProps }) => {
|
|
|
19
20
|
isSignedIn: !!pageProps.userData,
|
|
20
21
|
}, children: (0, jsx_runtime_1.jsx)(GlobalLayout_1.GlobalLayout, { children: children }) }) }) }) }));
|
|
21
22
|
};
|
|
23
|
+
const AppLayout = ({ children, pageProps }) => (0, HOCAuthSearchParamsLocalhostInterceptor_1.HOCAuthSearchParamsLocalhostInterceptor)((0, jsx_runtime_1.jsx)(AppLayoutProviders, { pageProps: pageProps, children: children }), pageProps);
|
|
22
24
|
exports.AppLayout = AppLayout;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AppProps } from "next/app";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
export declare const HOCAuthSearchParamsLocalhostInterceptor: (Component: ReactNode, pageProps: AppProps["pageProps"]) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<import("react").AwaitedReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HOCAuthSearchParamsLocalhostInterceptor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const env_1 = require("../../../store/env");
|
|
6
|
+
const api_1 = require("@ludo.ninja/api");
|
|
7
|
+
const router_1 = require("next/router");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const AuthLoginLocalhost = () => {
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
const currentUrl = new URL(window.location.href);
|
|
12
|
+
const userId = currentUrl.searchParams.get("userId");
|
|
13
|
+
const wallets = currentUrl.searchParams.get("wallets");
|
|
14
|
+
const newUser = currentUrl.searchParams.get("newUser");
|
|
15
|
+
const inviteCode = currentUrl.searchParams.get("inviteCode");
|
|
16
|
+
const role = currentUrl.searchParams.get("role");
|
|
17
|
+
const authToken = currentUrl.searchParams.get("authToken");
|
|
18
|
+
const refreshToken = currentUrl.searchParams.get("refreshToken");
|
|
19
|
+
if (userId && wallets && authToken && refreshToken) {
|
|
20
|
+
api_1.authCookies.assignCookies(userId, JSON.parse(wallets), authToken, refreshToken, String(newUser), inviteCode?.toString() || "null", String(role), "localhost");
|
|
21
|
+
const paramsToRemove = ["userId", "wallets", "newUser", "inviteCode", "role", "authToken", "refreshToken"];
|
|
22
|
+
paramsToRemove.forEach((param) => currentUrl.searchParams.delete(param));
|
|
23
|
+
window.location.href = currentUrl.toString();
|
|
24
|
+
}
|
|
25
|
+
}, []);
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
const HOCAuthSearchParamsLocalhostInterceptor = (Component, pageProps) => {
|
|
29
|
+
const router = (0, router_1.useRouter)();
|
|
30
|
+
const NEXT_PUBLIC_ENV_VALUE = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_ENV_VALUE);
|
|
31
|
+
if (!pageProps.userData && router.query?.authToken && NEXT_PUBLIC_ENV_VALUE === "development") {
|
|
32
|
+
return (0, jsx_runtime_1.jsx)(AuthLoginLocalhost, {});
|
|
33
|
+
}
|
|
34
|
+
return Component;
|
|
35
|
+
};
|
|
36
|
+
exports.HOCAuthSearchParamsLocalhostInterceptor = HOCAuthSearchParamsLocalhostInterceptor;
|
|
@@ -5,6 +5,8 @@ const env_1 = require("../../store/env");
|
|
|
5
5
|
const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
|
|
6
6
|
const useRedirectToLoginWindow = () => {
|
|
7
7
|
const NEXT_PUBLIC_ENV_VALUE = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_ENV_VALUE);
|
|
8
|
-
|
|
8
|
+
const isFromLocalhost = NEXT_PUBLIC_ENV_VALUE === "development";
|
|
9
|
+
const domainType = isFromLocalhost ? "stage" : NEXT_PUBLIC_ENV_VALUE;
|
|
10
|
+
return () => window.open(`${ludoDomains_1.ludoDomains[domainType]["auth"]}/login/?fallback_url=${window.location.href.replace(/\s/g, "")}${isFromLocalhost ? "&isFromLocalhost=true" : ""}`, "_self");
|
|
9
11
|
};
|
|
10
12
|
exports.useRedirectToLoginWindow = useRedirectToLoginWindow;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const redirectToApp: () => void;
|
|
@@ -0,0 +1,29 @@
|
|
|
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.redirectToApp = void 0;
|
|
7
|
+
const process_1 = __importDefault(require("process"));
|
|
8
|
+
const api_1 = require("@ludo.ninja/api");
|
|
9
|
+
const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
|
|
10
|
+
const redirectToApp = () => {
|
|
11
|
+
let url;
|
|
12
|
+
const { userId, wallets, newUser,
|
|
13
|
+
// inviteCode,
|
|
14
|
+
authToken, refreshToken, role, } = api_1.authCookies.getCookies();
|
|
15
|
+
if (authToken &&
|
|
16
|
+
refreshToken &&
|
|
17
|
+
userId &&
|
|
18
|
+
wallets &&
|
|
19
|
+
newUser &&
|
|
20
|
+
// inviteCode &&
|
|
21
|
+
role) {
|
|
22
|
+
url = `${ludoDomains_1.ludoDomains[process_1.default.env.NEXT_PUBLIC_ENV_VALUE]['profile']}/${userId}/nfts`;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
url = `${ludoDomains_1.ludoDomains[process_1.default.env.NEXT_PUBLIC_ENV_VALUE]['auth']}/login`;
|
|
26
|
+
}
|
|
27
|
+
window.open(url, '_self');
|
|
28
|
+
};
|
|
29
|
+
exports.redirectToApp = redirectToApp;
|