eleven-solutions-common-website-unique-web 20.0.47 → 20.0.49
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/components/admin/UserForm.js +2 -10
- package/dist/components/admin/Users.js +0 -8
- package/dist/components/api/user.d.ts +1 -1
- package/dist/components/api/user.js +4 -3
- package/package.json +1 -1
- package/src/components/admin/UserForm.tsx +2 -8
- package/src/components/admin/Users.tsx +0 -9
- package/src/components/api/user.ts +4 -2
@@ -17,11 +17,7 @@ const UserForm = ({ url }) => {
|
|
17
17
|
const [address, setAddress] = useState("");
|
18
18
|
const [roleType, setRoleType] = useState("");
|
19
19
|
const [gender, setGender] = useState("");
|
20
|
-
const [isDisabled, setIsDisabled] = useState(false);
|
21
20
|
const [isEditMode, setIsEditMode] = useState(false);
|
22
|
-
useEffect(() => {
|
23
|
-
setIsDisabled(isEditMode && !email);
|
24
|
-
}, [isEditMode, email]);
|
25
21
|
const validateForm = () => {
|
26
22
|
if (!userName || !roleType) {
|
27
23
|
alert("Please fill in all required fields: User Name, Email, and Role Type.");
|
@@ -60,7 +56,7 @@ const UserForm = ({ url }) => {
|
|
60
56
|
return;
|
61
57
|
try {
|
62
58
|
if (isEditMode) {
|
63
|
-
yield updateUserApi(url, id, userName, mobile, address, roleType, gender);
|
59
|
+
yield updateUserApi(url, id, userName, email, mobile, address, roleType, gender);
|
64
60
|
alert("User updated successfully");
|
65
61
|
}
|
66
62
|
else {
|
@@ -85,10 +81,6 @@ const UserForm = ({ url }) => {
|
|
85
81
|
window.history.pushState({}, "", "/admin/users");
|
86
82
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
87
83
|
};
|
88
|
-
return (_jsx("div", { className: "max-w-4xl p-6 mx-auto dark:bg-gray-800", children: _jsx("div", { children: _jsxs("form", { children: [_jsx("h1", { className: "text-3xl font-bold text-center text-blue-600 capitalize dark:text-white mb-4", children: isEditMode ? "Edit User" : "Add User" }), _jsxs("div", { className: "mb-6 w-full", children: [_jsxs("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: ["Name ", _jsx("span", { className: "text-red-500", children: "*" })] }), _jsx("input", { required: true, value: userName, onChange: (e) => setUserName(e.target.value), type: "text", className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", placeholder: "Enter User Name" })] }), _jsxs("div", { className: "mb-6 w-full", children: [_jsxs("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: ["Email ", _jsx("span", { className: "text-red-500", children: "*" })] }), _jsx("input", { required: true,
|
89
|
-
// value={email}
|
90
|
-
value: email || "", onChange: (e) => setEmail(e.target.value), type: "email", className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", placeholder: "Enter Email",
|
91
|
-
// disabled={isEditMode}
|
92
|
-
disabled: isDisabled })] }), _jsxs("div", { className: "mb-6 w-full", children: [_jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Mobile Number" }), _jsx("input", { required: true, value: mobile, onChange: (e) => setMobile(e.target.value), type: "number", className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", placeholder: "Enter Mobile Number" })] }), _jsxs("div", { className: "mb-6 w-full", children: [_jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Address" }), _jsx("input", { required: true, value: address, onChange: (e) => setAddress(e.target.value), type: "text", className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", placeholder: "Address" })] }), _jsxs("div", { className: "mb-6 w-full", children: [_jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Gender" }), _jsxs("select", { required: true, value: gender, onChange: (e) => setGender(e.target.value === "" ? null : e.target.value), className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", children: [_jsx("option", { value: "", children: "Select a Gender" }), _jsx("option", { value: "1", children: "Male" }), _jsx("option", { value: "2", children: "Female" })] })] }), _jsxs("div", { className: "mb-6 w-full", children: [_jsxs("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: ["Role Type ", _jsx("span", { className: "text-red-500", children: "*" })] }), _jsxs("select", { required: true, value: roleType, onChange: (e) => setRoleType(e.target.value), className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", children: [_jsx("option", { value: "", children: "Select a Role Type" }), _jsx("option", { value: "1", children: "Guest" }), _jsx("option", { value: "2", children: "Admin" })] })] }), _jsxs("div", { className: "flex space-x-4 mt-6 justify-end", children: [_jsx("button", { type: "submit", onClick: handleSubmit, className: "px-8 py-2.5 leading-5 text-white transition-colors duration-300 transform bg-blue-600 rounded-md hover:bg-blue-500 focus:outline-none focus:bg-gray-600", children: isEditMode ? "Edit" : "Add" }), _jsx("button", { type: "button", onClick: handleCancelClick, className: "px-8 py-2.5 leading-5 text-white transition-colors duration-300 transform bg-blue-600 rounded-md hover:bg-blue-500 focus:outline-none focus:bg-gray-600", children: "Cancel" })] })] }) }) }));
|
84
|
+
return (_jsx("div", { className: "max-w-4xl p-6 mx-auto dark:bg-gray-800", children: _jsx("div", { children: _jsxs("form", { children: [_jsx("h1", { className: "text-3xl font-bold text-center text-blue-600 capitalize dark:text-white mb-4", children: isEditMode ? "Edit User" : "Add User" }), _jsxs("div", { className: "mb-6 w-full", children: [_jsxs("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: ["Name ", _jsx("span", { className: "text-red-500", children: "*" })] }), _jsx("input", { required: true, value: userName, onChange: (e) => setUserName(e.target.value), type: "text", className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", placeholder: "Enter User Name" })] }), _jsxs("div", { className: "mb-6 w-full", children: [_jsxs("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: ["Email ", _jsx("span", { className: "text-red-500", children: "*" })] }), _jsx("input", { required: true, value: email, onChange: (e) => setEmail(e.target.value), type: "email", className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", placeholder: "Enter Email" })] }), _jsxs("div", { className: "mb-6 w-full", children: [_jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Mobile Number" }), _jsx("input", { required: true, value: mobile, onChange: (e) => setMobile(e.target.value), type: "number", className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", placeholder: "Enter Mobile Number" })] }), _jsxs("div", { className: "mb-6 w-full", children: [_jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Address" }), _jsx("input", { required: true, value: address, onChange: (e) => setAddress(e.target.value), type: "text", className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", placeholder: "Address" })] }), _jsxs("div", { className: "mb-6 w-full", children: [_jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Gender" }), _jsxs("select", { required: true, value: gender, onChange: (e) => setGender(e.target.value === "" ? null : e.target.value), className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", children: [_jsx("option", { value: "", children: "Select a Gender" }), _jsx("option", { value: "1", children: "Male" }), _jsx("option", { value: "2", children: "Female" })] })] }), _jsxs("div", { className: "mb-6 w-full", children: [_jsxs("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: ["Role Type ", _jsx("span", { className: "text-red-500", children: "*" })] }), _jsxs("select", { required: true, value: roleType, onChange: (e) => setRoleType(e.target.value), className: "w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring", children: [_jsx("option", { value: "", children: "Select a Role Type" }), _jsx("option", { value: "1", children: "Guest" }), _jsx("option", { value: "2", children: "Admin" })] })] }), _jsxs("div", { className: "flex space-x-4 mt-6 justify-end", children: [_jsx("button", { type: "submit", onClick: handleSubmit, className: "px-8 py-2.5 leading-5 text-white transition-colors duration-300 transform bg-blue-600 rounded-md hover:bg-blue-500 focus:outline-none focus:bg-gray-600", children: isEditMode ? "Edit" : "Add" }), _jsx("button", { type: "button", onClick: handleCancelClick, className: "px-8 py-2.5 leading-5 text-white transition-colors duration-300 transform bg-blue-600 rounded-md hover:bg-blue-500 focus:outline-none focus:bg-gray-600", children: "Cancel" })] })] }) }) }));
|
93
85
|
};
|
94
86
|
export default UserForm;
|
@@ -33,14 +33,6 @@ const Users = ({ url }) => {
|
|
33
33
|
};
|
34
34
|
const [currentPage, setCurrentPage] = useState(1);
|
35
35
|
const itemsPerPage = 10;
|
36
|
-
// const filteredUsers = users.filter((user) => {
|
37
|
-
// if (searchTerm.length < 2) return true;
|
38
|
-
// return (
|
39
|
-
// user.name.toLowerCase().includes(searchTerm) ||
|
40
|
-
// user.email.toLowerCase().includes(searchTerm) ||
|
41
|
-
// user.mobile.toString().includes(searchTerm)
|
42
|
-
// );
|
43
|
-
// });
|
44
36
|
const filteredUsers = users.filter((user) => {
|
45
37
|
var _a, _b, _c, _d, _e, _f;
|
46
38
|
if (searchTerm.length < 2)
|
@@ -4,4 +4,4 @@ export declare const fetchUserByIdApi: (url: string, userId: string) => Promise<
|
|
4
4
|
export declare const deleteUserApi: (url: string, id: string) => Promise<{
|
5
5
|
id: string;
|
6
6
|
}>;
|
7
|
-
export declare const updateUserApi: (url: string, id: string, name: string, mobile: string, address: string, roleType: string, gender: string) => Promise<unknown>;
|
7
|
+
export declare const updateUserApi: (url: string, id: string, name: string, email: string, mobile: string, address: string, roleType: string, gender: string) => Promise<unknown>;
|
@@ -85,12 +85,13 @@ export const deleteUserApi = (url, id) => __awaiter(void 0, void 0, void 0, func
|
|
85
85
|
throw error;
|
86
86
|
}
|
87
87
|
});
|
88
|
-
export const updateUserApi = (url, id, name, mobile, address, roleType, gender) => __awaiter(void 0, void 0, void 0, function* () {
|
88
|
+
export const updateUserApi = (url, id, name, email, mobile, address, roleType, gender) => __awaiter(void 0, void 0, void 0, function* () {
|
89
89
|
const token = cookies.get("authToken");
|
90
90
|
try {
|
91
91
|
const response = yield axios.post(`${url}/login/updateuser`, {
|
92
|
-
|
93
|
-
|
92
|
+
Id: id,
|
93
|
+
Name: name,
|
94
|
+
Email: email,
|
94
95
|
Mobile: mobile,
|
95
96
|
Address: address,
|
96
97
|
RoleType: Number(roleType),
|
package/package.json
CHANGED
@@ -15,13 +15,8 @@ const UserForm = ({ url }: UserFormProps) => {
|
|
15
15
|
const [roleType, setRoleType] = useState("");
|
16
16
|
const [gender, setGender] = useState("");
|
17
17
|
|
18
|
-
const [isDisabled, setIsDisabled] = useState(false);
|
19
18
|
const [isEditMode, setIsEditMode] = useState<boolean>(false);
|
20
19
|
|
21
|
-
useEffect(() => {
|
22
|
-
setIsDisabled(isEditMode && !email);
|
23
|
-
}, [isEditMode, email]);
|
24
|
-
|
25
20
|
const validateForm = () => {
|
26
21
|
if (!userName || !roleType) {
|
27
22
|
alert(
|
@@ -75,6 +70,7 @@ const UserForm = ({ url }: UserFormProps) => {
|
|
75
70
|
url,
|
76
71
|
id,
|
77
72
|
userName,
|
73
|
+
email,
|
78
74
|
mobile,
|
79
75
|
address,
|
80
76
|
roleType,
|
@@ -140,14 +136,12 @@ const UserForm = ({ url }: UserFormProps) => {
|
|
140
136
|
</label>
|
141
137
|
<input
|
142
138
|
required
|
143
|
-
|
144
|
-
value={email || ""}
|
139
|
+
value={email}
|
145
140
|
onChange={(e) => setEmail(e.target.value)}
|
146
141
|
type="email"
|
147
142
|
className="w-full px-4 py-2 mt-2 text-gray-800 bg-white border border-gray-400 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-800 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring"
|
148
143
|
placeholder="Enter Email"
|
149
144
|
// disabled={isEditMode}
|
150
|
-
disabled={isDisabled}
|
151
145
|
/>
|
152
146
|
</div>
|
153
147
|
<div className="mb-6 w-full">
|
@@ -35,15 +35,6 @@ const Users = ({ url }: UsersProps) => {
|
|
35
35
|
const [currentPage, setCurrentPage] = useState(1);
|
36
36
|
const itemsPerPage = 10;
|
37
37
|
|
38
|
-
// const filteredUsers = users.filter((user) => {
|
39
|
-
// if (searchTerm.length < 2) return true;
|
40
|
-
// return (
|
41
|
-
// user.name.toLowerCase().includes(searchTerm) ||
|
42
|
-
// user.email.toLowerCase().includes(searchTerm) ||
|
43
|
-
// user.mobile.toString().includes(searchTerm)
|
44
|
-
// );
|
45
|
-
// });
|
46
|
-
|
47
38
|
const filteredUsers = users.filter((user) => {
|
48
39
|
if (searchTerm.length < 2) return true;
|
49
40
|
|
@@ -100,6 +100,7 @@ export const updateUserApi = async (
|
|
100
100
|
|
101
101
|
id: string,
|
102
102
|
name: string,
|
103
|
+
email: string,
|
103
104
|
mobile: string,
|
104
105
|
address: string,
|
105
106
|
roleType: string,
|
@@ -111,8 +112,9 @@ export const updateUserApi = async (
|
|
111
112
|
const response = await axios.post(
|
112
113
|
`${url}/login/updateuser`,
|
113
114
|
{
|
114
|
-
|
115
|
-
|
115
|
+
Id: id,
|
116
|
+
Name: name,
|
117
|
+
Email: email,
|
116
118
|
Mobile: mobile,
|
117
119
|
Address: address,
|
118
120
|
RoleType: Number(roleType),
|