eleven-solutions-common-website-unique-web 20.0.35 → 20.0.37
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.
@@ -19,7 +19,7 @@ const UserForm = ({ url }) => {
|
|
19
19
|
const [gender, setGender] = useState("");
|
20
20
|
const [isEditMode, setIsEditMode] = useState(false);
|
21
21
|
const validateForm = () => {
|
22
|
-
if (!userName || !
|
22
|
+
if (!userName || !roleType) {
|
23
23
|
alert("Please fill in all required fields: User Name, Email, and Role Type.");
|
24
24
|
return false;
|
25
25
|
}
|
@@ -63,7 +63,6 @@ const UserForm = ({ url }) => {
|
|
63
63
|
yield addUserApi(url, userName, email, mobile, address, roleType, gender);
|
64
64
|
alert("User added successfully");
|
65
65
|
}
|
66
|
-
// window.location.href = "/admin/users";
|
67
66
|
window.history.pushState({}, "", "/admin/users");
|
68
67
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
69
68
|
}
|
@@ -82,6 +81,8 @@ const UserForm = ({ url }) => {
|
|
82
81
|
window.history.pushState({}, "", "/admin/users");
|
83
82
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
84
83
|
};
|
85
|
-
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", disabled: isEditMode })] }), _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: [
|
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", disabled: isEditMode })] }), _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,
|
85
|
+
// onChange={(e) => setGender(e.target.value)}
|
86
|
+
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" })] })] }) }) }));
|
86
87
|
};
|
87
88
|
export default UserForm;
|
@@ -33,16 +33,9 @@ const Users = ({ url }) => {
|
|
33
33
|
};
|
34
34
|
const [currentPage, setCurrentPage] = useState(1);
|
35
35
|
const itemsPerPage = 10;
|
36
|
-
// const filteredUsers = users.filter(
|
37
|
-
// (user) =>
|
38
|
-
// (searchTerm.length >= 2 &&
|
39
|
-
// user.name.toLowerCase().includes(searchTerm.toLowerCase())) ||
|
40
|
-
// user.email.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
41
|
-
// user.mobile.toString().includes(searchTerm)
|
42
|
-
// );
|
43
36
|
const filteredUsers = users.filter((user) => {
|
44
37
|
if (searchTerm.length < 2)
|
45
|
-
return true;
|
38
|
+
return true;
|
46
39
|
return (user.name.toLowerCase().includes(searchTerm) ||
|
47
40
|
user.email.toLowerCase().includes(searchTerm) ||
|
48
41
|
user.mobile.toString().includes(searchTerm));
|
@@ -77,15 +70,11 @@ const Users = ({ url }) => {
|
|
77
70
|
window.history.pushState({}, "", path + id);
|
78
71
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
79
72
|
};
|
80
|
-
// const handleSearchChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
81
|
-
// setSearchTerm(event.target.value.toLowerCase());
|
82
|
-
// setCurrentPage(1);
|
83
|
-
// };
|
84
73
|
const handleSearchChange = (event) => {
|
85
74
|
const value = event.target.value.toLowerCase();
|
86
|
-
setSearchTerm(value);
|
75
|
+
setSearchTerm(value);
|
87
76
|
if (value.length < 2) {
|
88
|
-
setCurrentPage(1);
|
77
|
+
setCurrentPage(1);
|
89
78
|
}
|
90
79
|
};
|
91
80
|
const handleSearchSubmit = (event) => {
|
package/package.json
CHANGED
@@ -18,7 +18,7 @@ const UserForm = ({ url }: UserFormProps) => {
|
|
18
18
|
const [isEditMode, setIsEditMode] = useState<boolean>(false);
|
19
19
|
|
20
20
|
const validateForm = () => {
|
21
|
-
if (!userName || !
|
21
|
+
if (!userName || !roleType) {
|
22
22
|
alert(
|
23
23
|
"Please fill in all required fields: User Name, Email, and Role Type."
|
24
24
|
);
|
@@ -88,7 +88,6 @@ const UserForm = ({ url }: UserFormProps) => {
|
|
88
88
|
);
|
89
89
|
alert("User added successfully");
|
90
90
|
}
|
91
|
-
// window.location.href = "/admin/users";
|
92
91
|
window.history.pushState({}, "", "/admin/users");
|
93
92
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
94
93
|
} catch (error) {
|
@@ -173,12 +172,15 @@ const UserForm = ({ url }: UserFormProps) => {
|
|
173
172
|
|
174
173
|
<div className="mb-6 w-full">
|
175
174
|
<label className="text-gray-900 dark:text-gray-200 font-semibold">
|
176
|
-
Gender
|
175
|
+
Gender
|
177
176
|
</label>
|
178
177
|
<select
|
179
178
|
required
|
180
179
|
value={gender}
|
181
|
-
onChange={(e) => setGender(e.target.value)}
|
180
|
+
// onChange={(e) => setGender(e.target.value)}
|
181
|
+
onChange={(e) =>
|
182
|
+
setGender(e.target.value === "" ? null : e.target.value)
|
183
|
+
}
|
182
184
|
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"
|
183
185
|
>
|
184
186
|
<option value="">Select a Gender</option>
|
@@ -35,16 +35,8 @@ const Users = ({ url }: UsersProps) => {
|
|
35
35
|
const [currentPage, setCurrentPage] = useState(1);
|
36
36
|
const itemsPerPage = 10;
|
37
37
|
|
38
|
-
// const filteredUsers = users.filter(
|
39
|
-
// (user) =>
|
40
|
-
// (searchTerm.length >= 2 &&
|
41
|
-
// user.name.toLowerCase().includes(searchTerm.toLowerCase())) ||
|
42
|
-
// user.email.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
43
|
-
// user.mobile.toString().includes(searchTerm)
|
44
|
-
// );
|
45
|
-
|
46
38
|
const filteredUsers = users.filter((user) => {
|
47
|
-
if (searchTerm.length < 2) return true;
|
39
|
+
if (searchTerm.length < 2) return true;
|
48
40
|
return (
|
49
41
|
user.name.toLowerCase().includes(searchTerm) ||
|
50
42
|
user.email.toLowerCase().includes(searchTerm) ||
|
@@ -96,16 +88,11 @@ const Users = ({ url }: UsersProps) => {
|
|
96
88
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
97
89
|
};
|
98
90
|
|
99
|
-
// const handleSearchChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
100
|
-
// setSearchTerm(event.target.value.toLowerCase());
|
101
|
-
// setCurrentPage(1);
|
102
|
-
// };
|
103
|
-
|
104
91
|
const handleSearchChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
105
92
|
const value = event.target.value.toLowerCase();
|
106
|
-
setSearchTerm(value);
|
93
|
+
setSearchTerm(value);
|
107
94
|
if (value.length < 2) {
|
108
|
-
setCurrentPage(1);
|
95
|
+
setCurrentPage(1);
|
109
96
|
}
|
110
97
|
};
|
111
98
|
|