@solidxai/core-ui 0.1.7-beta.6 → 0.1.7-beta.8
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/dist/adapters/auth/helper.d.ts +9 -0
- package/dist/adapters/auth/helper.d.ts.map +1 -0
- package/dist/adapters/auth/helper.js +37 -0
- package/dist/adapters/auth/helper.js.map +1 -0
- package/dist/adapters/auth/helper.ts +45 -0
- package/dist/adapters/auth/signInWithOtp.d.ts.map +1 -1
- package/dist/adapters/auth/signInWithOtp.js +3 -27
- package/dist/adapters/auth/signInWithOtp.js.map +1 -1
- package/dist/adapters/auth/signInWithOtp.ts +3 -23
- package/dist/components/auth/SolidOTPVerify.d.ts +3 -0
- package/dist/components/auth/SolidOTPVerify.d.ts.map +1 -0
- package/dist/components/auth/SolidOTPVerify.js +67 -0
- package/dist/components/auth/SolidOTPVerify.js.map +1 -0
- package/dist/components/auth/SolidOTPVerify.tsx +133 -0
- package/dist/components/common/AuthBanner.js.map +1 -1
- package/dist/components/core/common/LoadDynamicJsxComponent.d.ts +2 -0
- package/dist/components/core/common/LoadDynamicJsxComponent.d.ts.map +1 -0
- package/dist/components/core/common/LoadDynamicJsxComponent.js +50 -0
- package/dist/components/core/common/LoadDynamicJsxComponent.js.map +1 -0
- package/dist/components/core/common/LoadDynamicJsxComponent.tsx +70 -0
- package/dist/components/core/kanban/SolidManyToOneFilterElement.d.ts.map +1 -1
- package/dist/components/core/kanban/SolidManyToOneFilterElement.js.map +1 -1
- package/dist/components/core/kanban/SolidManyToOneFilterElement.tsx +2 -1
- package/dist/components/core/kanban/kanban-fields/SolidMediaMultipleKanbanField.d.ts.map +1 -1
- package/dist/components/core/kanban/kanban-fields/SolidMediaMultipleKanbanField.js +2 -2
- package/dist/components/core/kanban/kanban-fields/SolidMediaMultipleKanbanField.js.map +1 -1
- package/dist/components/core/kanban/kanban-fields/SolidMediaMultipleKanbanField.tsx +10 -21
- package/dist/components/core/kanban/kanban-fields/SolidMediaSingleKanbanField.d.ts.map +1 -1
- package/dist/components/core/kanban/kanban-fields/SolidMediaSingleKanbanField.js +2 -2
- package/dist/components/core/kanban/kanban-fields/SolidMediaSingleKanbanField.js.map +1 -1
- package/dist/components/core/kanban/kanban-fields/SolidMediaSingleKanbanField.tsx +10 -18
- package/dist/components/core/kanban/kanban-fields/SolidShortTextKanbanField.d.ts.map +1 -1
- package/dist/components/core/kanban/kanban-fields/SolidShortTextKanbanField.js +6 -3
- package/dist/components/core/kanban/kanban-fields/SolidShortTextKanbanField.js.map +1 -1
- package/dist/components/core/kanban/kanban-fields/SolidShortTextKanbanField.tsx +24 -30
- package/dist/components/core/kanban/kanban-fields/relations/SolidRelationManyToOneKanbanField.js.map +1 -1
- package/dist/components/core/kanban/kanban-fields/relations/SolidRelationManyToOneKanbanField.tsx +2 -2
- package/dist/components/core/list/SolidListViewRowButtonContextMenu.d.ts +1 -1
- package/dist/components/core/list/SolidListViewRowButtonContextMenu.d.ts.map +1 -1
- package/dist/components/core/list/SolidListViewRowButtonContextMenu.js +7 -6
- package/dist/components/core/list/SolidListViewRowButtonContextMenu.js.map +1 -1
- package/dist/components/core/list/SolidListViewRowButtonContextMenu.tsx +10 -9
- package/dist/components/core/users/ApiKeysTab/ApiKeysTab.d.ts +7 -0
- package/dist/components/core/users/ApiKeysTab/ApiKeysTab.d.ts.map +1 -0
- package/dist/components/core/users/ApiKeysTab/ApiKeysTab.js +138 -0
- package/dist/components/core/users/ApiKeysTab/ApiKeysTab.js.map +1 -0
- package/dist/components/core/users/ApiKeysTab/ApiKeysTab.tsx +246 -0
- package/dist/components/core/users/ApiKeysTab/GenerateApiKeyModal.d.ts +8 -0
- package/dist/components/core/users/ApiKeysTab/GenerateApiKeyModal.d.ts.map +1 -0
- package/dist/components/core/users/ApiKeysTab/GenerateApiKeyModal.js +156 -0
- package/dist/components/core/users/ApiKeysTab/GenerateApiKeyModal.js.map +1 -0
- package/dist/components/core/users/ApiKeysTab/GenerateApiKeyModal.tsx +184 -0
- package/dist/components/core/users/ApiKeysTab/RevealApiKeyModal.d.ts +9 -0
- package/dist/components/core/users/ApiKeysTab/RevealApiKeyModal.d.ts.map +1 -0
- package/dist/components/core/users/ApiKeysTab/RevealApiKeyModal.js +37 -0
- package/dist/components/core/users/ApiKeysTab/RevealApiKeyModal.js.map +1 -0
- package/dist/components/core/users/ApiKeysTab/RevealApiKeyModal.tsx +111 -0
- package/dist/components/core/users/ApiKeysTab/index.d.ts +4 -0
- package/dist/components/core/users/ApiKeysTab/index.d.ts.map +1 -0
- package/dist/components/core/users/ApiKeysTab/index.js +4 -0
- package/dist/components/core/users/ApiKeysTab/index.js.map +1 -0
- package/dist/components/core/users/ApiKeysTab/index.ts +3 -0
- package/dist/helpers/# no such endpoints exist, need to calle +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/index.ts +1 -0
- package/dist/nextAuth/authProviders.d.ts +4 -0
- package/dist/nextAuth/authProviders.d.ts.map +1 -0
- package/dist/nextAuth/authProviders.js +198 -0
- package/dist/nextAuth/authProviders.js.map +1 -0
- package/dist/nextAuth/authProviders.tsx +232 -0
- package/dist/nextAuth/handleLogout.d.ts +2 -0
- package/dist/nextAuth/handleLogout.d.ts.map +1 -0
- package/dist/nextAuth/handleLogout.js +36 -0
- package/dist/nextAuth/handleLogout.js.map +1 -0
- package/dist/nextAuth/handleLogout.tsx +39 -0
- package/dist/nextAuth/refreshAccessToken.d.ts +2 -0
- package/dist/nextAuth/refreshAccessToken.d.ts.map +1 -0
- package/dist/nextAuth/refreshAccessToken.js +24 -0
- package/dist/nextAuth/refreshAccessToken.js.map +1 -0
- package/dist/nextAuth/refreshAccessToken.tsx +28 -0
- package/dist/redux/api/apiKeyApi.d.ts +40 -0
- package/dist/redux/api/apiKeyApi.d.ts.map +1 -0
- package/dist/redux/api/apiKeyApi.js +36 -0
- package/dist/redux/api/apiKeyApi.js.map +1 -0
- package/dist/redux/api/apiKeyApi.ts +60 -0
- package/dist/redux/features/settingsSlice.d.ts +20 -0
- package/dist/redux/features/settingsSlice.d.ts.map +1 -0
- package/dist/redux/features/settingsSlice.js +39 -0
- package/dist/redux/features/settingsSlice.js.map +1 -0
- package/dist/redux/features/settingsSlice.ts +60 -0
- package/dist/routes/guards/AuthGuard.d.ts +5 -1
- package/dist/routes/guards/AuthGuard.d.ts.map +1 -1
- package/dist/routes/guards/AuthGuard.js +13 -2
- package/dist/routes/guards/AuthGuard.js.map +1 -1
- package/dist/routes/guards/AuthGuard.tsx +27 -3
- package/package.json +1 -1
- package/dist/components/core/list/SolidDataTablePagination.d.ts +0 -15
- package/dist/components/core/list/SolidDataTablePagination.d.ts.map +0 -1
- package/dist/components/core/list/SolidDataTablePagination.js +0 -22
- package/dist/components/core/list/SolidDataTablePagination.js.map +0 -1
- package/dist/components/core/list/SolidDataTablePagination.tsx +0 -71
- package/dist/components/solid-ui/SolidButton.d.ts +0 -14
- package/dist/components/solid-ui/SolidButton.d.ts.map +0 -1
- package/dist/components/solid-ui/SolidButton.js +0 -36
- package/dist/components/solid-ui/SolidButton.js.map +0 -1
- package/dist/components/solid-ui/SolidButton.tsx +0 -54
- package/dist/components/solid-ui/SolidTabs.d.ts +0 -18
- package/dist/components/solid-ui/SolidTabs.d.ts.map +0 -1
- package/dist/components/solid-ui/SolidTabs.js +0 -22
- package/dist/components/solid-ui/SolidTabs.js.map +0 -1
- package/dist/components/solid-ui/SolidTabs.tsx +0 -73
- package/dist/components/solid-ui/index.d.ts +0 -3
- package/dist/components/solid-ui/index.d.ts.map +0 -1
- package/dist/components/solid-ui/index.js +0 -3
- package/dist/components/solid-ui/index.js.map +0 -1
- package/dist/components/solid-ui/index.ts +0 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type AuthResult = {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
error: string | null;
|
|
4
|
+
status: number;
|
|
5
|
+
url: string | null;
|
|
6
|
+
};
|
|
7
|
+
export declare function handleAuthSuccess(accessToken: string, refreshToken: string, user: any, status: any): AuthResult;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/adapters/auth/helper.ts"],"names":[],"mappings":"AAIA,KAAK,UAAU,GAAG;IACd,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,WAAW,EAAC,MAAM,EAAG,YAAY,EAAE,MAAM,EAAG,IAAI,EAAE,GAAG,EAAE,MAAM,EAAC,GAAG,GAAG,UAAU,CAiC/G"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jwtDecode } from "jwt-decode";
|
|
13
|
+
import { saveSession } from "./storage";
|
|
14
|
+
import { eventBus, AppEvents } from "../../helpers/eventBus";
|
|
15
|
+
export function handleAuthSuccess(accessToken, refreshToken, user, status) {
|
|
16
|
+
// const accessToken = response?.data?.data?.accessToken;
|
|
17
|
+
// const refreshToken = response?.data?.data?.refreshToken;
|
|
18
|
+
// const user = response?.data?.data?.user || {};
|
|
19
|
+
if (!accessToken || !refreshToken) {
|
|
20
|
+
return { ok: false, error: "Missing tokens in response", status: status || 500, url: null };
|
|
21
|
+
}
|
|
22
|
+
var decoded = jwtDecode(accessToken);
|
|
23
|
+
var accessTokenExpires = decoded.exp ? decoded.exp * 1000 : undefined;
|
|
24
|
+
var session = {
|
|
25
|
+
user: __assign(__assign({}, user), { accessToken: accessToken, refreshToken: refreshToken, accessTokenExpires: accessTokenExpires }),
|
|
26
|
+
error: null,
|
|
27
|
+
};
|
|
28
|
+
saveSession(session);
|
|
29
|
+
eventBus.emit(AppEvents.SessionUpdated, session);
|
|
30
|
+
return {
|
|
31
|
+
ok: true,
|
|
32
|
+
error: null,
|
|
33
|
+
status: status,
|
|
34
|
+
url: null,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../src/adapters/auth/helper.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAS7D,MAAM,UAAU,iBAAiB,CAAC,WAAkB,EAAG,YAAoB,EAAG,IAAS,EAAE,MAAU;IAE/F,yDAAyD;IACzD,2DAA2D;IAC3D,iDAAiD;IAEjD,IAAI,CAAC,WAAW,IAAI,CAAC,YAAY,EAAE;QAC/B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,4BAA4B,EAAE,MAAM,EAAC,MAAM,IAAI,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;KAC9F;IAED,IAAM,OAAO,GAAG,SAAS,CAAmB,WAAW,CAAC,CAAC;IACzD,IAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAExE,IAAM,OAAO,GAAG;QACZ,IAAI,wBACG,IAAI,KACP,WAAW,aAAA,EACX,YAAY,cAAA,EACZ,kBAAkB,oBAAA,GACrB;QACD,KAAK,EAAE,IAAI;KACd,CAAC;IAEF,WAAW,CAAC,OAAO,CAAC,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEjD,OAAO;QACH,EAAE,EAAE,IAAI;QACR,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,IAAI;KACZ,CAAC;AAEN,CAAC","sourcesContent":["import { jwtDecode } from \"jwt-decode\";\nimport { saveSession } from \"./storage\";\nimport { eventBus, AppEvents } from \"../../helpers/eventBus\";\n\ntype AuthResult = {\n ok: boolean;\n error: string | null;\n status: number;\n url: string | null;\n};\n\nexport function handleAuthSuccess(accessToken:string , refreshToken: string , user: any ,status:any): AuthResult{\n\n // const accessToken = response?.data?.data?.accessToken;\n // const refreshToken = response?.data?.data?.refreshToken;\n // const user = response?.data?.data?.user || {};\n\n if (!accessToken || !refreshToken) {\n return { ok: false, error: \"Missing tokens in response\", status:status || 500, url: null };\n }\n\n const decoded = jwtDecode<{ exp?: number }>(accessToken);\n const accessTokenExpires = decoded.exp ? decoded.exp * 1000 : undefined;\n\n const session = {\n user: {\n ...user,\n accessToken,\n refreshToken,\n accessTokenExpires,\n },\n error: null,\n };\n\n saveSession(session);\n eventBus.emit(AppEvents.SessionUpdated, session);\n\n return {\n ok: true,\n error: null,\n status: status,\n url: null,\n };\n\n}"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jwtDecode } from "jwt-decode";
|
|
2
|
+
import { saveSession } from "./storage";
|
|
3
|
+
import { eventBus, AppEvents } from "../../helpers/eventBus";
|
|
4
|
+
|
|
5
|
+
type AuthResult = {
|
|
6
|
+
ok: boolean;
|
|
7
|
+
error: string | null;
|
|
8
|
+
status: number;
|
|
9
|
+
url: string | null;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function handleAuthSuccess(accessToken:string , refreshToken: string , user: any ,status:any): AuthResult{
|
|
13
|
+
|
|
14
|
+
// const accessToken = response?.data?.data?.accessToken;
|
|
15
|
+
// const refreshToken = response?.data?.data?.refreshToken;
|
|
16
|
+
// const user = response?.data?.data?.user || {};
|
|
17
|
+
|
|
18
|
+
if (!accessToken || !refreshToken) {
|
|
19
|
+
return { ok: false, error: "Missing tokens in response", status:status || 500, url: null };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const decoded = jwtDecode<{ exp?: number }>(accessToken);
|
|
23
|
+
const accessTokenExpires = decoded.exp ? decoded.exp * 1000 : undefined;
|
|
24
|
+
|
|
25
|
+
const session = {
|
|
26
|
+
user: {
|
|
27
|
+
...user,
|
|
28
|
+
accessToken,
|
|
29
|
+
refreshToken,
|
|
30
|
+
accessTokenExpires,
|
|
31
|
+
},
|
|
32
|
+
error: null,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
saveSession(session);
|
|
36
|
+
eventBus.emit(AppEvents.SessionUpdated, session);
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
ok: true,
|
|
40
|
+
error: null,
|
|
41
|
+
status: status,
|
|
42
|
+
url: null,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signInWithOtp.d.ts","sourceRoot":"","sources":["../../../src/adapters/auth/signInWithOtp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signInWithOtp.d.ts","sourceRoot":"","sources":["../../../src/adapters/auth/signInWithOtp.ts"],"names":[],"mappings":"AAIA,KAAK,cAAc,GAAG;IACpB,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CAuC1F"}
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -45,15 +34,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
35
|
}
|
|
47
36
|
};
|
|
48
|
-
import { jwtDecode } from "jwt-decode";
|
|
49
37
|
import { env } from "../env";
|
|
50
|
-
import { saveSession } from "./storage";
|
|
51
|
-
import { eventBus, AppEvents } from "../../helpers/eventBus";
|
|
52
38
|
import { solidPost } from "../..//http/solidHttp";
|
|
39
|
+
import { handleAuthSuccess } from "./helper";
|
|
53
40
|
export function signInWithOtp(options) {
|
|
54
41
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
55
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
-
var type, identifier, otp, apiUrl, response, message, accessToken, refreshToken, user,
|
|
43
|
+
var type, identifier, otp, apiUrl, response, message, accessToken, refreshToken, user, error_1, message;
|
|
57
44
|
return __generator(this, function (_t) {
|
|
58
45
|
switch (_t.label) {
|
|
59
46
|
case 0:
|
|
@@ -84,18 +71,7 @@ export function signInWithOtp(options) {
|
|
|
84
71
|
accessToken = (_g = (_f = response === null || response === void 0 ? void 0 : response.data) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.accessToken;
|
|
85
72
|
refreshToken = (_j = (_h = response === null || response === void 0 ? void 0 : response.data) === null || _h === void 0 ? void 0 : _h.data) === null || _j === void 0 ? void 0 : _j.refreshToken;
|
|
86
73
|
user = ((_l = (_k = response === null || response === void 0 ? void 0 : response.data) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.user) || {};
|
|
87
|
-
|
|
88
|
-
return [2 /*return*/, { ok: false, error: "Missing tokens in response", status: response.status || 500, url: null }];
|
|
89
|
-
}
|
|
90
|
-
decoded = jwtDecode(accessToken);
|
|
91
|
-
accessTokenExpires = decoded.exp ? decoded.exp * 1000 : undefined;
|
|
92
|
-
session = {
|
|
93
|
-
user: __assign(__assign({}, user), { accessToken: accessToken, refreshToken: refreshToken, accessTokenExpires: accessTokenExpires }),
|
|
94
|
-
error: null,
|
|
95
|
-
};
|
|
96
|
-
saveSession(session);
|
|
97
|
-
eventBus.emit(AppEvents.SessionUpdated, session);
|
|
98
|
-
return [2 /*return*/, { ok: true, error: null, status: response.status || 200, url: null }];
|
|
74
|
+
return [2 /*return*/, handleAuthSuccess(accessToken, refreshToken, user, response === null || response === void 0 ? void 0 : response.status)];
|
|
99
75
|
case 3:
|
|
100
76
|
error_1 = _t.sent();
|
|
101
77
|
message = ((_o = (_m = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _m === void 0 ? void 0 : _m.data) === null || _o === void 0 ? void 0 : _o.message) || ((_r = (_q = (_p = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _p === void 0 ? void 0 : _p.data) === null || _q === void 0 ? void 0 : _q.data) === null || _r === void 0 ? void 0 : _r.message) || (error_1 === null || error_1 === void 0 ? void 0 : error_1.message) || "Login failed";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signInWithOtp.js","sourceRoot":"","sources":["../../../src/adapters/auth/signInWithOtp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signInWithOtp.js","sourceRoot":"","sources":["../../../src/adapters/auth/signInWithOtp.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAe7C,MAAM,UAAgB,aAAa,CAAC,OAA6B;;;;;;;oBACvD,IAAI,GAAsB,OAAO,KAA7B,EAAE,UAAU,GAAU,OAAO,WAAjB,EAAE,GAAG,GAAK,OAAO,IAAZ,CAAa;oBACpC,MAAM,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;oBAE9B,IAAI,CAAC,MAAM,EAAE;wBACX,sBAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,2BAA2B,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAC;qBAClF;;;;oBAGkB,qBAAM,SAAS,CAC9B,UAAG,MAAM,+BAA4B,EACrC;4BACE,IAAI,MAAA;4BACJ,UAAU,YAAA;4BACV,GAAG,KAAA;yBACJ,EACD;4BACE,OAAO,EAAE;gCACP,MAAM,EAAE,KAAK;gCACb,cAAc,EAAE,kBAAkB;6BACnC;yBACF,CACF,EAAA;;oBAbK,QAAQ,GAAG,SAahB;oBAED,IAAI,CAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,0CAAE,UAAU,KAAI,CAAA,MAAA,QAAQ,aAA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AE,OAAO,CAAA,IAAI,cAAc,CAAC;oBAC3H,sBAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,CAAA,MAAA,OAAK,aAAL,OAAK,uBAAL,OAAK,CAAE,QAAQ,0CAAE,MAAM,KAAI,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAC;;;;;CAE3F","sourcesContent":["import { env } from \"../env\";\nimport { solidPost } from \"../..//http/solidHttp\";\nimport { handleAuthSuccess } from \"./helper\"; \n\ntype SignInResponse = {\n ok: boolean;\n error: string | null;\n status: number;\n url: string | null;\n};\n\ntype SignInWithOtpOptions = {\n type: string;\n identifier: string;\n otp: string;\n};\n\nexport async function signInWithOtp(options: SignInWithOtpOptions): Promise<SignInResponse> {\n const { type, identifier, otp } = options;\n const apiUrl = env(\"API_URL\");\n\n if (!apiUrl) {\n return { ok: false, error: \"API_URL is not configured\", status: 500, url: null };\n }\n\n try {\n const response = await solidPost(\n `${apiUrl}/api/iam/otp/login/confirm`,\n {\n type,\n identifier,\n otp,\n },\n {\n headers: {\n accept: \"*/*\",\n \"Content-Type\": \"application/json\",\n },\n }\n );\n\n if (response?.data?.statusCode && response?.data?.statusCode !== 200) {\n const message = response?.data?.error || response?.data?.message || \"Invalid OTP\";\n return { ok: false, error: message, status: response?.data?.statusCode || response.status || 400, url: null };\n }\n\n const accessToken = response?.data?.data?.accessToken;\n const refreshToken = response?.data?.data?.refreshToken;\n const user = response?.data?.data?.user || {};\n \n return handleAuthSuccess(accessToken,refreshToken,user,response?.status)\n\n } catch (error: any) {\n const message = error?.response?.data?.message || error?.response?.data?.data?.message || error?.message || \"Login failed\";\n return { ok: false, error: message, status: error?.response?.status || 500, url: null };\n }\n}\n"]}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { jwtDecode } from "jwt-decode";
|
|
2
1
|
import { env } from "../env";
|
|
3
|
-
import { saveSession } from "./storage";
|
|
4
|
-
import { eventBus, AppEvents } from "../../helpers/eventBus";
|
|
5
2
|
import { solidPost } from "../..//http/solidHttp";
|
|
3
|
+
import { handleAuthSuccess } from "./helper";
|
|
6
4
|
|
|
7
5
|
type SignInResponse = {
|
|
8
6
|
ok: boolean;
|
|
@@ -49,27 +47,9 @@ export async function signInWithOtp(options: SignInWithOtpOptions): Promise<Sign
|
|
|
49
47
|
const accessToken = response?.data?.data?.accessToken;
|
|
50
48
|
const refreshToken = response?.data?.data?.refreshToken;
|
|
51
49
|
const user = response?.data?.data?.user || {};
|
|
50
|
+
|
|
51
|
+
return handleAuthSuccess(accessToken,refreshToken,user,response?.status)
|
|
52
52
|
|
|
53
|
-
if (!accessToken || !refreshToken) {
|
|
54
|
-
return { ok: false, error: "Missing tokens in response", status: response.status || 500, url: null };
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const decoded = jwtDecode<{ exp?: number }>(accessToken);
|
|
58
|
-
const accessTokenExpires = decoded.exp ? decoded.exp * 1000 : undefined;
|
|
59
|
-
|
|
60
|
-
const session = {
|
|
61
|
-
user: {
|
|
62
|
-
...user,
|
|
63
|
-
accessToken,
|
|
64
|
-
refreshToken,
|
|
65
|
-
accessTokenExpires,
|
|
66
|
-
},
|
|
67
|
-
error: null,
|
|
68
|
-
};
|
|
69
|
-
saveSession(session);
|
|
70
|
-
eventBus.emit(AppEvents.SessionUpdated, session);
|
|
71
|
-
|
|
72
|
-
return { ok: true, error: null, status: response.status || 200, url: null };
|
|
73
53
|
} catch (error: any) {
|
|
74
54
|
const message = error?.response?.data?.message || error?.response?.data?.data?.message || error?.message || "Login failed";
|
|
75
55
|
return { ok: false, error: message, status: error?.response?.status || 500, url: null };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolidOTPVerify.d.ts","sourceRoot":"./","sources":["components/auth/SolidOTPVerify.tsx"],"names":[],"mappings":"AAiBA,QAAA,MAAM,cAAc,+CAmHnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { Form, Formik } from "formik";
|
|
4
|
+
import { signIn } from "next-auth/react";
|
|
5
|
+
import Link from "next/link";
|
|
6
|
+
import { useRouter } from "next/navigation";
|
|
7
|
+
import { Button } from "primereact/button";
|
|
8
|
+
import { InputOtp } from "primereact/inputotp";
|
|
9
|
+
import { Message } from "primereact/message";
|
|
10
|
+
import { Toast } from "primereact/toast";
|
|
11
|
+
import { useRef, useState } from "react";
|
|
12
|
+
import * as Yup from "yup";
|
|
13
|
+
import { useSelector } from "react-redux";
|
|
14
|
+
import Image from "next/image";
|
|
15
|
+
import SolidLogo from '../../resources/images/SolidXLogo.svg';
|
|
16
|
+
import { ERROR_MESSAGES } from "../../constants/error-messages";
|
|
17
|
+
const SolidOTPVerify = () => {
|
|
18
|
+
// const [trigger, { data: solidSettingsData }] = useLazyGetAuthSettingsQuery();
|
|
19
|
+
// useEffect(() => {
|
|
20
|
+
// trigger("") // Fetch settings on mount
|
|
21
|
+
// }, [trigger])
|
|
22
|
+
const solidSettingsData = useSelector((state) => state.settingsState?.solidSettings);
|
|
23
|
+
const [otp, setOTP] = useState();
|
|
24
|
+
const toast = useRef(null);
|
|
25
|
+
const router = useRouter();
|
|
26
|
+
const [password, setPassword] = useState('');
|
|
27
|
+
const [checked, setChecked] = useState(false);
|
|
28
|
+
const validationSchema = Yup.object({
|
|
29
|
+
email: Yup.string()
|
|
30
|
+
.email(ERROR_MESSAGES.FIELD_INVALID(' email address'))
|
|
31
|
+
.required(ERROR_MESSAGES.FIELD_REUQIRED('Email')),
|
|
32
|
+
});
|
|
33
|
+
const showToast = (severity, summary, detail) => {
|
|
34
|
+
toast.current?.show({
|
|
35
|
+
severity,
|
|
36
|
+
summary,
|
|
37
|
+
detail,
|
|
38
|
+
...(severity === "error"
|
|
39
|
+
? { sticky: true } // stays until user closes
|
|
40
|
+
: { life: 3000 }),
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const isFormFieldValid = (formik, fieldName) => formik.touched[fieldName] && formik.errors[fieldName];
|
|
44
|
+
return (_jsxs(_Fragment, { children: [_jsx(Toast, { ref: toast }), _jsxs("div", { className: `auth-container ${solidSettingsData?.authPagesLayout === 'center' ? 'center' : 'side'}`, style: { minWidth: 480 }, children: [solidSettingsData?.authPagesLayout === 'center' &&
|
|
45
|
+
_jsx("div", { className: "flex justify-content-center", children: _jsx("div", { className: `solid-logo flex align-items-center ${solidSettingsData?.appLogoPosition}`, children: _jsx(Image, { alt: "solid logo", src: solidSettingsData?.appLogo || SolidLogo, className: "relative", fill: true }) }) }), _jsx("h2", { className: `solid-auth-title ${solidSettingsData?.authPagesLayout === 'center' ? 'text-center' : 'text-left'}`, children: "OTP Verification" }), _jsx("p", { className: "solid-auth-subtitle text-sm", children: "Please enter the OTP sent to your email to complete verification" }), _jsx(_Fragment, { children: _jsx(Formik, { initialValues: {
|
|
46
|
+
email: "",
|
|
47
|
+
password: "",
|
|
48
|
+
}, validationSchema: validationSchema, onSubmit: async (values) => {
|
|
49
|
+
// Handle form submission
|
|
50
|
+
const email = values.email;
|
|
51
|
+
const password = values.password;
|
|
52
|
+
const response = await signIn("credentials", {
|
|
53
|
+
redirect: false,
|
|
54
|
+
email,
|
|
55
|
+
password,
|
|
56
|
+
});
|
|
57
|
+
if (response?.error) {
|
|
58
|
+
showToast("error", ERROR_MESSAGES.LOGIN_ERROR, response.error);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
showToast("success", ERROR_MESSAGES.LOGIN_SUCCESS, ERROR_MESSAGES.DASHBOARD_REDIRECTING);
|
|
62
|
+
router.push(`${process.env.NEXT_PUBLIC_LOGIN_REDIRECT_URL}`);
|
|
63
|
+
}
|
|
64
|
+
}, children: (formik) => (_jsxs(Form, { children: [_jsxs("div", { className: "flex flex-column gap-2 px-3", children: [_jsx("label", { htmlFor: "email", className: "solid-auth-input-label", children: "Enter OTP" }), _jsx(InputOtp, { value: otp, onChange: (e) => setOTP(e.value), length: 6, style: { width: '100%' } }), isFormFieldValid(formik, "email") && _jsx(Message, { className: "text-red-500 text-sm", severity: "error", text: formik?.errors?.email?.toString() }), _jsxs("div", { className: "flex align-items-center justify-content-between", children: [_jsx(Button, { type: "button", icon: 'pi pi-refresh', iconPos: "left", link: true, label: "Resend Code", className: "px-0 text-sm font-normal" }), _jsx("p", { className: "m-0 text-sm text-color", children: "Time left: 00:28" })] })] }), _jsx("div", { className: "mt-4", children: _jsx(Button, { type: "submit", className: "w-full font-light auth-submit-button", label: "Verify", disabled: formik.isSubmitting, loading: formik.isSubmitting }) })] })) }) })] }), _jsx("div", { className: "text-center mt-5", children: _jsxs("div", { className: "text-sm text-400 secondary-dark-color", children: ['<', " Back to ", _jsx(Link, { className: "font-bold", href: "/auth/login", children: "Sign In" })] }) })] }));
|
|
65
|
+
};
|
|
66
|
+
export default SolidOTPVerify;
|
|
67
|
+
//# sourceMappingURL=SolidOTPVerify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolidOTPVerify.js","sourceRoot":"./","sources":["components/auth/SolidOTPVerify.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAA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AAG,SAAS,EAAC,wBAAwB,iCAEjC,IACF,IACJ,EACN,cAAK,SAAS,EAAC,MAAM,YACjB,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,sCAAsC,EAAC,KAAK,EAAC,QAAQ,EAAC,QAAQ,EAAE,MAAM,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,YAAY,GAAI,GACnJ,IACH,CACV,GACI,GACV,IACD,EACN,cAAK,SAAS,EAAC,kBAAkB,YAC7B,eAAK,SAAS,EAAC,uCAAuC,aACjD,GAAG,eAAU,KAAC,IAAI,IAAC,SAAS,EAAC,WAAW,EAAC,IAAI,EAAC,aAAa,wBAAe,IACzE,GACJ,IACP,CACN,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["\"use client\";\n\nimport { Form, Formik } from \"formik\";\nimport { signIn } from \"next-auth/react\";\nimport Link from \"next/link\";\nimport { useRouter } from \"next/navigation\";\nimport { Button } from \"primereact/button\";\nimport { InputOtp } from \"primereact/inputotp\";\nimport { Message } from \"primereact/message\";\nimport { Toast } from \"primereact/toast\";\nimport { useRef, useState } from \"react\";\nimport * as Yup from \"yup\";\nimport { useSelector } from \"react-redux\";\nimport Image from \"next/image\";\nimport SolidLogo from '../../resources/images/SolidXLogo.svg'\nimport { ERROR_MESSAGES } from \"../../constants/error-messages\";\n\nconst SolidOTPVerify = () => {\n\n // const [trigger, { data: solidSettingsData }] = useLazyGetAuthSettingsQuery();\n // useEffect(() => {\n // trigger(\"\") // Fetch settings on mount\n // }, [trigger])\n\n const solidSettingsData = useSelector((state: any) => state.settingsState?.solidSettings);\n\n const [otp, setOTP] = useState<number | any>();\n\n const toast = useRef<Toast>(null);\n const router = useRouter();\n\n const [password, setPassword] = useState('');\n const [checked, setChecked] = useState<boolean>(false);\n\n const validationSchema = Yup.object({\n email: Yup.string()\n .email(ERROR_MESSAGES.FIELD_INVALID(' email address'))\n .required(ERROR_MESSAGES.FIELD_REUQIRED('Email')),\n });\n\n const showToast = (severity: \"success\" | \"error\", summary: string, detail: string) => {\n toast.current?.show({\n severity,\n summary,\n detail,\n ...(severity === \"error\"\n ? { sticky: true } // stays until user closes\n : { life: 3000 }),\n });\n };\n\n const isFormFieldValid = (formik: any, fieldName: string) =>\n formik.touched[fieldName] && formik.errors[fieldName];\n\n return (\n <>\n <Toast ref={toast} />\n <div className={`auth-container ${solidSettingsData?.authPagesLayout === 'center' ? 'center' : 'side'}`} style={{ minWidth: 480 }}>\n {solidSettingsData?.authPagesLayout === 'center' &&\n <div className=\"flex justify-content-center\">\n <div className={`solid-logo flex align-items-center ${solidSettingsData?.appLogoPosition}`}>\n <Image\n alt=\"solid logo\"\n src={solidSettingsData?.appLogo || SolidLogo}\n className=\"relative\"\n fill\n />\n </div>\n </div>\n }\n <h2 className={`solid-auth-title ${solidSettingsData?.authPagesLayout === 'center' ? 'text-center' : 'text-left'}`}>OTP Verification</h2>\n <p className=\"solid-auth-subtitle text-sm\">\n Please enter the OTP sent to your email to complete verification\n </p>\n <>\n <Formik\n initialValues={{\n email: \"\",\n password: \"\",\n }}\n validationSchema={validationSchema}\n onSubmit={async (values) => {\n // Handle form submission\n const email = values.email;\n const password = values.password;\n\n const response = await signIn(\"credentials\", {\n redirect: false,\n email,\n password,\n });\n if (response?.error) {\n showToast(\"error\", ERROR_MESSAGES.LOGIN_ERROR, response.error);\n } else {\n showToast(\"success\", ERROR_MESSAGES.LOGIN_SUCCESS, ERROR_MESSAGES.DASHBOARD_REDIRECTING);\n router.push(`${process.env.NEXT_PUBLIC_LOGIN_REDIRECT_URL}`);\n }\n\n }}\n >\n {(formik) => (\n <Form>\n <div className=\"flex flex-column gap-2 px-3\">\n <label htmlFor=\"email\" className=\"solid-auth-input-label\">Enter OTP</label>\n <InputOtp value={otp} onChange={(e) => setOTP(e.value)} length={6} style={{ width: '100%' }} />\n {isFormFieldValid(formik, \"email\") && <Message\n className=\"text-red-500 text-sm\"\n severity=\"error\"\n text={formik?.errors?.email?.toString()}\n />}\n <div className=\"flex align-items-center justify-content-between\">\n <Button type=\"button\" icon='pi pi-refresh' iconPos=\"left\" link label=\"Resend Code\" className=\"px-0 text-sm font-normal\" />\n <p className=\"m-0 text-sm text-color\">\n Time left: 00:28\n </p>\n </div>\n </div>\n <div className=\"mt-4\">\n <Button type=\"submit\" className=\"w-full font-light auth-submit-button\" label=\"Verify\" disabled={formik.isSubmitting} loading={formik.isSubmitting} />\n </div>\n </Form>\n )}\n </Formik>\n </>\n </div>\n <div className=\"text-center mt-5\">\n <div className=\"text-sm text-400 secondary-dark-color\">\n {'<'} Back to <Link className=\"font-bold\" href=\"/auth/login\">Sign In</Link>\n </div>\n </div>\n </>\n );\n};\n\nexport default SolidOTPVerify;"]}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Form, Formik } from "formik";
|
|
4
|
+
import { signIn } from "next-auth/react";
|
|
5
|
+
import Link from "next/link";
|
|
6
|
+
import { useRouter } from "next/navigation";
|
|
7
|
+
import { Button } from "primereact/button";
|
|
8
|
+
import { InputOtp } from "primereact/inputotp";
|
|
9
|
+
import { Message } from "primereact/message";
|
|
10
|
+
import { Toast } from "primereact/toast";
|
|
11
|
+
import { useEffect, useRef, useState } from "react";
|
|
12
|
+
import * as Yup from "yup";
|
|
13
|
+
import Image from "next/image";
|
|
14
|
+
import SolidLogo from '../../resources/images/SolidXLogo.svg'
|
|
15
|
+
import { ERROR_MESSAGES } from "../../constants/error-messages";
|
|
16
|
+
import { useLazyGetAuthSettingsQuery } from "../../redux/api/solidSettingsApi";
|
|
17
|
+
|
|
18
|
+
const SolidOTPVerify = () => {
|
|
19
|
+
|
|
20
|
+
const [trigger, { data: solidSettingsData }] = useLazyGetAuthSettingsQuery();
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
trigger("") // Fetch settings on mount
|
|
23
|
+
}, [trigger])
|
|
24
|
+
|
|
25
|
+
const [otp, setOTP] = useState<number | any>();
|
|
26
|
+
|
|
27
|
+
const toast = useRef<Toast>(null);
|
|
28
|
+
const router = useRouter();
|
|
29
|
+
|
|
30
|
+
const [password, setPassword] = useState('');
|
|
31
|
+
const [checked, setChecked] = useState<boolean>(false);
|
|
32
|
+
|
|
33
|
+
const validationSchema = Yup.object({
|
|
34
|
+
email: Yup.string()
|
|
35
|
+
.email(ERROR_MESSAGES.FIELD_INVALID(' email address'))
|
|
36
|
+
.required(ERROR_MESSAGES.FIELD_REUQIRED('Email')),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const showToast = (severity: "success" | "error", summary: string, detail: string) => {
|
|
40
|
+
toast.current?.show({
|
|
41
|
+
severity,
|
|
42
|
+
summary,
|
|
43
|
+
detail,
|
|
44
|
+
...(severity === "error"
|
|
45
|
+
? { sticky: true } // stays until user closes
|
|
46
|
+
: { life: 3000 }),
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const isFormFieldValid = (formik: any, fieldName: string) =>
|
|
51
|
+
formik.touched[fieldName] && formik.errors[fieldName];
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<>
|
|
55
|
+
<Toast ref={toast} />
|
|
56
|
+
<div className={`auth-container ${solidSettingsData?.data?.authPagesLayout === 'center' ? 'center' : 'side'}`} style={{ minWidth: 480 }}>
|
|
57
|
+
{solidSettingsData?.data?.authPagesLayout === 'center' &&
|
|
58
|
+
<div className="flex justify-content-center">
|
|
59
|
+
<div className={`solid-logo flex align-items-center ${solidSettingsData?.data?.appLogoPosition}`}>
|
|
60
|
+
<Image
|
|
61
|
+
alt="solid logo"
|
|
62
|
+
src={solidSettingsData?.data?.appLogo || SolidLogo}
|
|
63
|
+
className="relative"
|
|
64
|
+
fill
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
}
|
|
69
|
+
<h2 className={`solid-auth-title ${solidSettingsData?.data?.authPagesLayout === 'center' ? 'text-center' : 'text-left'}`}>OTP Verification</h2>
|
|
70
|
+
<p className="solid-auth-subtitle text-sm">
|
|
71
|
+
Please enter the OTP sent to your email to complete verification
|
|
72
|
+
</p>
|
|
73
|
+
<>
|
|
74
|
+
<Formik
|
|
75
|
+
initialValues={{
|
|
76
|
+
email: "",
|
|
77
|
+
password: "",
|
|
78
|
+
}}
|
|
79
|
+
validationSchema={validationSchema}
|
|
80
|
+
onSubmit={async (values) => {
|
|
81
|
+
// Handle form submission
|
|
82
|
+
const email = values.email;
|
|
83
|
+
const password = values.password;
|
|
84
|
+
|
|
85
|
+
const response = await signIn("credentials", {
|
|
86
|
+
redirect: false,
|
|
87
|
+
email,
|
|
88
|
+
password,
|
|
89
|
+
});
|
|
90
|
+
if (response?.error) {
|
|
91
|
+
showToast("error", ERROR_MESSAGES.LOGIN_ERROR, response.error);
|
|
92
|
+
} else {
|
|
93
|
+
showToast("success", ERROR_MESSAGES.LOGIN_SUCCESS, ERROR_MESSAGES.DASHBOARD_REDIRECTING);
|
|
94
|
+
router.push(`${process.env.NEXT_PUBLIC_LOGIN_REDIRECT_URL}`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
{(formik) => (
|
|
100
|
+
<Form>
|
|
101
|
+
<div className="flex flex-column gap-2 px-3">
|
|
102
|
+
<label htmlFor="email" className="solid-auth-input-label">Enter OTP</label>
|
|
103
|
+
<InputOtp value={otp} onChange={(e) => setOTP(e.value)} length={6} style={{ width: '100%' }} />
|
|
104
|
+
{isFormFieldValid(formik, "email") && <Message
|
|
105
|
+
className="text-red-500 text-sm"
|
|
106
|
+
severity="error"
|
|
107
|
+
text={formik?.errors?.email?.toString()}
|
|
108
|
+
/>}
|
|
109
|
+
<div className="flex align-items-center justify-content-between">
|
|
110
|
+
<Button type="button" icon='pi pi-refresh' iconPos="left" link label="Resend Code" className="px-0 text-sm font-normal" />
|
|
111
|
+
<p className="m-0 text-sm text-color">
|
|
112
|
+
Time left: 00:28
|
|
113
|
+
</p>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
<div className="mt-4">
|
|
117
|
+
<Button type="submit" className="w-full font-light auth-submit-button" label="Verify" disabled={formik.isSubmitting} loading={formik.isSubmitting} />
|
|
118
|
+
</div>
|
|
119
|
+
</Form>
|
|
120
|
+
)}
|
|
121
|
+
</Formik>
|
|
122
|
+
</>
|
|
123
|
+
</div>
|
|
124
|
+
<div className="text-center mt-5">
|
|
125
|
+
<div className="text-sm text-400 secondary-dark-color">
|
|
126
|
+
{'<'} Back to <Link className="font-bold" href="/auth/login">Sign In</Link>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
</>
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export default SolidOTPVerify;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthBanner.js","sourceRoot":"","sources":["../../../src/components/common/AuthBanner.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEzC,IAAM,UAAU,GAAG;IACjB,OAAO,CACL,cACE,KAAK,EAAE;YACL,QAAQ,EAAE,UAAU;YACpB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,aAAa;YACrB,UAAU,EAAE,4BAA4B;YACxC,8CAA8C;YAC9C,cAAc,EAAE,OAAO;YACvB,SAAS,EAAE,GAAG,CAAC,6BAA6B,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAClE,EACD,SAAS,EAAC,yBAAyB,YAEnC,cAAK,SAAS,EAAC,UAAU,YACvB,eAAK,SAAS,EAAC,eAAe,aAC5B,cAAK,SAAS,EAAC,iDAAiD,YAC7D,GAAG,CAAC,iBAAiB,CAAC,GACnB,EACN,cAAK,SAAS,EAAC,kCAAkC,YAC9C,GAAG,CAAC,mCAAmC,CAAC,GACrC,EACN,cAAK,SAAS,EAAC,MAAM,GASf,IACF,GACF,GACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"
|
|
1
|
+
{"version":3,"file":"AuthBanner.js","sourceRoot":"","sources":["../../../src/components/common/AuthBanner.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEzC,IAAM,UAAU,GAAG;IACjB,OAAO,CACL,cACE,KAAK,EAAE;YACL,QAAQ,EAAE,UAAU;YACpB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,aAAa;YACrB,UAAU,EAAE,4BAA4B;YACxC,8CAA8C;YAC9C,cAAc,EAAE,OAAO;YACvB,SAAS,EAAE,GAAG,CAAC,6BAA6B,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAClE,EACD,SAAS,EAAC,yBAAyB,YAEnC,cAAK,SAAS,EAAC,UAAU,YACvB,eAAK,SAAS,EAAC,eAAe,aAC5B,cAAK,SAAS,EAAC,iDAAiD,YAC7D,GAAG,CAAC,iBAAiB,CAAC,GACnB,EACN,cAAK,SAAS,EAAC,kCAAkC,YAC9C,GAAG,CAAC,mCAAmC,CAAC,GACrC,EACN,cAAK,SAAS,EAAC,MAAM,GASf,IACF,GACF,GACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadDynamicJsxComponent.d.ts","sourceRoot":"./","sources":["components/core/common/LoadDynamicJsxComponent.tsx"],"names":[],"mappings":"AAeA,eAAO,MAAM,uBAAuB,gBAAiB,GAAG,4CAoDvD,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ERROR_MESSAGES } from "../../../constants/error-messages";
|
|
4
|
+
import dynamic from "next/dynamic";
|
|
5
|
+
import { useState, useEffect } from "react";
|
|
6
|
+
// Fallback component for missing components
|
|
7
|
+
const FallbackComponent = ({ componentName }) => (_jsxs("div", { style: { color: "red" }, children: ["Could not load ", _jsx("strong", { children: componentName })] }));
|
|
8
|
+
export const LoadDynamicJsxComponent = ({ context }) => {
|
|
9
|
+
// const Component = dynamic<Props>(
|
|
10
|
+
// async () => {
|
|
11
|
+
// try {
|
|
12
|
+
// const componentName = context?.rowAction?.action?.customComponent.split('/').pop();
|
|
13
|
+
// const mod = await import();
|
|
14
|
+
// // Return the default export or a named export matching the componentName
|
|
15
|
+
// return mod.default || mod[componentName];
|
|
16
|
+
// } catch (error) {
|
|
17
|
+
// console.error(`Failed to load component "${context?.rowAction?.action?.customComponent}":`, error);
|
|
18
|
+
// // Return a fallback component if the import fails
|
|
19
|
+
// return () => <GenerateModelCodeRowAction context={context} />;
|
|
20
|
+
// }
|
|
21
|
+
// },
|
|
22
|
+
// { ssr: false } // Disable server-side rendering
|
|
23
|
+
// );
|
|
24
|
+
const [Component, setComponent] = useState(null);
|
|
25
|
+
const componentPath = context?.rowAction?.action?.customComponent;
|
|
26
|
+
const componentKey = componentPath?.split("/")?.pop();
|
|
27
|
+
const componentMap = {
|
|
28
|
+
"GenerateModelCodeRowAction": dynamic(() => import("../extension/solid-core/modelMetadata/list/GenerateModelCodeRowAction"), { ssr: false }),
|
|
29
|
+
"GenerateModuleCodeRowAction": dynamic(() => import("../extension/solid-core/moduleMetadata/list/GenerateModuleCodeRowAction"), { ssr: false }),
|
|
30
|
+
};
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!componentKey)
|
|
33
|
+
return;
|
|
34
|
+
if (componentMap[componentKey]) {
|
|
35
|
+
setComponent(() => () => setComponent(() => componentMap[componentKey]));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
import(componentPath)
|
|
39
|
+
.then((mod) => setComponent(() => mod.default || mod))
|
|
40
|
+
.catch((err) => {
|
|
41
|
+
console.error(` ${ERROR_MESSAGES.LOADING_COMPONENT} ${componentPath}:`, err);
|
|
42
|
+
setComponent(() => () => _jsx(FallbackComponent, { componentName: componentKey }));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}, [componentKey]);
|
|
46
|
+
if (!Component)
|
|
47
|
+
return _jsx("p", { children: "Loading..." });
|
|
48
|
+
return _jsx(Component, { context: context });
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=LoadDynamicJsxComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadDynamicJsxComponent.js","sourceRoot":"./","sources":["components/core/common/LoadDynamicJsxComponent.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,4CAA4C;AAC5C,MAAM,iBAAiB,GAAG,CAAC,EAAE,aAAa,EAAO,EAAE,EAAE,CAAC,CAClD,eAAK,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,gCACT,2BAAS,aAAa,GAAU,IAC7C,CACT,CAAC;AAMF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EAAE,OAAO,EAAO,EAAE,EAAE;IAGxD,oCAAoC;IACpC,oBAAoB;IACpB,gBAAgB;IAEhB,kGAAkG;IAClG,0CAA0C;IAC1C,wFAAwF;IACxF,wDAAwD;IACxD,4BAA4B;IAC5B,kHAAkH;IAClH,iEAAiE;IACjE,6EAA6E;IAC7E,YAAY;IACZ,SAAS;IACT,sDAAsD;IACtD,KAAK;IACL,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAM,IAAI,CAAC,CAAC;IACtD,MAAM,aAAa,GAAG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,CAAC;IAClE,MAAM,YAAY,GAAG,aAAa,EAAE,KAAK,CA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nimport dynamic from \"next/dynamic\";\nimport { useState, useEffect } from \"react\";\n// Fallback component for missing components\nconst FallbackComponent = ({ componentName }: any) => (\n <div style={{ color: \"red\" }}>\n Could not load <strong>{componentName}</strong>\n </div>\n);\n\ntype Props = {\n context: any;\n};\n\nexport const LoadDynamicJsxComponent = ({ context }: any) => {\n\n \n // const Component = dynamic<Props>(\n // async () => {\n // try {\n \n // const componentName = context?.rowAction?.action?.customComponent.split('/').pop();\n // const mod = await import();\n // // Return the default export or a named export matching the componentName\n // return mod.default || mod[componentName];\n // } catch (error) {\n // console.error(`Failed to load component \"${context?.rowAction?.action?.customComponent}\":`, error);\n // // Return a fallback component if the import fails\n // return () => <GenerateModelCodeRowAction context={context} />;\n // }\n // },\n // { ssr: false } // Disable server-side rendering\n // );\n const [Component, setComponent] = useState<any>(null);\n const componentPath = context?.rowAction?.action?.customComponent;\n const componentKey = componentPath?.split(\"/\")?.pop();\n\n const componentMap: Record<string, any> = {\n \"GenerateModelCodeRowAction\": dynamic(\n () => import(\"../extension/solid-core/modelMetadata/list/GenerateModelCodeRowAction\"),\n { ssr: false }\n ),\n \"GenerateModuleCodeRowAction\": dynamic(\n () => import(\"../extension/solid-core/moduleMetadata/list/GenerateModuleCodeRowAction\"),\n { ssr: false }\n ),\n };\n\n useEffect(() => {\n if (!componentKey) return;\n\n if (componentMap[componentKey]) {\n setComponent(() => () => setComponent(() => componentMap[componentKey]));\n } else {\n import(componentPath)\n .then((mod) => setComponent(() => mod.default || mod))\n .catch((err) => {\n console.error(` ${ERROR_MESSAGES.LOADING_COMPONENT} ${componentPath}:`, err);\n setComponent(() => () => <FallbackComponent componentName={componentKey} />);\n });\n }\n }, [componentKey]);\n\n if (!Component) return <p>Loading...</p>;\n\n return <Component context={context} />;\n}\n\n\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { ERROR_MESSAGES } from "../../../constants/error-messages";
|
|
3
|
+
import dynamic from "next/dynamic";
|
|
4
|
+
import { useState, useEffect } from "react";
|
|
5
|
+
// Fallback component for missing components
|
|
6
|
+
const FallbackComponent = ({ componentName }: any) => (
|
|
7
|
+
<div style={{ color: "red" }}>
|
|
8
|
+
Could not load <strong>{componentName}</strong>
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
type Props = {
|
|
13
|
+
context: any;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const LoadDynamicJsxComponent = ({ context }: any) => {
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
// const Component = dynamic<Props>(
|
|
20
|
+
// async () => {
|
|
21
|
+
// try {
|
|
22
|
+
|
|
23
|
+
// const componentName = context?.rowAction?.action?.customComponent.split('/').pop();
|
|
24
|
+
// const mod = await import();
|
|
25
|
+
// // Return the default export or a named export matching the componentName
|
|
26
|
+
// return mod.default || mod[componentName];
|
|
27
|
+
// } catch (error) {
|
|
28
|
+
// console.error(`Failed to load component "${context?.rowAction?.action?.customComponent}":`, error);
|
|
29
|
+
// // Return a fallback component if the import fails
|
|
30
|
+
// return () => <GenerateModelCodeRowAction context={context} />;
|
|
31
|
+
// }
|
|
32
|
+
// },
|
|
33
|
+
// { ssr: false } // Disable server-side rendering
|
|
34
|
+
// );
|
|
35
|
+
const [Component, setComponent] = useState<any>(null);
|
|
36
|
+
const componentPath = context?.rowAction?.action?.customComponent;
|
|
37
|
+
const componentKey = componentPath?.split("/")?.pop();
|
|
38
|
+
|
|
39
|
+
const componentMap: Record<string, any> = {
|
|
40
|
+
"GenerateModelCodeRowAction": dynamic(
|
|
41
|
+
() => import("../extension/solid-core/modelMetadata/list/GenerateModelCodeRowAction"),
|
|
42
|
+
{ ssr: false }
|
|
43
|
+
),
|
|
44
|
+
"GenerateModuleCodeRowAction": dynamic(
|
|
45
|
+
() => import("../extension/solid-core/moduleMetadata/list/GenerateModuleCodeRowAction"),
|
|
46
|
+
{ ssr: false }
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (!componentKey) return;
|
|
52
|
+
|
|
53
|
+
if (componentMap[componentKey]) {
|
|
54
|
+
setComponent(() => () => setComponent(() => componentMap[componentKey]));
|
|
55
|
+
} else {
|
|
56
|
+
import(componentPath)
|
|
57
|
+
.then((mod) => setComponent(() => mod.default || mod))
|
|
58
|
+
.catch((err) => {
|
|
59
|
+
console.error(` ${ERROR_MESSAGES.LOADING_COMPONENT} ${componentPath}:`, err);
|
|
60
|
+
setComponent(() => () => <FallbackComponent componentName={componentKey} />);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}, [componentKey]);
|
|
64
|
+
|
|
65
|
+
if (!Component) return <p>Loading...</p>;
|
|
66
|
+
|
|
67
|
+
return <Component context={context} />;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolidManyToOneFilterElement.d.ts","sourceRoot":"","sources":["../../../../src/components/core/kanban/SolidManyToOneFilterElement.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SolidManyToOneFilterElement.d.ts","sourceRoot":"","sources":["../../../../src/components/core/kanban/SolidManyToOneFilterElement.tsx"],"names":[],"mappings":"AAOA,eAAO,MAAM,2BAA2B,kDAAmD,GAAG,4CAmD7F,CAAA"}
|