eleven-solutions-common-website-unique-web 21.0.56 → 22.0.1
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/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,277 +0,0 @@
|
|
1
|
-
import React, { useState } from "react";
|
2
|
-
import { loginApi, registerApi } from "../api/api";
|
3
|
-
import Cookies from "universal-cookie";
|
4
|
-
import GoogleButton from "./GoogleButton";
|
5
|
-
interface LoginProps {
|
6
|
-
ModalOpen: boolean;
|
7
|
-
closeModal: () => void;
|
8
|
-
url: string;
|
9
|
-
isDarkMode: boolean;
|
10
|
-
}
|
11
|
-
const Login = ({ ModalOpen, closeModal, url, isDarkMode }: LoginProps) => {
|
12
|
-
const [isLoginMode, setIsLoginMode] = useState(true);
|
13
|
-
const [email, setEmail] = useState("");
|
14
|
-
const [password, setPassword] = useState("");
|
15
|
-
const [name, setName] = useState("");
|
16
|
-
const [mobile, setMobile] = useState("");
|
17
|
-
const [confirmPassword, setConfirmPassword] = useState("");
|
18
|
-
const [termsAccepted, setTermsAccepted] = useState(false);
|
19
|
-
const [loading] = useState(false);
|
20
|
-
const [error, setError] = useState<string | null>(null);
|
21
|
-
const [successMessage, setSuccessMessage] = useState<string | null>(null);
|
22
|
-
const cookies = new Cookies();
|
23
|
-
const toggleMode = () => setIsLoginMode(!isLoginMode);
|
24
|
-
|
25
|
-
const handleLogin = async (e: React.FormEvent) => {
|
26
|
-
e.preventDefault();
|
27
|
-
try {
|
28
|
-
const response = await loginApi(url, email, password);
|
29
|
-
if (!response) {
|
30
|
-
console.log("please try again after some time");
|
31
|
-
} else {
|
32
|
-
if (response?.data?.token) {
|
33
|
-
cookies.set("authToken", response.data.token, { maxAge: 86400 });
|
34
|
-
window.location.href = "/home";
|
35
|
-
}
|
36
|
-
}
|
37
|
-
console.log(response.data.token);
|
38
|
-
} catch (err) {
|
39
|
-
console.error("Error during login:", err);
|
40
|
-
setError("Error during login");
|
41
|
-
}
|
42
|
-
};
|
43
|
-
|
44
|
-
const handleRegister = async (e: React.FormEvent) => {
|
45
|
-
e.preventDefault();
|
46
|
-
|
47
|
-
if (password !== confirmPassword) {
|
48
|
-
setError("Passwords do not match.");
|
49
|
-
return;
|
50
|
-
}
|
51
|
-
|
52
|
-
if (!termsAccepted) {
|
53
|
-
setError("You must accept the terms and conditions.");
|
54
|
-
return;
|
55
|
-
}
|
56
|
-
|
57
|
-
const emailRegex = /^[a-zA-Z0-9._%+-]+@gmail\.com$/;
|
58
|
-
if (!emailRegex.test(email)) {
|
59
|
-
setError("Email must be a valid @gmail.com address.");
|
60
|
-
return;
|
61
|
-
}
|
62
|
-
|
63
|
-
try {
|
64
|
-
const response = await registerApi(
|
65
|
-
url,
|
66
|
-
name,
|
67
|
-
email,
|
68
|
-
mobile,
|
69
|
-
confirmPassword
|
70
|
-
);
|
71
|
-
console.log("res", response);
|
72
|
-
|
73
|
-
if (response) {
|
74
|
-
cookies.set("authToken", response, { maxAge: 86400 });
|
75
|
-
window.location.href = "/home";
|
76
|
-
|
77
|
-
setSuccessMessage("Registration successful!");
|
78
|
-
} else {
|
79
|
-
setError("Registration failed. Please try again.");
|
80
|
-
}
|
81
|
-
} catch (error) {
|
82
|
-
console.error("Error during registration:");
|
83
|
-
setError("An error occurred during registration.");
|
84
|
-
}
|
85
|
-
};
|
86
|
-
|
87
|
-
return (
|
88
|
-
<div
|
89
|
-
className={`${
|
90
|
-
isDarkMode ? "bg-[#2e2e2e] text-[#ffff]" : "bg-[#ffff] text-black"
|
91
|
-
}`}
|
92
|
-
>
|
93
|
-
{ModalOpen && (
|
94
|
-
<div className="fixed inset-0 flex items-center justify-center z-50 bg-black bg-opacity-50 transition-opacity duration-75 ease-in-out ">
|
95
|
-
<div
|
96
|
-
className={`relative ${
|
97
|
-
isDarkMode ? "bg-[#2e2e2e]" : "bg-white"
|
98
|
-
} 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 `}
|
99
|
-
>
|
100
|
-
<button
|
101
|
-
onClick={closeModal}
|
102
|
-
className={` absolute top-1 right-3 text-3xl ${
|
103
|
-
isDarkMode ? " text-[#ffff]" : " text-black"
|
104
|
-
}`}
|
105
|
-
>
|
106
|
-
×
|
107
|
-
</button>
|
108
|
-
<img
|
109
|
-
className="h-16 w-20 mx-auto animate-fadeIn"
|
110
|
-
src="images/BarelviLogo.png"
|
111
|
-
alt="Logo"
|
112
|
-
/>
|
113
|
-
<h1
|
114
|
-
className={`mt-3 text-xl sm:text-2xl font-semibold capitalize text-center ${
|
115
|
-
isDarkMode ? "text-[#ffff]" : "text-black"
|
116
|
-
}`}
|
117
|
-
>
|
118
|
-
{isLoginMode ? "Sign In" : "Sign Up"}
|
119
|
-
</h1>
|
120
|
-
|
121
|
-
<form onSubmit={isLoginMode ? handleLogin : handleRegister}>
|
122
|
-
{!isLoginMode && (
|
123
|
-
<>
|
124
|
-
<div className="relative flex items-center mt-4">
|
125
|
-
<input
|
126
|
-
type="text"
|
127
|
-
value={name}
|
128
|
-
onChange={(e) => setName(e.target.value)}
|
129
|
-
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"
|
130
|
-
placeholder="Full Name"
|
131
|
-
required
|
132
|
-
/>
|
133
|
-
</div>
|
134
|
-
|
135
|
-
<div className="relative flex items-center mt-4">
|
136
|
-
<input
|
137
|
-
type="tel"
|
138
|
-
value={mobile}
|
139
|
-
onChange={(e) => setMobile(e.target.value)}
|
140
|
-
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"
|
141
|
-
placeholder="Mobile Number"
|
142
|
-
required
|
143
|
-
/>
|
144
|
-
</div>
|
145
|
-
|
146
|
-
<div className="relative flex items-center mt-4">
|
147
|
-
<input
|
148
|
-
type="email"
|
149
|
-
value={email}
|
150
|
-
onChange={(e) => setEmail(e.target.value)}
|
151
|
-
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"
|
152
|
-
placeholder="Email address"
|
153
|
-
required
|
154
|
-
/>
|
155
|
-
</div>
|
156
|
-
|
157
|
-
<div className="relative flex items-center mt-4">
|
158
|
-
<input
|
159
|
-
type="password"
|
160
|
-
value={password}
|
161
|
-
onChange={(e) => setPassword(e.target.value)}
|
162
|
-
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"
|
163
|
-
placeholder="Password"
|
164
|
-
required
|
165
|
-
/>
|
166
|
-
</div>
|
167
|
-
|
168
|
-
<div className="relative flex items-center mt-4">
|
169
|
-
<input
|
170
|
-
type="password"
|
171
|
-
value={confirmPassword}
|
172
|
-
onChange={(e) => setConfirmPassword(e.target.value)}
|
173
|
-
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"
|
174
|
-
placeholder="Confirm Password"
|
175
|
-
required
|
176
|
-
/>
|
177
|
-
</div>
|
178
|
-
|
179
|
-
<div className="mt-4">
|
180
|
-
<label className="flex items-center">
|
181
|
-
<input
|
182
|
-
type="checkbox"
|
183
|
-
checked={termsAccepted}
|
184
|
-
onChange={() => setTermsAccepted(!termsAccepted)}
|
185
|
-
className="form-checkbox cursor-pointer"
|
186
|
-
/>
|
187
|
-
<span className="ml-2 text-sm text-gray-600 dark:text-gray-300">
|
188
|
-
I accept the{" "}
|
189
|
-
<button className="text-blue-500 hover:underline">
|
190
|
-
terms and conditions
|
191
|
-
</button>
|
192
|
-
</span>
|
193
|
-
</label>
|
194
|
-
</div>
|
195
|
-
</>
|
196
|
-
)}
|
197
|
-
|
198
|
-
{isLoginMode && (
|
199
|
-
<>
|
200
|
-
<div className="relative flex items-center mt-4">
|
201
|
-
<input
|
202
|
-
type="email"
|
203
|
-
value={email}
|
204
|
-
onChange={(e) => setEmail(e.target.value)}
|
205
|
-
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"
|
206
|
-
placeholder="Email address"
|
207
|
-
required
|
208
|
-
/>
|
209
|
-
</div>
|
210
|
-
|
211
|
-
<div className="relative flex items-center mt-4">
|
212
|
-
<input
|
213
|
-
type="password"
|
214
|
-
value={password}
|
215
|
-
onChange={(e) => setPassword(e.target.value)}
|
216
|
-
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"
|
217
|
-
placeholder="Password"
|
218
|
-
required
|
219
|
-
/>
|
220
|
-
</div>
|
221
|
-
</>
|
222
|
-
)}
|
223
|
-
|
224
|
-
<div className="mt-6">
|
225
|
-
<button
|
226
|
-
type="submit"
|
227
|
-
disabled={loading}
|
228
|
-
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"
|
229
|
-
>
|
230
|
-
{loading
|
231
|
-
? isLoginMode
|
232
|
-
? "Logging in..."
|
233
|
-
: "Registering..."
|
234
|
-
: isLoginMode
|
235
|
-
? "Login"
|
236
|
-
: "Register"}
|
237
|
-
</button>
|
238
|
-
</div>
|
239
|
-
</form>
|
240
|
-
|
241
|
-
<div className="flex items-center justify-center mt-2">
|
242
|
-
<hr className="w-1/4" />
|
243
|
-
<span className="mx-2 text-gray-500">or</span>
|
244
|
-
<hr className="w-1/4" />
|
245
|
-
</div>
|
246
|
-
<div className="">
|
247
|
-
<GoogleButton url={url} onClose={function (): void {
|
248
|
-
throw new Error("Function not implemented.");
|
249
|
-
} } />
|
250
|
-
</div>
|
251
|
-
<div className="mt-2 text-center">
|
252
|
-
<button
|
253
|
-
onClick={toggleMode}
|
254
|
-
className="text-sm text-blue-500 hover:underline"
|
255
|
-
>
|
256
|
-
{isLoginMode
|
257
|
-
? "Don't have an account? Sign Up"
|
258
|
-
: "Already have an account? Sign In"}
|
259
|
-
</button>
|
260
|
-
</div>
|
261
|
-
|
262
|
-
{error && (
|
263
|
-
<p className="mt-2 w-full text-center text-red-500">{error}</p>
|
264
|
-
)}
|
265
|
-
{successMessage && (
|
266
|
-
<p className="mt-2 text-center text-green-500">
|
267
|
-
{successMessage}
|
268
|
-
</p>
|
269
|
-
)}
|
270
|
-
</div>
|
271
|
-
</div>
|
272
|
-
)}
|
273
|
-
</div>
|
274
|
-
);
|
275
|
-
};
|
276
|
-
|
277
|
-
export default Login;
|
@@ -1,136 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { useState } from "react";
|
3
|
-
import { getProfileApi } from "../api/updateuser";
|
4
|
-
|
5
|
-
interface AddUserDetailsProps {
|
6
|
-
usermodalopen: boolean;
|
7
|
-
closeusermodal: () => void;
|
8
|
-
url: string;
|
9
|
-
isDarkMode: boolean;
|
10
|
-
}
|
11
|
-
|
12
|
-
interface UserProfile {
|
13
|
-
name: string;
|
14
|
-
mobile: string;
|
15
|
-
address: string;
|
16
|
-
// add any other fields that `userProfile` is expected to have
|
17
|
-
}
|
18
|
-
|
19
|
-
const AddUserDetails: React.FC<AddUserDetailsProps> = ({
|
20
|
-
usermodalopen,
|
21
|
-
closeusermodal,
|
22
|
-
url,
|
23
|
-
isDarkMode,
|
24
|
-
}) => {
|
25
|
-
const [name, setName] = useState("");
|
26
|
-
const [mobile, setMobile] = useState("");
|
27
|
-
const [address, setAddress] = useState("");
|
28
|
-
|
29
|
-
return (
|
30
|
-
<div
|
31
|
-
className={`fixed inset-0 flex items-center justify-center ${
|
32
|
-
isDarkMode ? "bg-gray-800 bg-opacity-90" : "bg-gray-500 bg-opacity-75"
|
33
|
-
}`}
|
34
|
-
>
|
35
|
-
<div
|
36
|
-
className={`rounded-lg p-6 w-full max-w-md relative ${
|
37
|
-
isDarkMode
|
38
|
-
? "border border-gray-300 bg-[#242424] text-white"
|
39
|
-
: "bg-white text-black"
|
40
|
-
}`}
|
41
|
-
>
|
42
|
-
<button
|
43
|
-
onClick={closeusermodal}
|
44
|
-
className={`absolute top-3 right-3 ${
|
45
|
-
isDarkMode
|
46
|
-
? "text-gray-300 hover:text-gray-500"
|
47
|
-
: "text-gray-400 hover:text-gray-600"
|
48
|
-
} text-2xl`}
|
49
|
-
>
|
50
|
-
×
|
51
|
-
</button>
|
52
|
-
|
53
|
-
<h3 className="text-center text-xl font-bold mb-4">
|
54
|
-
Update User Details
|
55
|
-
</h3>
|
56
|
-
|
57
|
-
<div className="mb-4">
|
58
|
-
<label
|
59
|
-
className={`block text-sm font-medium mb-1 ${
|
60
|
-
isDarkMode ? "text-gray-300" : "text-gray-700"
|
61
|
-
}`}
|
62
|
-
>
|
63
|
-
Name
|
64
|
-
</label>
|
65
|
-
<input
|
66
|
-
type="text"
|
67
|
-
placeholder="Name"
|
68
|
-
value={name}
|
69
|
-
onChange={(e) => setName(e.target.value)}
|
70
|
-
className={`w-full p-2 border rounded focus:outline-none focus:ring ${
|
71
|
-
isDarkMode
|
72
|
-
? "bg-gray-800 border-gray-700 text-white "
|
73
|
-
: "border-gray-300 "
|
74
|
-
}`}
|
75
|
-
/>
|
76
|
-
</div>
|
77
|
-
|
78
|
-
<div className="mb-4">
|
79
|
-
<label
|
80
|
-
className={`block text-sm font-medium mb-1 ${
|
81
|
-
isDarkMode ? "text-gray-300" : "text-gray-700"
|
82
|
-
}`}
|
83
|
-
>
|
84
|
-
Mobile
|
85
|
-
</label>
|
86
|
-
<input
|
87
|
-
type="tel"
|
88
|
-
placeholder="Mobile"
|
89
|
-
value={mobile}
|
90
|
-
onChange={(e) => setMobile(e.target.value)}
|
91
|
-
className={`w-full p-2 border rounded focus:outline-none focus:ring ${
|
92
|
-
isDarkMode
|
93
|
-
? "bg-gray-800 border-gray-700 text-white "
|
94
|
-
: "border-gray-300 "
|
95
|
-
}`}
|
96
|
-
/>
|
97
|
-
</div>
|
98
|
-
|
99
|
-
<div className="mb-4">
|
100
|
-
<label
|
101
|
-
className={`block text-sm font-medium mb-1 ${
|
102
|
-
isDarkMode ? "text-gray-300" : "text-gray-700"
|
103
|
-
}`}
|
104
|
-
>
|
105
|
-
Address
|
106
|
-
</label>
|
107
|
-
<input
|
108
|
-
type="text"
|
109
|
-
placeholder="Address"
|
110
|
-
value={address}
|
111
|
-
onChange={(e) => setAddress(e.target.value)}
|
112
|
-
className={`w-full p-2 border rounded focus:outline-none focus:ring ${
|
113
|
-
isDarkMode
|
114
|
-
? "bg-gray-800 border-gray-700 text-white "
|
115
|
-
: "border-gray-300 "
|
116
|
-
}`}
|
117
|
-
/>
|
118
|
-
</div>
|
119
|
-
|
120
|
-
<div className="flex justify-end">
|
121
|
-
<button
|
122
|
-
className={`px-4 py-2 rounded ${
|
123
|
-
isDarkMode
|
124
|
-
? "bg-blue-500 hover:bg-blue-400 text-white"
|
125
|
-
: "bg-blue-500 hover:bg-blue-400 text-white"
|
126
|
-
}`}
|
127
|
-
>
|
128
|
-
Update Details
|
129
|
-
</button>
|
130
|
-
</div>
|
131
|
-
</div>
|
132
|
-
</div>
|
133
|
-
);
|
134
|
-
};
|
135
|
-
|
136
|
-
export default AddUserDetails;
|
@@ -1,214 +0,0 @@
|
|
1
|
-
import React, { useState, useEffect, ChangeEvent } from "react";
|
2
|
-
import { updateProfileApi, getProfileApi } from "../api/updateuser";
|
3
|
-
import Cookies from "universal-cookie";
|
4
|
-
|
5
|
-
interface UpdateUserDetailsProps {
|
6
|
-
usermodalopen: boolean;
|
7
|
-
closeusermodal: () => void;
|
8
|
-
url: string;
|
9
|
-
isDarkMode: boolean;
|
10
|
-
}
|
11
|
-
interface UserProfile {
|
12
|
-
name: string;
|
13
|
-
mobile: string;
|
14
|
-
address: string;
|
15
|
-
// add any other fields that `userProfile` is expected to have
|
16
|
-
}
|
17
|
-
|
18
|
-
const UpdateUserDetails: React.FC<UpdateUserDetailsProps> = ({
|
19
|
-
usermodalopen,
|
20
|
-
closeusermodal,
|
21
|
-
url,
|
22
|
-
isDarkMode,
|
23
|
-
}) => {
|
24
|
-
const [name, setName] = useState<string>("");
|
25
|
-
const [mobile, setMobile] = useState<string>("");
|
26
|
-
const [address, setAddress] = useState<string>("");
|
27
|
-
|
28
|
-
const [user, setUser] = useState<UserProfile | undefined>(undefined);
|
29
|
-
|
30
|
-
const cookies = new Cookies();
|
31
|
-
const token = cookies.get("authToken");
|
32
|
-
|
33
|
-
const userToken = token?.data?.token || token;
|
34
|
-
|
35
|
-
useEffect(() => {
|
36
|
-
const fetchUserProfile = async () => {
|
37
|
-
if (usermodalopen && userToken && !user) {
|
38
|
-
try {
|
39
|
-
const userProfile = await getProfileApi(userToken, url);
|
40
|
-
if (userProfile) {
|
41
|
-
setUser(userProfile);
|
42
|
-
setName(userProfile.name);
|
43
|
-
setMobile(userProfile.mobile);
|
44
|
-
setAddress(userProfile.address);
|
45
|
-
}
|
46
|
-
} catch (error) {
|
47
|
-
console.error("Error fetching user profile:", error);
|
48
|
-
}
|
49
|
-
}
|
50
|
-
};
|
51
|
-
|
52
|
-
fetchUserProfile();
|
53
|
-
}, [usermodalopen, userToken, user]);
|
54
|
-
|
55
|
-
const validateForm = () => {
|
56
|
-
if (!name || !mobile || !address) {
|
57
|
-
alert("Please fill in all required fields: Name, Mobile, and Address.");
|
58
|
-
return false;
|
59
|
-
}
|
60
|
-
return true;
|
61
|
-
};
|
62
|
-
|
63
|
-
const handleUpdate = async (event: React.MouseEvent<HTMLButtonElement>) => {
|
64
|
-
event.preventDefault();
|
65
|
-
|
66
|
-
if (!name.trim() || !mobile.trim() || !address.trim()) {
|
67
|
-
alert("Name ,Mobile and Address fields cannot be empty.");
|
68
|
-
return;
|
69
|
-
}
|
70
|
-
|
71
|
-
if (!validateForm()) return;
|
72
|
-
try {
|
73
|
-
const response = await updateProfileApi(
|
74
|
-
url,
|
75
|
-
userToken,
|
76
|
-
name,
|
77
|
-
mobile,
|
78
|
-
address
|
79
|
-
);
|
80
|
-
if (response.status === 200) {
|
81
|
-
alert("Updated Successfully");
|
82
|
-
closeusermodal();
|
83
|
-
window.location.reload();
|
84
|
-
} else {
|
85
|
-
console.error("Update failed:", response.statusText);
|
86
|
-
}
|
87
|
-
} catch (error) {
|
88
|
-
console.error("Error updating profile:", error);
|
89
|
-
}
|
90
|
-
};
|
91
|
-
|
92
|
-
const handleNameChange = (event: ChangeEvent<HTMLInputElement>) => {
|
93
|
-
setName(event.target.value);
|
94
|
-
};
|
95
|
-
|
96
|
-
const handleMobileChange = (event: ChangeEvent<HTMLInputElement>) => {
|
97
|
-
setMobile(event.target.value);
|
98
|
-
};
|
99
|
-
|
100
|
-
const handleAddressChange = (event: ChangeEvent<HTMLInputElement>) => {
|
101
|
-
setAddress(event.target.value);
|
102
|
-
};
|
103
|
-
|
104
|
-
if (!usermodalopen) return null;
|
105
|
-
|
106
|
-
return (
|
107
|
-
<div
|
108
|
-
className={`fixed inset-0 flex items-center justify-center ${
|
109
|
-
isDarkMode ? "bg-gray-800 bg-opacity-90" : "bg-gray-500 bg-opacity-75"
|
110
|
-
}`}
|
111
|
-
>
|
112
|
-
<div
|
113
|
-
className={`rounded-lg p-6 w-full max-w-md relative ${
|
114
|
-
isDarkMode
|
115
|
-
? "border border-gray-300 bg-[#242424] text-white"
|
116
|
-
: "bg-white text-black"
|
117
|
-
}`}
|
118
|
-
>
|
119
|
-
<button
|
120
|
-
onClick={closeusermodal}
|
121
|
-
className={`absolute top-3 right-3 ${
|
122
|
-
isDarkMode
|
123
|
-
? "text-gray-300 hover:text-gray-500"
|
124
|
-
: "text-gray-400 hover:text-gray-600"
|
125
|
-
} text-2xl`}
|
126
|
-
>
|
127
|
-
×
|
128
|
-
</button>
|
129
|
-
|
130
|
-
<h3 className="text-center text-xl font-bold mb-4">
|
131
|
-
Update User Details
|
132
|
-
</h3>
|
133
|
-
|
134
|
-
<div className="mb-4">
|
135
|
-
<label
|
136
|
-
className={`block text-sm font-medium mb-1 ${
|
137
|
-
isDarkMode ? "text-gray-300" : "text-gray-700"
|
138
|
-
}`}
|
139
|
-
>
|
140
|
-
Name
|
141
|
-
</label>
|
142
|
-
<input
|
143
|
-
type="text"
|
144
|
-
placeholder="Name"
|
145
|
-
value={name}
|
146
|
-
onChange={handleNameChange}
|
147
|
-
className={`w-full p-2 border rounded focus:outline-none focus:ring ${
|
148
|
-
isDarkMode
|
149
|
-
? "bg-gray-800 border-gray-700 text-white "
|
150
|
-
: "border-gray-300 "
|
151
|
-
}`}
|
152
|
-
/>
|
153
|
-
</div>
|
154
|
-
|
155
|
-
<div className="mb-4">
|
156
|
-
<label
|
157
|
-
className={`block text-sm font-medium mb-1 ${
|
158
|
-
isDarkMode ? "text-gray-300" : "text-gray-700"
|
159
|
-
}`}
|
160
|
-
>
|
161
|
-
Mobile
|
162
|
-
</label>
|
163
|
-
<input
|
164
|
-
type="tel"
|
165
|
-
placeholder="Mobile"
|
166
|
-
value={mobile}
|
167
|
-
onChange={handleMobileChange}
|
168
|
-
className={`w-full p-2 border rounded focus:outline-none focus:ring ${
|
169
|
-
isDarkMode
|
170
|
-
? "bg-gray-800 border-gray-700 text-white "
|
171
|
-
: "border-gray-300 "
|
172
|
-
}`}
|
173
|
-
/>
|
174
|
-
</div>
|
175
|
-
|
176
|
-
<div className="mb-4">
|
177
|
-
<label
|
178
|
-
className={`block text-sm font-medium mb-1 ${
|
179
|
-
isDarkMode ? "text-gray-300" : "text-gray-700"
|
180
|
-
}`}
|
181
|
-
>
|
182
|
-
Address
|
183
|
-
</label>
|
184
|
-
<input
|
185
|
-
type="text"
|
186
|
-
placeholder="Address"
|
187
|
-
value={address}
|
188
|
-
onChange={handleAddressChange}
|
189
|
-
className={`w-full p-2 border rounded focus:outline-none focus:ring ${
|
190
|
-
isDarkMode
|
191
|
-
? "bg-gray-800 border-gray-700 text-white "
|
192
|
-
: "border-gray-300 "
|
193
|
-
}`}
|
194
|
-
/>
|
195
|
-
</div>
|
196
|
-
|
197
|
-
<div className="flex justify-end">
|
198
|
-
<button
|
199
|
-
onClick={handleUpdate}
|
200
|
-
className={`px-4 py-2 rounded ${
|
201
|
-
isDarkMode
|
202
|
-
? "bg-blue-500 hover:bg-blue-400 text-white"
|
203
|
-
: "bg-blue-500 hover:bg-blue-400 text-white"
|
204
|
-
}`}
|
205
|
-
>
|
206
|
-
Update Details
|
207
|
-
</button>
|
208
|
-
</div>
|
209
|
-
</div>
|
210
|
-
</div>
|
211
|
-
);
|
212
|
-
};
|
213
|
-
|
214
|
-
export default UpdateUserDetails;
|
package/src/index.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from "./components/index";
|
package/tsconfig.json
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"target": "es2015",
|
4
|
-
"module": "ESNext",
|
5
|
-
"moduleResolution": "node",
|
6
|
-
"jsx": "react-jsx",
|
7
|
-
"declaration": true,
|
8
|
-
"outDir": "dist",
|
9
|
-
"lib": ["dom", "es2015"],
|
10
|
-
"esModuleInterop": true,
|
11
|
-
"skipLibCheck": true,
|
12
|
-
"forceConsistentCasingInFileNames": true
|
13
|
-
},
|
14
|
-
"include": ["src/**/*"]
|
15
|
-
}
|