eleven-solutions-common-website-unique-web 1.0.28 → 1.0.30
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,76 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
return
|
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
|
+
});
|
4
9
|
};
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
11
|
+
import { useState, useEffect } from "react";
|
12
|
+
import { FaPlus } from "react-icons/fa";
|
13
|
+
import { fetchUsersApi, deleteUserApi } from "../api/user";
|
14
|
+
function Users({ handleNav }) {
|
15
|
+
const [users, setUsers] = useState([]);
|
16
|
+
const fetchUsersData = () => __awaiter(this, void 0, void 0, function* () {
|
17
|
+
const data = yield fetchUsersApi();
|
18
|
+
if (data) {
|
19
|
+
setUsers(data);
|
20
|
+
}
|
21
|
+
else {
|
22
|
+
console.error("Failed to fetch users");
|
23
|
+
}
|
24
|
+
});
|
25
|
+
useEffect(() => {
|
26
|
+
fetchUsersData();
|
27
|
+
}, []);
|
28
|
+
// const handleNav = (e: React.FormEvent) => {
|
29
|
+
// e.preventDefault();
|
30
|
+
// window.history.pushState({}, "", "/admin/users/userform");
|
31
|
+
// // Trigger React's routing logic manually if required
|
32
|
+
// const navEvent = new PopStateEvent("popstate");
|
33
|
+
// window.dispatchEvent(navEvent);
|
34
|
+
// };
|
35
|
+
const [currentPage, setCurrentPage] = useState(1);
|
36
|
+
const itemsPerPage = 10;
|
37
|
+
const totalPages = Math.ceil(users.length / itemsPerPage);
|
38
|
+
const handleNextPage = () => {
|
39
|
+
if (currentPage < totalPages) {
|
40
|
+
setCurrentPage(currentPage + 1);
|
41
|
+
}
|
42
|
+
};
|
43
|
+
const handlePreviousPage = () => {
|
44
|
+
if (currentPage > 1) {
|
45
|
+
setCurrentPage(currentPage - 1);
|
46
|
+
}
|
47
|
+
};
|
48
|
+
const handlePageClick = (pageNumber) => {
|
49
|
+
setCurrentPage(pageNumber);
|
50
|
+
};
|
51
|
+
const paginatedUsers = users.slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage);
|
52
|
+
const handleDeleteClick = (id) => __awaiter(this, void 0, void 0, function* () {
|
53
|
+
try {
|
54
|
+
yield deleteUserApi(id);
|
55
|
+
alert("User deleted successfully");
|
56
|
+
fetchUsersData();
|
57
|
+
}
|
58
|
+
catch (error) {
|
59
|
+
console.error("Error deleting User:", error);
|
60
|
+
}
|
61
|
+
});
|
62
|
+
// const handleEditClick = (id: string) => {
|
63
|
+
// navigate("/admin/user/userform", { state: { id } });
|
64
|
+
// };
|
65
|
+
const handleEditClick = (id) => {
|
66
|
+
return (_jsx("a", { href: `/admin/users/userform?id=${id}`, onClick: (e) => e.preventDefault(), children: "Edit User" }));
|
67
|
+
};
|
68
|
+
return (_jsxs("div", { className: "container px-4 mx-auto mt-6", children: [_jsx("div", { className: "w-3/4", children: _jsx("h1", { className: "text-3xl font-bold text-blue-600 mb-5", children: "Users" }) }), _jsx("div", { className: "flex-grow ml-0 w-full mt-10", children: _jsxs("form", { className: "w-full ", children: [_jsx("label", { htmlFor: "default-search", className: "mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white", children: "Search" }), _jsxs("div", { className: "relative w-full", children: [_jsx("div", { className: "absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none", children: _jsx("svg", { className: "w-4 h-4 text-gray-500 dark:text-gray-400", "aria-hidden": "true", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 20 20", children: _jsx("path", { stroke: "currentColor", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z" }) }) }), _jsx("input", { type: "search", id: "default-search", className: "inline-block min-w-full p-3 ps-10 outline-none text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500", placeholder: "Search Users", required: true }), _jsx("button", { type: "submit", className: "text-white absolute end-1.5 bottom-1.5 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800", children: "Search" })] })] }) }), _jsx("div", { className: "flex-grow ml-0 w-3/4", children: _jsx("form", { className: "w-auto" }) }), _jsxs("div", { className: "flex-grow ml-0 mt-4 w-full", children: [_jsx("div", { className: "overflow-hidden border border-gray-200 dark:border-gray-700 md:rounded-lg mt-6", children: _jsxs("table", { className: "min-w-full divide-y divide-gray-200 dark:divide-gray-700", children: [_jsx("thead", { className: "bg-gray-50 dark:bg-gray-800", children: _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", children: "Edit/Delete" }), _jsx("th", { scope: "col", className: "py-3.5 px-4 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", children: _jsx("div", { className: "flex items-center gap-x-3", children: _jsx("span", { children: "Name" }) }) }), _jsx("th", { scope: "col", className: "px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", children: _jsx("button", { className: "flex items-center gap-x-2", children: _jsx("span", { children: "Email" }) }) }), _jsx("th", { scope: "col", className: "px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", children: _jsx("button", { className: "flex items-center gap-x-2", children: _jsx("span", { children: "Mobile" }) }) }), _jsx("th", { scope: "col", className: "px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", children: "Address" }), _jsx("th", { scope: "col", className: "px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", children: "Role Type" })] }) }), _jsx("tbody", { className: "bg-white divide-y divide-gray-200 dark:divide-gray-700 dark:bg-gray-900", children: paginatedUsers.map((user, index) => (_jsxs("tr", { children: [_jsx("td", { className: "px-4 py-4 text-sm whitespace-nowrap", children: _jsxs("div", { className: "flex items-center gap-x-6", children: [_jsx("button", { onClick: () => handleDeleteClick(user.id), className: "text-gray-500 transition-colors duration-200 dark:hover:text-red-600 dark:text-gray-300 hover:text-red-500 focus:outline-none", 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", children: _jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" }) }) }), _jsx("a", { href: `/admin/users/userform?id=${user.id}`, onClick: (e) => {
|
69
|
+
e.preventDefault(); // Prevent default navigation
|
70
|
+
handleEditClick(user.id); // Trigger the edit functionality
|
71
|
+
window.location.href = `/admin/users/userform?id=${user.id}`; // Manually navigate
|
72
|
+
}, 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
|
+
? "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: handleNav, 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
|
+
}
|
5
76
|
export default Users;
|
package/package.json
CHANGED
@@ -1,358 +1,357 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
// import { FaPlus } from "react-icons/fa";
|
5
|
-
|
6
|
-
// import { fetchUsersApi, deleteUserApi } from "../api/user";
|
7
|
-
// function Users() {
|
8
|
-
// const [users, setUsers] = useState<any[]>([]);
|
1
|
+
import React from "react";
|
2
|
+
import { useState, useEffect } from "react";
|
9
3
|
|
10
|
-
|
11
|
-
// const data = await fetchUsersApi();
|
12
|
-
// if (data) {
|
13
|
-
// setUsers(data as any[]);
|
14
|
-
// } else {
|
15
|
-
// console.error("Failed to fetch users");
|
16
|
-
// }
|
17
|
-
// };
|
4
|
+
import { FaPlus } from "react-icons/fa";
|
18
5
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
// };
|
6
|
+
import { fetchUsersApi, deleteUserApi } from "../api/user";
|
7
|
+
interface UserProps {
|
8
|
+
handleNav: () => void;
|
9
|
+
}
|
10
|
+
function Users({ handleNav }: UserProps) {
|
11
|
+
const [users, setUsers] = useState<any[]>([]);
|
26
12
|
|
27
|
-
|
28
|
-
|
13
|
+
const fetchUsersData = async () => {
|
14
|
+
const data = await fetchUsersApi();
|
15
|
+
if (data) {
|
16
|
+
setUsers(data as any[]);
|
17
|
+
} else {
|
18
|
+
console.error("Failed to fetch users");
|
19
|
+
}
|
20
|
+
};
|
29
21
|
|
30
|
-
|
22
|
+
useEffect(() => {
|
23
|
+
fetchUsersData();
|
24
|
+
}, []);
|
25
|
+
// const handleNav = (e: React.FormEvent) => {
|
26
|
+
// e.preventDefault();
|
27
|
+
// window.history.pushState({}, "", "/admin/users/userform");
|
31
28
|
|
32
|
-
//
|
33
|
-
//
|
34
|
-
//
|
35
|
-
//
|
36
|
-
// };
|
29
|
+
// // Trigger React's routing logic manually if required
|
30
|
+
// const navEvent = new PopStateEvent("popstate");
|
31
|
+
// window.dispatchEvent(navEvent);
|
32
|
+
// };
|
37
33
|
|
38
|
-
|
39
|
-
|
40
|
-
// setCurrentPage(currentPage - 1);
|
41
|
-
// }
|
42
|
-
// };
|
34
|
+
const [currentPage, setCurrentPage] = useState(1);
|
35
|
+
const itemsPerPage = 10;
|
43
36
|
|
44
|
-
|
45
|
-
// setCurrentPage(pageNumber);
|
46
|
-
// };
|
37
|
+
const totalPages = Math.ceil(users.length / itemsPerPage);
|
47
38
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
39
|
+
const handleNextPage = () => {
|
40
|
+
if (currentPage < totalPages) {
|
41
|
+
setCurrentPage(currentPage + 1);
|
42
|
+
}
|
43
|
+
};
|
52
44
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
45
|
+
const handlePreviousPage = () => {
|
46
|
+
if (currentPage > 1) {
|
47
|
+
setCurrentPage(currentPage - 1);
|
48
|
+
}
|
49
|
+
};
|
57
50
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
// }
|
62
|
-
// };
|
51
|
+
const handlePageClick = (pageNumber: number) => {
|
52
|
+
setCurrentPage(pageNumber);
|
53
|
+
};
|
63
54
|
|
64
|
-
|
65
|
-
|
66
|
-
|
55
|
+
const paginatedUsers = users.slice(
|
56
|
+
(currentPage - 1) * itemsPerPage,
|
57
|
+
currentPage * itemsPerPage
|
58
|
+
);
|
67
59
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
// onClick={(e) => e.preventDefault()}
|
73
|
-
// >
|
74
|
-
// Edit User
|
75
|
-
// </a>
|
76
|
-
// );
|
77
|
-
// };
|
60
|
+
const handleDeleteClick = async (id: string) => {
|
61
|
+
try {
|
62
|
+
await deleteUserApi(id);
|
63
|
+
alert("User deleted successfully");
|
78
64
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
// <div className="flex-grow ml-0 w-full mt-10">
|
85
|
-
// <form className="w-full ">
|
86
|
-
// <label
|
87
|
-
// htmlFor="default-search"
|
88
|
-
// className="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white"
|
89
|
-
// >
|
90
|
-
// Search
|
91
|
-
// </label>
|
92
|
-
// <div className="relative w-full">
|
93
|
-
// <div className="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
|
94
|
-
// <svg
|
95
|
-
// className="w-4 h-4 text-gray-500 dark:text-gray-400"
|
96
|
-
// aria-hidden="true"
|
97
|
-
// xmlns="http://www.w3.org/2000/svg"
|
98
|
-
// fill="none"
|
99
|
-
// viewBox="0 0 20 20"
|
100
|
-
// >
|
101
|
-
// <path
|
102
|
-
// stroke="currentColor"
|
103
|
-
// stroke-linecap="round"
|
104
|
-
// stroke-linejoin="round"
|
105
|
-
// stroke-width="2"
|
106
|
-
// d="m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z"
|
107
|
-
// />
|
108
|
-
// </svg>
|
109
|
-
// </div>
|
110
|
-
// <input
|
111
|
-
// type="search"
|
112
|
-
// id="default-search"
|
113
|
-
// className="inline-block min-w-full p-3 ps-10 outline-none text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
114
|
-
// placeholder="Search Users"
|
115
|
-
// required
|
116
|
-
// />
|
117
|
-
// <button
|
118
|
-
// type="submit"
|
119
|
-
// className="text-white absolute end-1.5 bottom-1.5 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
|
120
|
-
// >
|
121
|
-
// Search
|
122
|
-
// </button>
|
123
|
-
// </div>
|
124
|
-
// </form>
|
125
|
-
// </div>
|
126
|
-
// <div className="flex-grow ml-0 w-3/4">
|
127
|
-
// <form className="w-auto">{/* Search Form */}</form>
|
128
|
-
// </div>
|
129
|
-
// <div className="flex-grow ml-0 mt-4 w-full">
|
130
|
-
// <div className="overflow-hidden border border-gray-200 dark:border-gray-700 md:rounded-lg mt-6">
|
131
|
-
// <table className="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
|
132
|
-
// <thead className="bg-gray-50 dark:bg-gray-800">
|
133
|
-
// <tr>
|
134
|
-
// <th
|
135
|
-
// scope="col"
|
136
|
-
// className="px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400"
|
137
|
-
// >
|
138
|
-
// Edit/Delete
|
139
|
-
// </th>
|
140
|
-
// <th
|
141
|
-
// scope="col"
|
142
|
-
// className="py-3.5 px-4 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400"
|
143
|
-
// >
|
144
|
-
// <div className="flex items-center gap-x-3">
|
145
|
-
// <span>Name</span>
|
146
|
-
// </div>
|
147
|
-
// </th>
|
65
|
+
fetchUsersData();
|
66
|
+
} catch (error) {
|
67
|
+
console.error("Error deleting User:", error);
|
68
|
+
}
|
69
|
+
};
|
148
70
|
|
149
|
-
//
|
150
|
-
//
|
151
|
-
//
|
152
|
-
// >
|
153
|
-
// <button className="flex items-center gap-x-2">
|
154
|
-
// <span>Email</span>
|
155
|
-
// </button>
|
156
|
-
// </th>
|
71
|
+
// const handleEditClick = (id: string) => {
|
72
|
+
// navigate("/admin/user/userform", { state: { id } });
|
73
|
+
// };
|
157
74
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
75
|
+
const handleEditClick = (id: string) => {
|
76
|
+
return (
|
77
|
+
<a
|
78
|
+
href={`/admin/users/userform?id=${id}`}
|
79
|
+
onClick={(e) => e.preventDefault()}
|
80
|
+
>
|
81
|
+
Edit User
|
82
|
+
</a>
|
83
|
+
);
|
84
|
+
};
|
166
85
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
86
|
+
return (
|
87
|
+
<div className="container px-4 mx-auto mt-6">
|
88
|
+
<div className="w-3/4">
|
89
|
+
<h1 className="text-3xl font-bold text-blue-600 mb-5">Users</h1>
|
90
|
+
</div>
|
91
|
+
<div className="flex-grow ml-0 w-full mt-10">
|
92
|
+
<form className="w-full ">
|
93
|
+
<label
|
94
|
+
htmlFor="default-search"
|
95
|
+
className="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white"
|
96
|
+
>
|
97
|
+
Search
|
98
|
+
</label>
|
99
|
+
<div className="relative w-full">
|
100
|
+
<div className="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
|
101
|
+
<svg
|
102
|
+
className="w-4 h-4 text-gray-500 dark:text-gray-400"
|
103
|
+
aria-hidden="true"
|
104
|
+
xmlns="http://www.w3.org/2000/svg"
|
105
|
+
fill="none"
|
106
|
+
viewBox="0 0 20 20"
|
107
|
+
>
|
108
|
+
<path
|
109
|
+
stroke="currentColor"
|
110
|
+
stroke-linecap="round"
|
111
|
+
stroke-linejoin="round"
|
112
|
+
stroke-width="2"
|
113
|
+
d="m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z"
|
114
|
+
/>
|
115
|
+
</svg>
|
116
|
+
</div>
|
117
|
+
<input
|
118
|
+
type="search"
|
119
|
+
id="default-search"
|
120
|
+
className="inline-block min-w-full p-3 ps-10 outline-none text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
121
|
+
placeholder="Search Users"
|
122
|
+
required
|
123
|
+
/>
|
124
|
+
<button
|
125
|
+
type="submit"
|
126
|
+
className="text-white absolute end-1.5 bottom-1.5 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
|
127
|
+
>
|
128
|
+
Search
|
129
|
+
</button>
|
130
|
+
</div>
|
131
|
+
</form>
|
132
|
+
</div>
|
133
|
+
<div className="flex-grow ml-0 w-3/4">
|
134
|
+
<form className="w-auto">{/* Search Form */}</form>
|
135
|
+
</div>
|
136
|
+
<div className="flex-grow ml-0 mt-4 w-full">
|
137
|
+
<div className="overflow-hidden border border-gray-200 dark:border-gray-700 md:rounded-lg mt-6">
|
138
|
+
<table className="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
|
139
|
+
<thead className="bg-gray-50 dark:bg-gray-800">
|
140
|
+
<tr>
|
141
|
+
<th
|
142
|
+
scope="col"
|
143
|
+
className="px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400"
|
144
|
+
>
|
145
|
+
Edit/Delete
|
146
|
+
</th>
|
147
|
+
<th
|
148
|
+
scope="col"
|
149
|
+
className="py-3.5 px-4 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400"
|
150
|
+
>
|
151
|
+
<div className="flex items-center gap-x-3">
|
152
|
+
<span>Name</span>
|
153
|
+
</div>
|
154
|
+
</th>
|
173
155
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
// <tbody className="bg-white divide-y divide-gray-200 dark:divide-gray-700 dark:bg-gray-900">
|
183
|
-
// {paginatedUsers.map((user, index) => (
|
184
|
-
// <tr key={user.id || index}>
|
185
|
-
// <td className="px-4 py-4 text-sm whitespace-nowrap">
|
186
|
-
// <div className="flex items-center gap-x-6">
|
187
|
-
// <button
|
188
|
-
// onClick={() => handleDeleteClick(user.id)}
|
189
|
-
// className="text-gray-500 transition-colors duration-200 dark:hover:text-red-600 dark:text-gray-300 hover:text-red-500 focus:outline-none"
|
190
|
-
// >
|
191
|
-
// <svg
|
192
|
-
// xmlns="http://www.w3.org/2000/svg"
|
193
|
-
// fill="none"
|
194
|
-
// viewBox="0 0 24 24"
|
195
|
-
// stroke-width="1.5"
|
196
|
-
// stroke="currentColor"
|
197
|
-
// className="w-5 h-5"
|
198
|
-
// >
|
199
|
-
// <path
|
200
|
-
// stroke-linecap="round"
|
201
|
-
// stroke-linejoin="round"
|
202
|
-
// d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
|
203
|
-
// />
|
204
|
-
// </svg>
|
205
|
-
// </button>
|
156
|
+
<th
|
157
|
+
scope="col"
|
158
|
+
className="px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400"
|
159
|
+
>
|
160
|
+
<button className="flex items-center gap-x-2">
|
161
|
+
<span>Email</span>
|
162
|
+
</button>
|
163
|
+
</th>
|
206
164
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
// <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">
|
216
|
-
// <svg
|
217
|
-
// xmlns="http://www.w3.org/2000/svg"
|
218
|
-
// fill="none"
|
219
|
-
// viewBox="0 0 24 24"
|
220
|
-
// strokeWidth="1.5"
|
221
|
-
// stroke="currentColor"
|
222
|
-
// className="w-5 h-5"
|
223
|
-
// >
|
224
|
-
// <path
|
225
|
-
// strokeLinecap="round"
|
226
|
-
// strokeLinejoin="round"
|
227
|
-
// 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"
|
228
|
-
// />
|
229
|
-
// </svg>
|
230
|
-
// </button>
|
231
|
-
// </a>
|
232
|
-
// </div>
|
233
|
-
// </td>
|
234
|
-
// <td className="px-4 py-4 text-sm font-medium text-gray-700 whitespace-nowrap">
|
235
|
-
// <div className="inline-flex items-center gap-x-3">
|
236
|
-
// <div className="flex items-center gap-x-2">
|
237
|
-
// <div>
|
238
|
-
// <h2 className=" text-sm font-medium text-gray-800 dark:text-white ">
|
239
|
-
// {user.name}
|
240
|
-
// </h2>
|
241
|
-
// </div>
|
242
|
-
// </div>
|
243
|
-
// </div>
|
244
|
-
// </td>
|
245
|
-
// <td className="px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap">
|
246
|
-
// {user.email}
|
247
|
-
// </td>
|
248
|
-
// <td className="px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap">
|
249
|
-
// {user?.mobile || "Not Provided"}
|
250
|
-
// </td>
|
251
|
-
// <td className="px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap">
|
252
|
-
// {user?.address || "Not Provided"}
|
253
|
-
// </td>
|
254
|
-
// <td className="px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap">
|
255
|
-
// {user.roleType === "1" ? "Guest" : "Admin"}
|
256
|
-
// </td>
|
257
|
-
// </tr>
|
258
|
-
// ))}
|
259
|
-
// </tbody>
|
260
|
-
// </table>
|
261
|
-
// </div>
|
165
|
+
<th
|
166
|
+
scope="col"
|
167
|
+
className="px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400"
|
168
|
+
>
|
169
|
+
<button className="flex items-center gap-x-2">
|
170
|
+
<span>Mobile</span>
|
171
|
+
</button>
|
172
|
+
</th>
|
262
173
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
// <svg
|
270
|
-
// xmlns="http://www.w3.org/2000/svg"
|
271
|
-
// fill="none"
|
272
|
-
// viewBox="0 0 24 24"
|
273
|
-
// stroke-width="1.5"
|
274
|
-
// stroke="currentColor"
|
275
|
-
// className="w-5 h-5 rtl:-scale-x-100"
|
276
|
-
// >
|
277
|
-
// <path
|
278
|
-
// stroke-linecap="round"
|
279
|
-
// stroke-linejoin="round"
|
280
|
-
// d="M6.75 15.75L3 12m0 0l3.75-3.75M3 12h18"
|
281
|
-
// />
|
282
|
-
// </svg>
|
174
|
+
<th
|
175
|
+
scope="col"
|
176
|
+
className="px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400"
|
177
|
+
>
|
178
|
+
Address
|
179
|
+
</th>
|
283
180
|
|
284
|
-
|
285
|
-
|
181
|
+
<th
|
182
|
+
scope="col"
|
183
|
+
className="px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400"
|
184
|
+
>
|
185
|
+
Role Type
|
186
|
+
</th>
|
187
|
+
</tr>
|
188
|
+
</thead>
|
189
|
+
<tbody className="bg-white divide-y divide-gray-200 dark:divide-gray-700 dark:bg-gray-900">
|
190
|
+
{paginatedUsers.map((user, index) => (
|
191
|
+
<tr key={user.id || index}>
|
192
|
+
<td className="px-4 py-4 text-sm whitespace-nowrap">
|
193
|
+
<div className="flex items-center gap-x-6">
|
194
|
+
<button
|
195
|
+
onClick={() => handleDeleteClick(user.id)}
|
196
|
+
className="text-gray-500 transition-colors duration-200 dark:hover:text-red-600 dark:text-gray-300 hover:text-red-500 focus:outline-none"
|
197
|
+
>
|
198
|
+
<svg
|
199
|
+
xmlns="http://www.w3.org/2000/svg"
|
200
|
+
fill="none"
|
201
|
+
viewBox="0 0 24 24"
|
202
|
+
stroke-width="1.5"
|
203
|
+
stroke="currentColor"
|
204
|
+
className="w-5 h-5"
|
205
|
+
>
|
206
|
+
<path
|
207
|
+
stroke-linecap="round"
|
208
|
+
stroke-linejoin="round"
|
209
|
+
d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
|
210
|
+
/>
|
211
|
+
</svg>
|
212
|
+
</button>
|
286
213
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
//
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
214
|
+
<a
|
215
|
+
href={`/admin/users/userform?id=${user.id}`}
|
216
|
+
onClick={(e) => {
|
217
|
+
e.preventDefault(); // Prevent default navigation
|
218
|
+
handleEditClick(user.id); // Trigger the edit functionality
|
219
|
+
window.location.href = `/admin/users/userform?id=${user.id}`; // Manually navigate
|
220
|
+
}}
|
221
|
+
>
|
222
|
+
<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">
|
223
|
+
<svg
|
224
|
+
xmlns="http://www.w3.org/2000/svg"
|
225
|
+
fill="none"
|
226
|
+
viewBox="0 0 24 24"
|
227
|
+
strokeWidth="1.5"
|
228
|
+
stroke="currentColor"
|
229
|
+
className="w-5 h-5"
|
230
|
+
>
|
231
|
+
<path
|
232
|
+
strokeLinecap="round"
|
233
|
+
strokeLinejoin="round"
|
234
|
+
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"
|
235
|
+
/>
|
236
|
+
</svg>
|
237
|
+
</button>
|
238
|
+
</a>
|
239
|
+
</div>
|
240
|
+
</td>
|
241
|
+
<td className="px-4 py-4 text-sm font-medium text-gray-700 whitespace-nowrap">
|
242
|
+
<div className="inline-flex items-center gap-x-3">
|
243
|
+
<div className="flex items-center gap-x-2">
|
244
|
+
<div>
|
245
|
+
<h2 className=" text-sm font-medium text-gray-800 dark:text-white ">
|
246
|
+
{user.name}
|
247
|
+
</h2>
|
248
|
+
</div>
|
249
|
+
</div>
|
250
|
+
</div>
|
251
|
+
</td>
|
252
|
+
<td className="px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap">
|
253
|
+
{user.email}
|
254
|
+
</td>
|
255
|
+
<td className="px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap">
|
256
|
+
{user?.mobile || "Not Provided"}
|
257
|
+
</td>
|
258
|
+
<td className="px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap">
|
259
|
+
{user?.address || "Not Provided"}
|
260
|
+
</td>
|
261
|
+
<td className="px-4 py-4 text-sm text-gray-500 dark:text-gray-300 whitespace-nowrap">
|
262
|
+
{user.roleType === "1" ? "Guest" : "Admin"}
|
263
|
+
</td>
|
264
|
+
</tr>
|
265
|
+
))}
|
266
|
+
</tbody>
|
267
|
+
</table>
|
268
|
+
</div>
|
308
269
|
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
270
|
+
<div className="flex items-center justify-between mt-6">
|
271
|
+
<button
|
272
|
+
onClick={handlePreviousPage}
|
273
|
+
disabled={currentPage === 1}
|
274
|
+
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"
|
275
|
+
>
|
276
|
+
<svg
|
277
|
+
xmlns="http://www.w3.org/2000/svg"
|
278
|
+
fill="none"
|
279
|
+
viewBox="0 0 24 24"
|
280
|
+
stroke-width="1.5"
|
281
|
+
stroke="currentColor"
|
282
|
+
className="w-5 h-5 rtl:-scale-x-100"
|
283
|
+
>
|
284
|
+
<path
|
285
|
+
stroke-linecap="round"
|
286
|
+
stroke-linejoin="round"
|
287
|
+
d="M6.75 15.75L3 12m0 0l3.75-3.75M3 12h18"
|
288
|
+
/>
|
289
|
+
</svg>
|
325
290
|
|
326
|
-
|
327
|
-
|
328
|
-
// <button
|
329
|
-
// type="button"
|
330
|
-
// 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"
|
331
|
-
// >
|
332
|
-
// <FaPlus className="mr-2 font-medium" />
|
333
|
-
// User
|
334
|
-
// </button>
|
335
|
-
// </a> */}
|
336
|
-
// <button
|
337
|
-
// type="button"
|
338
|
-
// onClick={handleNav}
|
339
|
-
// 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"
|
340
|
-
// >
|
341
|
-
// <FaPlus className="mr-2 font-medium" />
|
342
|
-
// User
|
343
|
-
// </button>
|
344
|
-
// </div>
|
345
|
-
// </div>
|
346
|
-
// </div>
|
347
|
-
// );
|
348
|
-
// }
|
291
|
+
<span>previous</span>
|
292
|
+
</button>
|
349
293
|
|
350
|
-
|
294
|
+
<div className="items-center hidden lg:flex gap-x-3">
|
295
|
+
{Array.from({ length: totalPages }, (_, index) => (
|
296
|
+
<button
|
297
|
+
key={index + 1}
|
298
|
+
onClick={() => handlePageClick(index + 1)}
|
299
|
+
className={`px-2 py-1 text-sm ${
|
300
|
+
currentPage === index + 1
|
301
|
+
? "text-blue-500 bg-blue-100"
|
302
|
+
: "text-gray-500 hover:bg-gray-100"
|
303
|
+
} rounded-md`}
|
304
|
+
>
|
305
|
+
{index + 1}
|
306
|
+
</button>
|
307
|
+
))}
|
308
|
+
</div>
|
309
|
+
<button
|
310
|
+
onClick={handleNextPage}
|
311
|
+
disabled={currentPage === totalPages}
|
312
|
+
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"
|
313
|
+
>
|
314
|
+
<span>Next</span>
|
351
315
|
|
352
|
-
|
316
|
+
<svg
|
317
|
+
xmlns="http://www.w3.org/2000/svg"
|
318
|
+
fill="none"
|
319
|
+
viewBox="0 0 24 24"
|
320
|
+
stroke-width="1.5"
|
321
|
+
stroke="currentColor"
|
322
|
+
className="w-5 h-5 rtl:-scale-x-100"
|
323
|
+
>
|
324
|
+
<path
|
325
|
+
stroke-linecap="round"
|
326
|
+
stroke-linejoin="round"
|
327
|
+
d="M17.25 8.25L21 12m0 0l-3.75 3.75M21 12H3"
|
328
|
+
/>
|
329
|
+
</svg>
|
330
|
+
</button>
|
331
|
+
</div>
|
353
332
|
|
354
|
-
|
355
|
-
|
356
|
-
|
333
|
+
<div className="flex-grow ml-0 mt-4 w-0">
|
334
|
+
{/* <a href="/admin/users/userform">
|
335
|
+
<button
|
336
|
+
type="button"
|
337
|
+
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"
|
338
|
+
>
|
339
|
+
<FaPlus className="mr-2 font-medium" />
|
340
|
+
User
|
341
|
+
</button>
|
342
|
+
</a> */}
|
343
|
+
<button
|
344
|
+
type="button"
|
345
|
+
onClick={handleNav}
|
346
|
+
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
|
+
>
|
348
|
+
<FaPlus className="mr-2 font-medium" />
|
349
|
+
User
|
350
|
+
</button>
|
351
|
+
</div>
|
352
|
+
</div>
|
353
|
+
</div>
|
354
|
+
);
|
355
|
+
}
|
357
356
|
|
358
357
|
export default Users;
|