eleven-solutions-common-website-unique-web 21.0.56 → 22.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/App.d.ts +0 -3
- package/dist/App.js +0 -2
- package/dist/components/admin/Sidebar.d.ts +0 -1
- package/dist/components/admin/Sidebar.js +2 -2
- package/dist/components/admin/UserForm.js +6 -5
- package/dist/components/admin/Users.js +4 -3
- package/dist/components/footer/Footer.d.ts +3 -2
- package/dist/components/footer/Footer.js +2 -3
- package/dist/components/index.d.ts +3 -2
- package/dist/components/index.js +3 -2
- package/dist/components/login/GoogleButton.js +4 -1
- package/dist/components/login/Header.d.ts +3 -1
- package/dist/components/login/Header.js +135 -31
- package/dist/components/login/Login.d.ts +2 -1
- package/dist/components/login/Login.js +15 -65
- package/dist/components/login/Setcookie.d.ts +2 -0
- package/dist/components/login/Setcookie.js +7 -0
- package/dist/components/redux/slices/types/types.d.ts +3 -0
- package/dist/components/redux/slices/types/types.js +1 -0
- package/dist/components/redux/slices/userSlice.d.ts +20 -0
- package/dist/components/redux/slices/userSlice.js +90 -0
- package/dist/components/useraccount/UpdateUserDetails.d.ts +1 -0
- package/dist/components/useraccount/UpdateUserDetails.js +15 -22
- package/package.json +9 -4
- package/.github/workflows/main.yml +0 -22
- package/azure-pipelines.yml +0 -20
- package/dist/components/Navbar.d.ts +0 -6
- package/dist/components/Navbar.js +0 -5
- package/dist/components/login/View.d.ts +0 -2
- package/dist/components/login/View.js +0 -10
- package/dist/components/useraccount/AddMissingDetails.d.ts +0 -9
- package/dist/components/useraccount/AddMissingDetails.js +0 -56
- package/dist/components/useraccount/AddUserDetails.d.ts +0 -9
- package/dist/components/useraccount/AddUserDetails.js +0 -21
- package/src/App.tsx +0 -21
- package/src/components/Navbar.tsx +0 -21
- package/src/components/admin/Dashboard.tsx +0 -7
- package/src/components/admin/Editor.tsx +0 -25
- package/src/components/admin/Sidebar.tsx +0 -102
- package/src/components/admin/Taxionomies.tsx +0 -314
- package/src/components/admin/TaxonomyForm.tsx +0 -744
- package/src/components/admin/Template.tsx +0 -304
- package/src/components/admin/TemplateForm.tsx +0 -141
- package/src/components/admin/UserForm.tsx +0 -231
- package/src/components/admin/Users.tsx +0 -479
- package/src/components/api/api.ts +0 -59
- package/src/components/api/taxonomy.ts +0 -201
- package/src/components/api/template.ts +0 -114
- package/src/components/api/updateuser.ts +0 -53
- package/src/components/api/user.ts +0 -133
- package/src/components/footer/Footer.tsx +0 -128
- package/src/components/footer/Privacy.tsx +0 -82
- package/src/components/footer/Terms.tsx +0 -156
- package/src/components/index.ts +0 -19
- package/src/components/login/GoogleButton.tsx +0 -85
- package/src/components/login/Header.tsx +0 -340
- package/src/components/login/Login.tsx +0 -277
- package/src/components/useraccount/AddUserDetails.tsx +0 -136
- package/src/components/useraccount/UpdateUserDetails.tsx +0 -214
- package/src/index.ts +0 -1
- package/tsconfig.json +0 -15
@@ -1,18 +1,12 @@
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
-
});
|
9
|
-
};
|
10
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
11
2
|
import { useState } from "react";
|
12
|
-
import
|
13
|
-
import Cookies from "universal-cookie";
|
3
|
+
// import Cookies from "universal-cookie";
|
14
4
|
import GoogleButton from "./GoogleButton";
|
15
|
-
|
5
|
+
import { loginUser, registerUser } from "../redux/slices/userSlice";
|
6
|
+
// import { Dispatch } from "@reduxjs/toolkit";
|
7
|
+
import { useDispatch } from "react-redux";
|
8
|
+
// import { AppDispatch } from "../redux/slices/types/types";
|
9
|
+
const Login = ({ ModalOpen, closeModal, url, isDarkMode, img }) => {
|
16
10
|
const [isLoginMode, setIsLoginMode] = useState(true);
|
17
11
|
const [email, setEmail] = useState("");
|
18
12
|
const [password, setPassword] = useState("");
|
@@ -23,62 +17,18 @@ const Login = ({ ModalOpen, closeModal, url, isDarkMode }) => {
|
|
23
17
|
const [loading] = useState(false);
|
24
18
|
const [error, setError] = useState(null);
|
25
19
|
const [successMessage, setSuccessMessage] = useState(null);
|
26
|
-
const cookies = new Cookies();
|
20
|
+
// const cookies = new Cookies();
|
27
21
|
const toggleMode = () => setIsLoginMode(!isLoginMode);
|
28
|
-
const
|
29
|
-
|
22
|
+
const dispatch = useDispatch(); // Typing the dispatch with AppDispatch
|
23
|
+
const handleLogin = (e) => {
|
30
24
|
e.preventDefault();
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
console.log("please try again after some time");
|
35
|
-
}
|
36
|
-
else {
|
37
|
-
if ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.token) {
|
38
|
-
cookies.set("authToken", response.data.token, { maxAge: 86400 });
|
39
|
-
window.location.href = "/home";
|
40
|
-
}
|
41
|
-
}
|
42
|
-
console.log(response.data.token);
|
43
|
-
}
|
44
|
-
catch (err) {
|
45
|
-
console.error("Error during login:", err);
|
46
|
-
setError("Error during login");
|
47
|
-
}
|
48
|
-
});
|
49
|
-
const handleRegister = (e) => __awaiter(void 0, void 0, void 0, function* () {
|
25
|
+
dispatch(loginUser(url, email, password));
|
26
|
+
};
|
27
|
+
const handleRegister = (e) => {
|
50
28
|
e.preventDefault();
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}
|
55
|
-
if (!termsAccepted) {
|
56
|
-
setError("You must accept the terms and conditions.");
|
57
|
-
return;
|
58
|
-
}
|
59
|
-
const emailRegex = /^[a-zA-Z0-9._%+-]+@gmail\.com$/;
|
60
|
-
if (!emailRegex.test(email)) {
|
61
|
-
setError("Email must be a valid @gmail.com address.");
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
try {
|
65
|
-
const response = yield registerApi(url, name, email, mobile, confirmPassword);
|
66
|
-
console.log("res", response);
|
67
|
-
if (response) {
|
68
|
-
cookies.set("authToken", response, { maxAge: 86400 });
|
69
|
-
window.location.href = "/home";
|
70
|
-
setSuccessMessage("Registration successful!");
|
71
|
-
}
|
72
|
-
else {
|
73
|
-
setError("Registration failed. Please try again.");
|
74
|
-
}
|
75
|
-
}
|
76
|
-
catch (error) {
|
77
|
-
console.error("Error during registration:");
|
78
|
-
setError("An error occurred during registration.");
|
79
|
-
}
|
80
|
-
});
|
81
|
-
return (_jsx("div", { className: `${isDarkMode ? "bg-[#2e2e2e] text-[#ffff]" : "bg-[#ffff] text-black"}`, children: ModalOpen && (_jsx("div", { className: "fixed inset-0 flex items-center justify-center z-50 bg-black bg-opacity-50 transition-opacity duration-75 ease-in-out ", children: _jsxs("div", { className: `relative ${isDarkMode ? "bg-[#2e2e2e]" : "bg-white"} p-4 sm:p-6 lg:p-8 rounded-lg max-w-sm sm:max-w-md w-full shadow-lg transform transition-all duration-500 ease-in-out `, children: [_jsx("button", { onClick: closeModal, className: ` absolute top-1 right-3 text-3xl ${isDarkMode ? " text-[#ffff]" : " text-black"}`, children: "\u00D7" }), _jsx("img", { className: "h-16 w-20 mx-auto animate-fadeIn", src: "images/BarelviLogo.png", alt: "Logo" }), _jsx("h1", { className: `mt-3 text-xl sm:text-2xl font-semibold capitalize text-center ${isDarkMode ? "text-[#ffff]" : "text-black"}`, children: isLoginMode ? "Sign In" : "Sign Up" }), _jsxs("form", { onSubmit: isLoginMode ? handleLogin : handleRegister, children: [!isLoginMode && (_jsxs(_Fragment, { children: [_jsx("div", { className: "relative flex items-center mt-4", children: _jsx("input", { type: "text", value: name, onChange: (e) => setName(e.target.value), className: "block w-full py-2 text-gray-700 bg-white border rounded-lg px-3 sm:px-6 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40", placeholder: "Full Name", required: true }) }), _jsx("div", { className: "relative flex items-center mt-4", children: _jsx("input", { type: "tel", value: mobile, onChange: (e) => setMobile(e.target.value), className: "block w-full py-2 text-gray-700 bg-white border rounded-lg px-3 sm:px-6 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40", placeholder: "Mobile Number", required: true }) }), _jsx("div", { className: "relative flex items-center mt-4", children: _jsx("input", { type: "email", value: email, onChange: (e) => setEmail(e.target.value), className: "block w-full py-2 text-gray-700 bg-white border rounded-lg px-3 sm:px-6 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40", placeholder: "Email address", required: true }) }), _jsx("div", { className: "relative flex items-center mt-4", children: _jsx("input", { type: "password", value: password, onChange: (e) => setPassword(e.target.value), className: "block w-full px-3 sm:px-6 py-2 text-gray-700 bg-white border rounded-lg dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40", placeholder: "Password", required: true }) }), _jsx("div", { className: "relative flex items-center mt-4", children: _jsx("input", { type: "password", value: confirmPassword, onChange: (e) => setConfirmPassword(e.target.value), className: "block w-full py-2 text-gray-700 bg-white border rounded-lg px-3 sm:px-6 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40", placeholder: "Confirm Password", required: true }) }), _jsx("div", { className: "mt-4", children: _jsxs("label", { className: "flex items-center", children: [_jsx("input", { type: "checkbox", checked: termsAccepted, onChange: () => setTermsAccepted(!termsAccepted), className: "form-checkbox cursor-pointer" }), _jsxs("span", { className: "ml-2 text-sm text-gray-600 dark:text-gray-300", children: ["I accept the", " ", _jsx("button", { className: "text-blue-500 hover:underline", children: "terms and conditions" })] })] }) })] })), isLoginMode && (_jsxs(_Fragment, { children: [_jsx("div", { className: "relative flex items-center mt-4", children: _jsx("input", { type: "email", value: email, onChange: (e) => setEmail(e.target.value), className: "block w-full py-2 text-gray-700 bg-white border rounded-lg px-3 sm:px-6 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40", placeholder: "Email address", required: true }) }), _jsx("div", { className: "relative flex items-center mt-4", children: _jsx("input", { type: "password", value: password, onChange: (e) => setPassword(e.target.value), className: "block w-full px-3 sm:px-6 py-2 text-gray-700 bg-white border rounded-lg dark:bg-gray-900 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40", placeholder: "Password", required: true }) })] })), _jsx("div", { className: "mt-6", children: _jsx("button", { type: "submit", disabled: loading, className: "w-full px-6 py-2 text-sm font-medium tracking-wide text-white capitalize transition-colors duration-300 transform bg-blue-500 rounded-lg hover:bg-blue-400 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-50", children: loading
|
29
|
+
dispatch(registerUser(url, name, email, mobile, confirmPassword));
|
30
|
+
};
|
31
|
+
return (_jsx("div", { className: `${isDarkMode ? "bg-[#2e2e2e] text-[#ffff]" : "bg-[#ffff] text-black"}`, children: ModalOpen && (_jsx("div", { className: "fixed inset-0 flex items-center justify-center z-50 bg-black bg-opacity-50 transition-opacity duration-75 ease-in-out ", children: _jsxs("div", { className: `relative ${isDarkMode ? "bg-[#2e2e2e]" : "bg-white"} p-4 sm:p-6 lg:p-8 rounded-lg max-w-sm sm:max-w-md w-full shadow-lg transform transition-all duration-500 ease-in-out `, children: [_jsx("button", { onClick: closeModal, className: ` absolute top-1 right-3 text-3xl ${isDarkMode ? " text-[#ffff]" : " text-black"}`, children: "\u00D7" }), _jsx("img", { className: "h-20 w-20 mx-auto animate-fadeIn", src: img, alt: "Logo" }), _jsx("h1", { className: `mt-3 text-xl sm:text-2xl font-semibold capitalize text-center ${isDarkMode ? "text-[#ffff]" : "text-black"}`, children: isLoginMode ? "Sign In" : "Sign Up" }), _jsxs("form", { onSubmit: isLoginMode ? handleLogin : handleRegister, children: [!isLoginMode && (_jsxs(_Fragment, { children: [_jsx("div", { className: "relative flex items-center mt-4", children: _jsx("input", { type: "text", value: name, onChange: (e) => setName(e.target.value), className: "block w-full py-2 text-gray-700 bg-white border rounded-lg px-3 sm:px-6 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40", placeholder: "Full Name", required: true }) }), _jsx("div", { className: "relative flex items-center mt-4", children: _jsx("input", { type: "tel", value: mobile, onChange: (e) => setMobile(e.target.value), className: "block w-full py-2 text-gray-700 bg-white border rounded-lg px-3 sm:px-6 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40", placeholder: "Mobile Number", required: true }) }), _jsx("div", { className: "relative flex items-center mt-4", children: _jsx("input", { type: "email", value: email, onChange: (e) => setEmail(e.target.value), className: "block w-full py-2 text-gray-700 bg-white border rounded-lg px-3 sm:px-6 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40", placeholder: "Email address", required: true }) }), _jsx("div", { className: "relative flex items-center mt-4", children: _jsx("input", { type: "password", value: password, onChange: (e) => setPassword(e.target.value), className: "block w-full px-3 sm:px-6 py-2 text-gray-700 bg-white border rounded-lg dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40", placeholder: "Password", required: true }) }), _jsx("div", { className: "relative flex items-center mt-4", children: _jsx("input", { type: "password", value: confirmPassword, onChange: (e) => setConfirmPassword(e.target.value), className: "block w-full py-2 text-gray-700 bg-white border rounded-lg px-3 sm:px-6 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40", placeholder: "Confirm Password", required: true }) }), _jsx("div", { className: "mt-4", children: _jsxs("label", { className: "flex items-center", children: [_jsx("input", { type: "checkbox", checked: termsAccepted, onChange: () => setTermsAccepted(!termsAccepted), className: "form-checkbox cursor-pointer" }), _jsxs("span", { className: "ml-2 text-sm text-gray-600 dark:text-gray-300", children: ["I accept the", " ", _jsx("button", { className: "text-blue-500 hover:underline", children: "terms and conditions" })] })] }) })] })), isLoginMode && (_jsxs(_Fragment, { children: [_jsx("div", { className: "relative flex items-center mt-4", children: _jsx("input", { type: "email", value: email, onChange: (e) => setEmail(e.target.value), className: "block w-full py-2 text-gray-700 bg-white border rounded-lg px-3 sm:px-6 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40", placeholder: "Email address", required: true }) }), _jsx("div", { className: "relative flex items-center mt-4", children: _jsx("input", { type: "password", value: password, onChange: (e) => setPassword(e.target.value), className: "block w-full px-3 sm:px-6 py-2 text-gray-700 bg-white border rounded-lg dark:bg-gray-900 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40", placeholder: "Password", required: true }) })] })), _jsx("div", { className: "mt-6", children: _jsx("button", { type: "submit", disabled: loading, className: "w-full px-6 py-2 text-sm font-medium tracking-wide text-white capitalize transition-colors duration-300 transform bg-blue-500 rounded-lg hover:bg-blue-400 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-50", children: loading
|
82
32
|
? isLoginMode
|
83
33
|
? "Logging in..."
|
84
34
|
: "Registering..."
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { AppDispatch } from "./types/types";
|
2
|
+
interface ProfileData {
|
3
|
+
id: string;
|
4
|
+
name: string | null;
|
5
|
+
mobile: string | null;
|
6
|
+
email: string;
|
7
|
+
address: string | null;
|
8
|
+
roleType: number;
|
9
|
+
}
|
10
|
+
interface UserState {
|
11
|
+
profileData: ProfileData | null;
|
12
|
+
successMessage: string | null;
|
13
|
+
errorMessage: string | null;
|
14
|
+
isLoading: boolean;
|
15
|
+
}
|
16
|
+
export declare const setProfileData: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<ProfileData, "user/setProfileData">, clearProfileData: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"user/clearProfileData">, setErrorMessage: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string, "user/setErrorMessage">, setSuccessMessage: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string, "user/setSuccessMessage">, setLoading: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<boolean, "user/setLoading">;
|
17
|
+
export declare const loginUser: (url: string, email: string, password: string) => (dispatch: AppDispatch) => Promise<void>;
|
18
|
+
export declare const registerUser: (url: string, name: string, email: string, mobile: string, confirmPassword: string) => (dispatch: AppDispatch) => Promise<void>;
|
19
|
+
declare const _default: import("redux").Reducer<UserState>;
|
20
|
+
export default _default;
|
@@ -0,0 +1,90 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
// commonRepo/features/user/userSlice.ts
|
11
|
+
import { createSlice } from "@reduxjs/toolkit";
|
12
|
+
import Cookies from "universal-cookie";
|
13
|
+
import { loginApi, registerApi } from "../../api/api";
|
14
|
+
import setCookie from "../../login/Setcookie";
|
15
|
+
const cookies = new Cookies();
|
16
|
+
const initialState = {
|
17
|
+
profileData: null,
|
18
|
+
successMessage: null,
|
19
|
+
errorMessage: null,
|
20
|
+
isLoading: false,
|
21
|
+
};
|
22
|
+
const userSlice = createSlice({
|
23
|
+
name: "user",
|
24
|
+
initialState,
|
25
|
+
reducers: {
|
26
|
+
setProfileData: (state, action) => {
|
27
|
+
state.profileData = action.payload;
|
28
|
+
},
|
29
|
+
clearProfileData: (state) => {
|
30
|
+
state.profileData = null;
|
31
|
+
state.successMessage = "Logged out successfully!";
|
32
|
+
cookies.remove("authToken", { path: "/" });
|
33
|
+
window.location.href = "/home";
|
34
|
+
},
|
35
|
+
setErrorMessage: (state, action) => {
|
36
|
+
state.errorMessage = action.payload;
|
37
|
+
},
|
38
|
+
setSuccessMessage: (state, action) => {
|
39
|
+
state.successMessage = action.payload;
|
40
|
+
},
|
41
|
+
setLoading: (state, action) => {
|
42
|
+
state.isLoading = action.payload;
|
43
|
+
},
|
44
|
+
},
|
45
|
+
});
|
46
|
+
export const { setProfileData, clearProfileData, setErrorMessage, setSuccessMessage, setLoading, } = userSlice.actions;
|
47
|
+
export const loginUser = (url, email, password) => (dispatch) => __awaiter(void 0, void 0, void 0, function* () {
|
48
|
+
var _a;
|
49
|
+
dispatch(setLoading(true));
|
50
|
+
try {
|
51
|
+
const response = yield loginApi(url, email, password);
|
52
|
+
if ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.token) {
|
53
|
+
// cookies.set("authToken", response.data.token, { maxAge: 86400 });
|
54
|
+
setCookie(response.data.token);
|
55
|
+
console.log(response);
|
56
|
+
dispatch(setProfileData(Object.assign(Object.assign({}, response.data), { token: response.data.token })));
|
57
|
+
dispatch(setSuccessMessage("Login successful!"));
|
58
|
+
window.location.href = "/home";
|
59
|
+
}
|
60
|
+
else {
|
61
|
+
dispatch(setErrorMessage("Login failed. Please try again."));
|
62
|
+
}
|
63
|
+
}
|
64
|
+
catch (error) {
|
65
|
+
console.error("Error during login:", error);
|
66
|
+
dispatch(setErrorMessage("An error occurred during login."));
|
67
|
+
}
|
68
|
+
dispatch(setLoading(false));
|
69
|
+
});
|
70
|
+
export const registerUser = (url, name, email, mobile, confirmPassword) => (dispatch) => __awaiter(void 0, void 0, void 0, function* () {
|
71
|
+
dispatch(setLoading(true));
|
72
|
+
try {
|
73
|
+
const response = yield registerApi(url, name, email, mobile, confirmPassword);
|
74
|
+
if (response) {
|
75
|
+
// cookies.set("authToken", response, { maxAge: 86400 });
|
76
|
+
setCookie(response.data.token);
|
77
|
+
dispatch(setSuccessMessage("Registration successful!"));
|
78
|
+
// window.location.href = "/home";
|
79
|
+
}
|
80
|
+
else {
|
81
|
+
dispatch(setErrorMessage("Registration failed. Please try again."));
|
82
|
+
}
|
83
|
+
}
|
84
|
+
catch (error) {
|
85
|
+
console.error("Error during registration:", error);
|
86
|
+
dispatch(setErrorMessage("An error occurred during registration."));
|
87
|
+
}
|
88
|
+
dispatch(setLoading(false));
|
89
|
+
});
|
90
|
+
export default userSlice.reducer;
|
@@ -9,35 +9,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
};
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
11
11
|
import { useState, useEffect } from "react";
|
12
|
-
import { updateProfileApi
|
12
|
+
import { updateProfileApi } from "../api/updateuser";
|
13
13
|
import Cookies from "universal-cookie";
|
14
|
-
const UpdateUserDetails = ({ usermodalopen, closeusermodal, url, isDarkMode, }) => {
|
14
|
+
const UpdateUserDetails = ({ usermodalopen, closeusermodal, url, isDarkMode, userdetails, }) => {
|
15
15
|
var _a;
|
16
16
|
const [name, setName] = useState("");
|
17
17
|
const [mobile, setMobile] = useState("");
|
18
18
|
const [address, setAddress] = useState("");
|
19
|
-
const [user, setUser] = useState(
|
19
|
+
const [user, setUser] = useState(null);
|
20
20
|
const cookies = new Cookies();
|
21
21
|
const token = cookies.get("authToken");
|
22
22
|
const userToken = ((_a = token === null || token === void 0 ? void 0 : token.data) === null || _a === void 0 ? void 0 : _a.token) || token;
|
23
|
+
// const dispatch = useDispatch();
|
24
|
+
// console.log("in update", JSON.stringify(userdetails, null, 2));
|
23
25
|
useEffect(() => {
|
24
|
-
const fetchUserProfile = () =>
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
setAddress(userProfile.address);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
catch (error) {
|
36
|
-
console.error("Error fetching user profile:", error);
|
37
|
-
}
|
38
|
-
}
|
39
|
-
});
|
40
|
-
fetchUserProfile();
|
26
|
+
// const fetchUserProfile = async () => {
|
27
|
+
// try {
|
28
|
+
// const userProfile = await getProfileApi(userToken, url);
|
29
|
+
if (userdetails) {
|
30
|
+
setName(userdetails.name || "");
|
31
|
+
setMobile(userdetails.mobile || "");
|
32
|
+
setAddress(userdetails.address || "");
|
33
|
+
}
|
41
34
|
}, [usermodalopen, userToken, user]);
|
42
35
|
const validateForm = () => {
|
43
36
|
if (!name || !mobile || !address) {
|
@@ -80,11 +73,11 @@ const UpdateUserDetails = ({ usermodalopen, closeusermodal, url, isDarkMode, })
|
|
80
73
|
};
|
81
74
|
if (!usermodalopen)
|
82
75
|
return null;
|
83
|
-
return (_jsx("div", { className: `fixed inset-0 flex items-center justify-center ${isDarkMode ? "bg-gray-800 bg-opacity-90" : "bg-gray-500 bg-opacity-75"}`, children: _jsxs("div", { className: `rounded-lg p-6 w-full max-w-md relative ${isDarkMode
|
76
|
+
return (_jsx("div", { onClick: closeusermodal, className: `fixed z-50 inset-0 flex items-center justify-center ${isDarkMode ? "bg-gray-800 bg-opacity-90" : "bg-gray-500 bg-opacity-75"}`, children: _jsxs("div", { onClick: (e) => e.stopPropagation(), className: `rounded-lg p-6 w-full max-w-md relative ${isDarkMode
|
84
77
|
? "border border-gray-300 bg-[#242424] text-white"
|
85
78
|
: "bg-white text-black"}`, children: [_jsx("button", { onClick: closeusermodal, className: `absolute top-3 right-3 ${isDarkMode
|
86
79
|
? "text-gray-300 hover:text-gray-500"
|
87
|
-
: "text-gray-400 hover:text-gray-600"} text-
|
80
|
+
: "text-gray-400 hover:text-gray-600"} text-3xl`, children: "\u00D7" }), _jsx("h3", { className: "text-center text-xl font-bold mb-4", children: "Update User Details" }), _jsxs("div", { className: "mb-4", children: [_jsx("label", { className: `block text-sm font-medium mb-1 ${isDarkMode ? "text-gray-300" : "text-gray-700"}`, children: "Name" }), _jsx("input", { type: "text", placeholder: "Name", value: name, onChange: handleNameChange, className: `w-full p-2 border rounded focus:outline-none focus:ring ${isDarkMode
|
88
81
|
? "bg-gray-800 border-gray-700 text-white "
|
89
82
|
: "border-gray-300 "}` })] }), _jsxs("div", { className: "mb-4", children: [_jsx("label", { className: `block text-sm font-medium mb-1 ${isDarkMode ? "text-gray-300" : "text-gray-700"}`, children: "Mobile" }), _jsx("input", { type: "tel", placeholder: "Mobile", value: mobile, onChange: handleMobileChange, className: `w-full p-2 border rounded focus:outline-none focus:ring ${isDarkMode
|
90
83
|
? "bg-gray-800 border-gray-700 text-white "
|
package/package.json
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "eleven-solutions-common-website-unique-web",
|
3
|
-
"version": "
|
3
|
+
"version": "22.0.1",
|
4
4
|
"main": "./dist/index.js",
|
5
|
+
"files": [
|
6
|
+
"dist"
|
7
|
+
],
|
5
8
|
"scripts": {
|
6
9
|
"build": "tsc",
|
7
10
|
"test": "echo \"Error: no test specified\" && exit 1"
|
@@ -10,8 +13,8 @@
|
|
10
13
|
"license": "ISC",
|
11
14
|
"description": "",
|
12
15
|
"peerDependencies": {
|
13
|
-
"react": "
|
14
|
-
"react-dom": "
|
16
|
+
"react": ">=18.3.1 <20",
|
17
|
+
"react-dom": ">=18.3.1 <20"
|
15
18
|
},
|
16
19
|
"devDependencies": {
|
17
20
|
"@types/axios": "^0.9.36",
|
@@ -21,10 +24,12 @@
|
|
21
24
|
},
|
22
25
|
"dependencies": {
|
23
26
|
"@react-oauth/google": "^0.12.1",
|
27
|
+
"@reduxjs/toolkit": "^2.3.0",
|
24
28
|
"@tabler/icons-react": "^3.21.0",
|
25
|
-
"eleven-solutions-common-website-unique-web": "^12.0.2",
|
26
29
|
"jodit-react": "^4.1.2",
|
30
|
+
"react-hot-toast": "^2.5.1",
|
27
31
|
"react-icons": "^5.3.0",
|
32
|
+
"react-redux": "^9.1.2",
|
28
33
|
"react-router-dom": "^6.27.0",
|
29
34
|
"universal-cookie": "^7.2.2"
|
30
35
|
}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
name: Node.js Package
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches:
|
6
|
-
- main
|
7
|
-
|
8
|
-
jobs:
|
9
|
-
publish-gpr:
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
steps:
|
12
|
-
- uses: actions/checkout@v2
|
13
|
-
- uses: actions/setup-node@v3
|
14
|
-
with:
|
15
|
-
node-version: '14' # Consider using a newer version than 12
|
16
|
-
registry-url: 'https://npm.pkg.github.com'
|
17
|
-
scope: '@11SolutionsPvtLtd'
|
18
|
-
- run: npm install
|
19
|
-
- run: npm run build # Run build if needed before publish
|
20
|
-
- run: npm publish
|
21
|
-
env:
|
22
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
package/azure-pipelines.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# Node.js with React
|
2
|
-
# Build a Node.js project that uses React.
|
3
|
-
# Add steps that analyze code, save build artifacts, deploy, and more:
|
4
|
-
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
|
5
|
-
|
6
|
-
trigger:
|
7
|
-
- main
|
8
|
-
|
9
|
-
pool: Azure Pipelines
|
10
|
-
|
11
|
-
steps:
|
12
|
-
- task: NodeTool@0
|
13
|
-
inputs:
|
14
|
-
versionSpec: '20.x'
|
15
|
-
displayName: 'Install Node.js'
|
16
|
-
|
17
|
-
- script: |
|
18
|
-
npm install
|
19
|
-
npm run build
|
20
|
-
displayName: 'npm install and build'
|
@@ -1,5 +0,0 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
const Navbar = ({ name }) => {
|
3
|
-
return (_jsxs("div", { className: "bg-gray-800 text-white p-4 text-center text-lg", children: [name, _jsx("button", { onClick: () => (window.location.href = "/footer"), className: "ml-4 p-2 bg-blue-500 rounded", children: "Go to Footer" })] }));
|
4
|
-
};
|
5
|
-
export default Navbar;
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import React, { useState } from "react";
|
3
|
-
const View = () => {
|
4
|
-
const [variable, setVariable] = useState("I'm a variable");
|
5
|
-
const [counter, setCounter] = useState(0);
|
6
|
-
const [isVisible, setIsVisible] = useState(true);
|
7
|
-
const [userName, setUserName] = useState("Guest");
|
8
|
-
return (_jsxs("div", { children: [_jsx("h1", { children: "Hello from form-viewer-comp" }), _jsx("p", { children: variable }), _jsxs("div", { children: [_jsxs("h2", { children: ["Counter: ", counter] }), _jsx("button", { onClick: () => setCounter(counter + 1), children: "Increase Counter" })] }), _jsxs("div", { children: [_jsxs("h2", { children: ["Visibility: ", isVisible ? "Visible" : "Hidden"] }), _jsx("button", { onClick: () => setIsVisible(!isVisible), children: "Toggle Visibility" })] }), _jsxs("div", { children: [_jsxs("h2", { children: ["User Name: ", userName] }), _jsx("button", { onClick: () => setUserName("New User"), children: "Change User Name" })] })] }));
|
9
|
-
};
|
10
|
-
export default View;
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
interface AddMissingDetailsProps {
|
3
|
-
usermodalopen: boolean;
|
4
|
-
closeusermodal: () => void;
|
5
|
-
url: string;
|
6
|
-
isDarkMode: boolean;
|
7
|
-
}
|
8
|
-
declare const AddMissingDetails: React.FC<AddMissingDetailsProps>;
|
9
|
-
export default AddMissingDetails;
|
@@ -1,56 +0,0 @@
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
-
});
|
9
|
-
};
|
10
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
11
|
-
import { useState, useEffect } from "react";
|
12
|
-
import { getProfileApi } from "../api/updateuser";
|
13
|
-
import Cookies from "universal-cookie";
|
14
|
-
const AddMissingDetails = ({ usermodalopen, closeusermodal, url, isDarkMode, }) => {
|
15
|
-
var _a;
|
16
|
-
const [name, setName] = useState("");
|
17
|
-
const [mobile, setMobile] = useState("");
|
18
|
-
const [address, setAddress] = useState("");
|
19
|
-
const [user, setUser] = useState(undefined);
|
20
|
-
const cookies = new Cookies();
|
21
|
-
const token = cookies.get("authToken");
|
22
|
-
const userToken = ((_a = token === null || token === void 0 ? void 0 : token.data) === null || _a === void 0 ? void 0 : _a.token) || token;
|
23
|
-
useEffect(() => {
|
24
|
-
const fetchUserProfile = () => __awaiter(void 0, void 0, void 0, function* () {
|
25
|
-
if (usermodalopen && userToken && !user) {
|
26
|
-
try {
|
27
|
-
const userProfile = yield getProfileApi(userToken, url);
|
28
|
-
if (userProfile) {
|
29
|
-
setUser(userProfile);
|
30
|
-
setName(userProfile.name);
|
31
|
-
setMobile(userProfile.mobile);
|
32
|
-
setAddress(userProfile.address);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
catch (error) {
|
36
|
-
console.error("Error fetching user profile:", error);
|
37
|
-
}
|
38
|
-
}
|
39
|
-
});
|
40
|
-
fetchUserProfile();
|
41
|
-
}, [usermodalopen, userToken, user]);
|
42
|
-
return (_jsx("div", { className: `fixed inset-0 flex items-center justify-center ${isDarkMode ? "bg-gray-800 bg-opacity-90" : "bg-gray-500 bg-opacity-75"}`, children: _jsxs("div", { className: `rounded-lg p-6 w-full max-w-md relative ${isDarkMode
|
43
|
-
? "border border-gray-300 bg-[#242424] text-white"
|
44
|
-
: "bg-white text-black"}`, children: [_jsx("button", { onClick: closeusermodal, className: `absolute top-3 right-3 ${isDarkMode
|
45
|
-
? "text-gray-300 hover:text-gray-500"
|
46
|
-
: "text-gray-400 hover:text-gray-600"} text-2xl`, children: "\u00D7" }), _jsx("h3", { className: "text-center text-xl font-bold mb-4", children: "Add User Details" }), _jsxs("div", { className: "mb-4", children: [_jsx("label", { className: `block text-sm font-medium mb-1 ${isDarkMode ? "text-gray-300" : "text-gray-700"}`, children: "Name" }), _jsx("input", { type: "text", placeholder: "Name", className: `w-full p-2 border rounded focus:outline-none focus:ring ${isDarkMode
|
47
|
-
? "bg-gray-800 border-gray-700 text-white "
|
48
|
-
: "border-gray-300 "}` })] }), _jsxs("div", { className: "mb-4", children: [_jsx("label", { className: `block text-sm font-medium mb-1 ${isDarkMode ? "text-gray-300" : "text-gray-700"}`, children: "Mobile" }), _jsx("input", { type: "tel", placeholder: "Mobile", className: `w-full p-2 border rounded focus:outline-none focus:ring ${isDarkMode
|
49
|
-
? "bg-gray-800 border-gray-700 text-white "
|
50
|
-
: "border-gray-300 "}` })] }), _jsxs("div", { className: "mb-4", children: [_jsx("label", { className: `block text-sm font-medium mb-1 ${isDarkMode ? "text-gray-300" : "text-gray-700"}`, children: "Address" }), _jsx("input", { type: "text", placeholder: "Address", className: `w-full p-2 border rounded focus:outline-none focus:ring ${isDarkMode
|
51
|
-
? "bg-gray-800 border-gray-700 text-white "
|
52
|
-
: "border-gray-300 "}` })] }), _jsx("div", { className: "flex justify-end", children: _jsx("button", { className: `px-4 py-2 rounded ${isDarkMode
|
53
|
-
? "bg-blue-500 hover:bg-blue-400 text-white"
|
54
|
-
: "bg-blue-500 hover:bg-blue-400 text-white"}`, children: "Add Details" }) })] }) }));
|
55
|
-
};
|
56
|
-
export default AddMissingDetails;
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import { useState } from "react";
|
3
|
-
const AddUserDetails = ({ usermodalopen, closeusermodal, url, isDarkMode, }) => {
|
4
|
-
const [name, setName] = useState("");
|
5
|
-
const [mobile, setMobile] = useState("");
|
6
|
-
const [address, setAddress] = useState("");
|
7
|
-
return (_jsx("div", { className: `fixed inset-0 flex items-center justify-center ${isDarkMode ? "bg-gray-800 bg-opacity-90" : "bg-gray-500 bg-opacity-75"}`, children: _jsxs("div", { className: `rounded-lg p-6 w-full max-w-md relative ${isDarkMode
|
8
|
-
? "border border-gray-300 bg-[#242424] text-white"
|
9
|
-
: "bg-white text-black"}`, children: [_jsx("button", { onClick: closeusermodal, className: `absolute top-3 right-3 ${isDarkMode
|
10
|
-
? "text-gray-300 hover:text-gray-500"
|
11
|
-
: "text-gray-400 hover:text-gray-600"} text-2xl`, children: "\u00D7" }), _jsx("h3", { className: "text-center text-xl font-bold mb-4", children: "Update User Details" }), _jsxs("div", { className: "mb-4", children: [_jsx("label", { className: `block text-sm font-medium mb-1 ${isDarkMode ? "text-gray-300" : "text-gray-700"}`, children: "Name" }), _jsx("input", { type: "text", placeholder: "Name", value: name, onChange: (e) => setName(e.target.value), className: `w-full p-2 border rounded focus:outline-none focus:ring ${isDarkMode
|
12
|
-
? "bg-gray-800 border-gray-700 text-white "
|
13
|
-
: "border-gray-300 "}` })] }), _jsxs("div", { className: "mb-4", children: [_jsx("label", { className: `block text-sm font-medium mb-1 ${isDarkMode ? "text-gray-300" : "text-gray-700"}`, children: "Mobile" }), _jsx("input", { type: "tel", placeholder: "Mobile", value: mobile, onChange: (e) => setMobile(e.target.value), className: `w-full p-2 border rounded focus:outline-none focus:ring ${isDarkMode
|
14
|
-
? "bg-gray-800 border-gray-700 text-white "
|
15
|
-
: "border-gray-300 "}` })] }), _jsxs("div", { className: "mb-4", children: [_jsx("label", { className: `block text-sm font-medium mb-1 ${isDarkMode ? "text-gray-300" : "text-gray-700"}`, children: "Address" }), _jsx("input", { type: "text", placeholder: "Address", value: address, onChange: (e) => setAddress(e.target.value), className: `w-full p-2 border rounded focus:outline-none focus:ring ${isDarkMode
|
16
|
-
? "bg-gray-800 border-gray-700 text-white "
|
17
|
-
: "border-gray-300 "}` })] }), _jsx("div", { className: "flex justify-end", children: _jsx("button", { className: `px-4 py-2 rounded ${isDarkMode
|
18
|
-
? "bg-blue-500 hover:bg-blue-400 text-white"
|
19
|
-
: "bg-blue-500 hover:bg-blue-400 text-white"}`, children: "Update Details" }) })] }) }));
|
20
|
-
};
|
21
|
-
export default AddUserDetails;
|
package/src/App.tsx
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
3
|
-
import Navbar from "./components/Navbar"; // Ensure correct path to your Navbar
|
4
|
-
import Footer from "./components/footer/Footer"; // Ensure correct path to your Footer
|
5
|
-
|
6
|
-
const App: React.FC = () => {
|
7
|
-
return (
|
8
|
-
<BrowserRouter>
|
9
|
-
{/* <Navbar name="My Package" /> */}
|
10
|
-
<Routes>
|
11
|
-
{/* <Route path="/" element={<div>Home Page</div>} /> */}
|
12
|
-
{/* <Route path="/navbar" element={<Navbar />} /> */}
|
13
|
-
<Route path="/footer" element={<Footer />} />
|
14
|
-
</Routes>
|
15
|
-
</BrowserRouter>
|
16
|
-
);
|
17
|
-
};
|
18
|
-
|
19
|
-
// Named exports for Navbar and Footer
|
20
|
-
export { Navbar, Footer };
|
21
|
-
export default App;
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
|
3
|
-
interface NavbarProps {
|
4
|
-
name: string;
|
5
|
-
}
|
6
|
-
|
7
|
-
const Navbar: React.FC<NavbarProps> = ({ name }) => {
|
8
|
-
return (
|
9
|
-
<div className="bg-gray-800 text-white p-4 text-center text-lg">
|
10
|
-
{name}
|
11
|
-
<button
|
12
|
-
onClick={() => (window.location.href = "/footer")}
|
13
|
-
className="ml-4 p-2 bg-blue-500 rounded"
|
14
|
-
>
|
15
|
-
Go to Footer
|
16
|
-
</button>
|
17
|
-
</div>
|
18
|
-
);
|
19
|
-
};
|
20
|
-
|
21
|
-
export default Navbar;
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { useRef } from "react";
|
3
|
-
import JoditEditor from "jodit-react";
|
4
|
-
|
5
|
-
interface EditorProps {
|
6
|
-
content: string;
|
7
|
-
setContent: (newContent: string) => void;
|
8
|
-
config?: Record<string, any>;
|
9
|
-
}
|
10
|
-
|
11
|
-
const Editor: React.FC<EditorProps> = ({ content, setContent, config }) => {
|
12
|
-
const editor = useRef(null);
|
13
|
-
|
14
|
-
return (
|
15
|
-
<JoditEditor
|
16
|
-
ref={editor}
|
17
|
-
value={content}
|
18
|
-
config={config}
|
19
|
-
onBlur={(newContent) => setContent(newContent)}
|
20
|
-
onChange={() => {}}
|
21
|
-
/>
|
22
|
-
);
|
23
|
-
};
|
24
|
-
|
25
|
-
export default Editor;
|