eleven-solutions-common-website-unique-web 22.0.0 → 22.0.2

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.
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { useState, useEffect } from "react";
12
+ import toast from "react-hot-toast";
12
13
  import { addUserApi, updateUserApi, fetchUserByIdApi } from "../api/user";
13
14
  const UserForm = ({ url }) => {
14
15
  const [userName, setUserName] = useState("");
@@ -20,7 +21,7 @@ const UserForm = ({ url }) => {
20
21
  const [isEditMode, setIsEditMode] = useState(false);
21
22
  const validateForm = () => {
22
23
  if (!userName || !roleType) {
23
- alert("Please fill in all required fields: User Name, Email, and Role Type.");
24
+ toast.error("Please fill in all required fields: User Name, Email, and Role Type.");
24
25
  return false;
25
26
  }
26
27
  return true;
@@ -57,18 +58,18 @@ const UserForm = ({ url }) => {
57
58
  try {
58
59
  if (isEditMode) {
59
60
  yield updateUserApi(url, id, userName, email, mobile, address, roleType, gender);
60
- alert("User updated successfully");
61
+ toast.success("User updated successfully");
61
62
  }
62
63
  else {
63
64
  yield addUserApi(url, userName, email, mobile, address, roleType, gender);
64
- alert("User added successfully");
65
+ toast.success("User added successfully");
65
66
  }
66
67
  window.history.pushState({}, "", "/admin/users");
67
68
  window.dispatchEvent(new PopStateEvent("popstate"));
68
69
  }
69
70
  catch (error) {
70
71
  console.error("Error adding/updating User:", error);
71
- alert(isEditMode ? "Failed to Update the User." : "Failed to Add the User.");
72
+ toast.error(isEditMode ? "Failed to Update the User." : "Failed to Add the User.");
72
73
  }
73
74
  });
74
75
  const handleCancelClick = () => {
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { useState, useEffect } from "react";
12
+ import toast from "react-hot-toast";
12
13
  import { FaPlus } from "react-icons/fa";
13
14
  import { fetchUsersApi, deleteUserApi } from "../api/user";
14
15
  const Users = ({ url }) => {
@@ -70,7 +71,7 @@ const Users = ({ url }) => {
70
71
  const handleDeleteClick = (id) => __awaiter(void 0, void 0, void 0, function* () {
71
72
  try {
72
73
  yield deleteUserApi(url, id);
73
- alert("User deleted successfully");
74
+ toast.success("User deleted successfully");
74
75
  fetchUsersData();
75
76
  }
76
77
  catch (error) {
@@ -101,9 +102,15 @@ const Users = ({ url }) => {
101
102
  day: "2-digit",
102
103
  month: "2-digit",
103
104
  year: "numeric",
104
- }) })] }, user.id || index))) })] }) }), _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"] }) }), _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
105
- ? "text-blue-500 bg-blue-100"
106
- : "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: "inset-0 bg-gray-800 bg-opacity-50 z-50 transition-opacity duration-300", children: _jsxs("div", { className: `fixed top-0 right-0 h-full w-[300px] bg-white p-4 rounded-md shadow-lg transform transition-transform duration-500 ease-in-out
105
+ }) })] }, user.id || index))) })] }) }), _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"] }) }), _jsxs("div", { className: "flex items-center justify-between mt-6", children: [_jsxs("button", { disabled: currentPage === 1, onClick: () => setCurrentPage((prev) => Math.max(prev - 1, 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", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5 rtl:-scale-x-100", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "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: Math.min(10, totalPages) }, (_, index) => {
106
+ const startPage = Math.max(1, currentPage - 5);
107
+ const page = startPage + index;
108
+ if (page > totalPages)
109
+ return null;
110
+ return (_jsx("button", { onClick: () => setCurrentPage(page), className: `px-2 py-1 text-sm ${currentPage === page
111
+ ? "text-blue-500 bg-blue-100"
112
+ : "text-gray-500 hover:bg-gray-100"} rounded-md`, children: page }, page));
113
+ }) }), _jsxs("button", { onClick: () => setCurrentPage((prev) => Math.min(prev + 1, totalPages)), 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", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5 rtl:-scale-x-100", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M17.25 8.25L21 12m0 0l-3.75 3.75M21 12H3" }) })] })] })] }), _jsx("div", { className: "inset-0 bg-gray-800 bg-opacity-50 z-50 transition-opacity duration-300", children: _jsxs("div", { className: `fixed top-0 right-0 h-full w-[300px] bg-white p-4 rounded-md shadow-lg transform transition-transform duration-500 ease-in-out
107
114
  ${filterModal ? "translate-x-0" : "translate-x-full"}`, children: [_jsx("h1", { className: "text-2xl md:text-3xl font-bold text-blue-600 mb-4 md:mb-6", children: "Filter" }), _jsx("button", { onClick: () => setFilterModal(false), className: "absolute top-1 right-3 text-gray-400 hover:text-gray-600 text-2xl", children: "\u00D7" }), _jsxs("div", { className: "flex flex-col", children: [_jsxs("div", { className: "mb-4 flex flex-col", children: [_jsx("label", { className: "block text-gray-700 mb-2", children: "Role Type" }), _jsx("div", { className: "w-full", children: _jsxs("select", { value: Number(selectedRoleType), onChange: handleRoleTypeChange, required: true, className: "w-full px-4 py-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: "All" }), _jsx("option", { value: "1", children: "Guest" }), _jsx("option", { value: "2", children: "Admin" })] }) })] }), _jsx("div", { className: "flex flex-row gap-3", children: _jsx("button", { onClick: resetFilter, className: "mt-2 px-4 py-2 bg-blue-500 text-white rounded-md w-32", children: "Reset" }) })] })] }) })] }));
108
115
  };
109
116
  export default Users;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleven-solutions-common-website-unique-web",
3
- "version": "22.0.0",
3
+ "version": "22.0.2",
4
4
  "main": "./dist/index.js",
5
5
  "files": [
6
6
  "dist"
@@ -27,6 +27,7 @@
27
27
  "@reduxjs/toolkit": "^2.3.0",
28
28
  "@tabler/icons-react": "^3.21.0",
29
29
  "jodit-react": "^4.1.2",
30
+ "react-hot-toast": "^2.5.1",
30
31
  "react-icons": "^5.3.0",
31
32
  "react-redux": "^9.1.2",
32
33
  "react-router-dom": "^6.27.0",