eleven-solutions-common-website-unique-web 1.0.30 → 1.0.32
Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { useState, useEffect } from "react";
|
12
12
|
import { FaPlus } from "react-icons/fa";
|
13
13
|
import { fetchUsersApi, deleteUserApi } from "../api/user";
|
14
|
-
function Users(
|
14
|
+
function Users() {
|
15
15
|
const [users, setUsers] = useState([]);
|
16
16
|
const fetchUsersData = () => __awaiter(this, void 0, void 0, function* () {
|
17
17
|
const data = yield fetchUsersApi();
|
@@ -32,6 +32,11 @@ function Users({ handleNav }) {
|
|
32
32
|
// const navEvent = new PopStateEvent("popstate");
|
33
33
|
// window.dispatchEvent(navEvent);
|
34
34
|
// };
|
35
|
+
const handleNavigation = (event, path) => {
|
36
|
+
event.preventDefault();
|
37
|
+
window.history.pushState({}, "", path);
|
38
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
39
|
+
};
|
35
40
|
const [currentPage, setCurrentPage] = useState(1);
|
36
41
|
const itemsPerPage = 10;
|
37
42
|
const totalPages = Math.ceil(users.length / itemsPerPage);
|
@@ -71,6 +76,6 @@ function Users({ handleNav }) {
|
|
71
76
|
window.location.href = `/admin/users/userform?id=${user.id}`; // Manually navigate
|
72
77
|
}, children: _jsx("button", { className: "text-gray-500 transition-colors duration-200 dark:hover:text-yellow-500 dark:text-gray-300 hover:text-yellow-500 focus:outline-none", children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10" }) }) }) })] }) }), _jsx("td", { className: "px-4 py-4 text-sm font-medium text-gray-700 whitespace-nowrap", children: _jsx("div", { className: "inline-flex items-center gap-x-3", children: _jsx("div", { className: "flex items-center gap-x-2", children: _jsx("div", { children: _jsx("h2", { className: " text-sm font-medium text-gray-800 dark:text-white ", children: user.name }) }) }) }) }), _jsx("td", { className: "px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap", children: user.email }), _jsx("td", { className: "px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap", children: (user === null || user === void 0 ? void 0 : user.mobile) || "Not Provided" }), _jsx("td", { className: "px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap", children: (user === null || user === void 0 ? void 0 : user.address) || "Not Provided" }), _jsx("td", { className: "px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap", children: user.roleType === "1" ? "Guest" : "Admin" })] }, user.id || index))) })] }) }), _jsxs("div", { className: "flex items-center justify-between mt-6", children: [_jsxs("button", { onClick: handlePreviousPage, disabled: currentPage === 1, className: "flex items-center px-5 py-2 text-sm text-gray-700 capitalize transition-colors duration-200 bg-white border rounded-md gap-x-2 hover:bg-gray-100 dark:bg-gray-900 dark:text-gray-200 dark:border-gray-700 dark:hover:bg-gray-800", children: [_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", className: "w-5 h-5 rtl:-scale-x-100", children: _jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6.75 15.75L3 12m0 0l3.75-3.75M3 12h18" }) }), _jsx("span", { children: "previous" })] }), _jsx("div", { className: "items-center hidden lg:flex gap-x-3", children: Array.from({ length: totalPages }, (_, index) => (_jsx("button", { onClick: () => handlePageClick(index + 1), className: `px-2 py-1 text-sm ${currentPage === index + 1
|
73
78
|
? "text-blue-500 bg-blue-100"
|
74
|
-
: "text-gray-500 hover:bg-gray-100"} rounded-md`, children: index + 1 }, index + 1))) }), _jsxs("button", { onClick: handleNextPage, disabled: currentPage === totalPages, className: "flex items-center px-5 py-2 text-sm text-gray-700 capitalize transition-colors duration-200 bg-white border rounded-md gap-x-2 hover:bg-gray-100 dark:bg-gray-900 dark:text-gray-200 dark:border-gray-700 dark:hover:bg-gray-800", children: [_jsx("span", { children: "Next" }), _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", className: "w-5 h-5 rtl:-scale-x-100", children: _jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M17.25 8.25L21 12m0 0l-3.75 3.75M21 12H3" }) })] })] }), _jsx("div", { className: "flex-grow ml-0 mt-4 w-0", children: _jsxs("button", { type: "button", onClick:
|
79
|
+
: "text-gray-500 hover:bg-gray-100"} rounded-md`, children: index + 1 }, index + 1))) }), _jsxs("button", { onClick: handleNextPage, disabled: currentPage === totalPages, className: "flex items-center px-5 py-2 text-sm text-gray-700 capitalize transition-colors duration-200 bg-white border rounded-md gap-x-2 hover:bg-gray-100 dark:bg-gray-900 dark:text-gray-200 dark:border-gray-700 dark:hover:bg-gray-800", children: [_jsx("span", { children: "Next" }), _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", className: "w-5 h-5 rtl:-scale-x-100", children: _jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M17.25 8.25L21 12m0 0l-3.75 3.75M21 12H3" }) })] })] }), _jsx("div", { className: "flex-grow ml-0 mt-4 w-0", children: _jsxs("button", { type: "button", onClick: (event) => handleNavigation(event, "/admin/users/userform"), className: "flex items-center justify-center px-6 py-2 font-medium tracking-wide text-white capitalize transition-colors duration-300 transform bg-blue-600 rounded-lg hover:bg-blue-500 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80", children: [_jsx(FaPlus, { className: "mr-2 font-medium" }), "User"] }) })] })] }));
|
75
80
|
}
|
76
81
|
export default Users;
|
package/package.json
CHANGED
@@ -4,10 +4,8 @@ import { useState, useEffect } from "react";
|
|
4
4
|
import { FaPlus } from "react-icons/fa";
|
5
5
|
|
6
6
|
import { fetchUsersApi, deleteUserApi } from "../api/user";
|
7
|
-
|
8
|
-
|
9
|
-
}
|
10
|
-
function Users({ handleNav }: UserProps) {
|
7
|
+
|
8
|
+
function Users() {
|
11
9
|
const [users, setUsers] = useState<any[]>([]);
|
12
10
|
|
13
11
|
const fetchUsersData = async () => {
|
@@ -31,6 +29,12 @@ function Users({ handleNav }: UserProps) {
|
|
31
29
|
// window.dispatchEvent(navEvent);
|
32
30
|
// };
|
33
31
|
|
32
|
+
const handleNavigation = (event: React.MouseEvent, path: string) => {
|
33
|
+
event.preventDefault();
|
34
|
+
window.history.pushState({}, "", path);
|
35
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
36
|
+
};
|
37
|
+
|
34
38
|
const [currentPage, setCurrentPage] = useState(1);
|
35
39
|
const itemsPerPage = 10;
|
36
40
|
|
@@ -342,7 +346,9 @@ function Users({ handleNav }: UserProps) {
|
|
342
346
|
</a> */}
|
343
347
|
<button
|
344
348
|
type="button"
|
345
|
-
onClick={
|
349
|
+
onClick={(event) =>
|
350
|
+
handleNavigation(event, "/admin/users/userform")
|
351
|
+
}
|
346
352
|
className="flex items-center justify-center px-6 py-2 font-medium tracking-wide text-white capitalize transition-colors duration-300 transform bg-blue-600 rounded-lg hover:bg-blue-500 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80"
|
347
353
|
>
|
348
354
|
<FaPlus className="mr-2 font-medium" />
|