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

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,7 @@ import React from "react";
12
12
  import { useState, useEffect } from "react";
13
13
  import { addTaxonomyApi, fetchTaxonomyByIdApi, updateTaxonomyApi, fetchTaxonomiessApi, deleteTaxonomyApi, addSubTypeApi, } from "../api/taxonomy";
14
14
  import { FaPlus } from "react-icons/fa";
15
+ import toast from "react-hot-toast";
15
16
  const TaxonomyForm = ({ url }) => {
16
17
  const [type, setType] = useState("");
17
18
  const [code, setCode] = useState("");
@@ -51,7 +52,7 @@ const TaxonomyForm = ({ url }) => {
51
52
  const handleDeleteSubTypeClick = (id) => __awaiter(void 0, void 0, void 0, function* () {
52
53
  try {
53
54
  yield deleteTaxonomyApi(url, id);
54
- alert("Taxonomy deleted successfully");
55
+ toast.success("Taxonomy deleted successfully");
55
56
  const fetchedTaxonomies = yield fetchTaxonomiessApi(url);
56
57
  if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
57
58
  setAllTaxonomies(fetchedTaxonomies);
@@ -59,7 +60,7 @@ const TaxonomyForm = ({ url }) => {
59
60
  }
60
61
  catch (error) {
61
62
  console.error("Error deleting Taxonomy:", error);
62
- alert("Error deleting Taxonomy: " + error.message);
63
+ toast.error("Error deleting Taxonomy: " + error.message);
63
64
  }
64
65
  });
65
66
  const [editTaxonomyItem, setEditTaxonomyItem] = useState(null);
@@ -152,17 +153,17 @@ const TaxonomyForm = ({ url }) => {
152
153
  const handleSubTypeSubmitClick = () => __awaiter(void 0, void 0, void 0, function* () {
153
154
  var _a, _b;
154
155
  if (!subCode || !subValue) {
155
- alert("Please fill out both Code and Value fields before proceeding.");
156
+ toast.error("Please fill out both Code and Value fields before proceeding.");
156
157
  return;
157
158
  }
158
159
  try {
159
160
  if (editTaxonomyItem) {
160
161
  yield updateTaxonomyApi(url, selectedTaxonomyId, type, Number(subCode), subValue);
161
- alert("SubType edited successfully");
162
+ toast.success("SubType edited successfully");
162
163
  }
163
164
  else {
164
165
  yield addSubTypeApi(url, selectedTaxonomyId, type, Number(subCode), subValue);
165
- alert("SubType added successfully");
166
+ toast.success("SubType added successfully");
166
167
  }
167
168
  const fetchedTaxonomies = yield fetchTaxonomiessApi(url);
168
169
  if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
@@ -172,7 +173,7 @@ const TaxonomyForm = ({ url }) => {
172
173
  catch (error) {
173
174
  console.error(`Error ${editTaxonomyItem ? "editing" : "adding"} SubType:`, error);
174
175
  const errorMessage = ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || ((_b = error.response) === null || _b === void 0 ? void 0 : _b.statusText) || error.message;
175
- alert(`Error while ${editTaxonomyItem ? "editing" : "adding"} SubType: ${errorMessage}`);
176
+ toast.error(`Error while ${editTaxonomyItem ? "editing" : "adding"} SubType: ${errorMessage}`);
176
177
  setNewCode("");
177
178
  setNewValue("");
178
179
  }
@@ -191,17 +192,17 @@ const TaxonomyForm = ({ url }) => {
191
192
  const handleSubmitClick = () => __awaiter(void 0, void 0, void 0, function* () {
192
193
  var _a, _b;
193
194
  if (!newCode || !newValue) {
194
- alert("Please fill out both Code and Value fields before submitting.");
195
+ toast.error("Please fill out both Code and Value fields before submitting.");
195
196
  return;
196
197
  }
197
198
  try {
198
199
  if (editTaxonomyItem) {
199
200
  yield updateTaxonomyApi(url, selectedTaxonomyId, type, Number(newCode), newValue);
200
- alert("Taxonomy updated successfully");
201
+ toast.success("Taxonomy updated successfully");
201
202
  }
202
203
  else {
203
204
  yield addTaxonomyApi(url, type, Number(newCode), newValue);
204
- alert("Value added successfully");
205
+ toast.success("Value added successfully");
205
206
  }
206
207
  const response = yield fetchTaxonomiessApi(url);
207
208
  const filteredTaxonomies = response.filter((taxonomy) => taxonomy.type === type);
@@ -210,7 +211,7 @@ const TaxonomyForm = ({ url }) => {
210
211
  catch (error) {
211
212
  console.error(editTaxonomyItem ? "Error updating Taxonomy:" : "Error adding value:", error);
212
213
  const errorMessage = ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || ((_b = error.response) === null || _b === void 0 ? void 0 : _b.statusText) || error.message;
213
- alert(`Error while ${editTaxonomyItem ? "editing" : "adding"} SubType: ${errorMessage}`);
214
+ toast.error(`Error while ${editTaxonomyItem ? "editing" : "adding"} SubType: ${errorMessage}`);
214
215
  setNewCode("");
215
216
  setNewValue("");
216
217
  }
@@ -221,7 +222,7 @@ const TaxonomyForm = ({ url }) => {
221
222
  const handleDeleteClick = (id) => __awaiter(void 0, void 0, void 0, function* () {
222
223
  try {
223
224
  yield deleteTaxonomyApi(url, id);
224
- alert("Taxonomy deleted successfully");
225
+ toast.success("Taxonomy deleted successfully");
225
226
  setSimilarTaxonomies((prevTaxonomies) => prevTaxonomies.filter((taxonomy) => taxonomy.id !== id));
226
227
  }
227
228
  catch (error) {
@@ -229,7 +230,7 @@ const TaxonomyForm = ({ url }) => {
229
230
  }
230
231
  });
231
232
  const parentTaxonomies = similarTaxonomies.filter((taxonomy) => !taxonomy.parentId);
232
- return (_jsxs("div", { className: `${isEditMode ? "w-full" : "max-w-4xl"} p-6 mx-auto dark:bg-gray-800`, children: [_jsxs("div", { className: `transition duration-300 ${isModalOpen ? "filter blur-sm" : ""}`, children: [_jsx("h1", { className: "text-3xl font-bold text-center text-blue-600 capitalize dark:text-white mb-4", children: isEditMode ? "Edit Taxonomy" : "Add Taxonomy" }), _jsx("h4", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: isEditMode ? `Taxonomy Type: ${type}` : "" }), isSimilarTaxonomyOpen && isEditMode && (_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", style: { width: "200px" }, children: "Actions" }), _jsx("th", { className: "px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", children: "Code" }), _jsx("th", { className: "px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", children: "Value" })] }) }), _jsx("tbody", { className: "divide-y divide-gray-200", children: parentTaxonomies.map((taxonomy, index) => {
233
+ return (_jsxs("div", { className: `${isEditMode ? "w-full" : "max-w-4xl"} p-6 mx-auto dark:bg-gray-800`, children: [_jsxs("div", { className: `transition duration-300 ${isModalOpen ? "filter blur-sm" : ""}`, children: [_jsx("h1", { className: "text-3xl font-bold text-blue-600 capitalize dark:text-white mb-4", children: isEditMode ? "Edit Taxonomy" : "Add Taxonomy" }), _jsx("h4", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: isEditMode ? `Taxonomy Type: ${type}` : "" }), isSimilarTaxonomyOpen && isEditMode && (_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", style: { width: "200px" }, children: "Actions" }), _jsx("th", { className: "px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", children: "Code" }), _jsx("th", { className: "px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", children: "Value" })] }) }), _jsx("tbody", { className: "divide-y divide-gray-200", children: parentTaxonomies.map((taxonomy, index) => {
233
234
  const hasChildren = allTaxonomies.some((item) => item.parentId === taxonomy.id);
234
235
  return (_jsxs(React.Fragment, { children: [_jsxs("tr", { children: [_jsx("td", { className: "px-4 py-4 text-sm whitespace-nowrap", children: taxonomy.isEdit && (_jsxs("div", { className: "flex items-center gap-x-6", children: [_jsx("button", { type: "button", onClick: () => handleDeleteClick(taxonomy.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", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "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("button", { type: "button", onClick: () => handleEditClick(index, taxonomy.id), 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("button", { type: "button", onClick: () => handleAddSubType(index, taxonomy.id), className: "text-gray-500 transition-colors duration-200 dark:hover:text-blue-500 dark:text-gray-300 hover:text-blue-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: "M12 4.5v15m7.5-7.5h-15" }) }) }), hasChildren && (_jsx("button", { type: "button", onClick: () => toggleRowExpansion(taxonomy.id), className: "text-gray-500 transition-colors duration-200 dark:hover:text-blue-600 dark:text-gray-300 hover:text-blue-500 focus:outline-none", children: expandedRows.indexOf(taxonomy.id) !==
235
236
  -1 ? (_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: "M19.5 15.75l-7.5-7.5-7.5 7.5" }) })) : (_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: "M19.5 8.25l-7.5 7.5-7.5-7.5" }) })) }))] })) }), _jsx("td", { className: "px-4 py-4 text-sm text-gray-500 dark:text-gray-400", children: taxonomy.code }), _jsx("td", { className: "px-4 py-4 text-sm font-medium text-gray-900 dark:text-white", children: _jsx("div", { className: "flex justify-between items-center", children: _jsx("span", { children: taxonomy.value }) }) })] }, index), expandedRows.indexOf(taxonomy.id) !== -1 && (_jsx("tr", { children: _jsx("td", { colSpan: 3, children: _jsxs("table", { className: "min-w-full divide-y ", children: [_jsx("thead", { className: "bg-gray-50 dark:bg-gray-800", children: _jsxs("tr", { children: [similarTaxonomies.some((taxonomy) => taxonomy.isEdit) && (_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", style: { width: "200px" }, children: "Actions" })), _jsx("th", { scope: "col", style: { width: "350px" }, className: "px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400 w-[23%]", children: "Code" }), _jsx("th", { className: "px-4 py-3.5 text-md font-normal text-left rtl:text-right text-gray-500 dark:text-gray-400", children: "Value" })] }) }), _jsx("tbody", { children: allTaxonomies
@@ -11,6 +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 { fetchTemplatesApi, deleteTemplateApi } from "../api/template";
14
+ import toast from "react-hot-toast";
14
15
  const Template = ({ url }) => {
15
16
  const [templates, setTemplates] = useState([]);
16
17
  const fetchTemplatesData = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -56,7 +57,7 @@ const Template = ({ url }) => {
56
57
  const handleDeleteClick = (id) => __awaiter(void 0, void 0, void 0, function* () {
57
58
  try {
58
59
  yield deleteTemplateApi(url, id);
59
- alert("Template deleted successfully");
60
+ toast.success("Template deleted successfully");
60
61
  fetchTemplatesData();
61
62
  }
62
63
  catch (error) {
@@ -65,8 +66,8 @@ const Template = ({ url }) => {
65
66
  });
66
67
  return (_jsxs("div", { className: "container px-4 mx-auto mt-6 h-full", children: [_jsx("div", { className: "w-3/4", children: _jsx("h1", { className: "text-3xl font-bold text-blue-600 mb-5", children: "Template" }) }), _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 Templates", 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", style: { width: "200px" }, children: "Actions" }), _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("tbody", { className: "bg-white divide-y divide-gray-200 dark:divide-gray-700 dark:bg-gray-900", children: paginatedTemplates
67
68
  .filter((template) => !template.isDeleted)
68
- .map((template, 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(template.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("button", { onClick: (event) => handleEditClick(event, "/admin/template/templateform?id=", template.id), 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: template.name }) }) }) }) })] }, template.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
69
+ .map((template, 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(template.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("button", { onClick: (event) => handleEditClick(event, "/admin/template/templateform?id=", template.id), 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: template.name }) }) }) }) })] }, template.id || index))) })] }) }), _jsx("div", { className: "flex-grow ml-0 mt-4 w-0", children: _jsxs("button", { type: "button", onClick: (event) => handleNavigation(event, "/admin/template/templateform"), 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" }), "Template"] }) }), _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
69
70
  ? "text-blue-500 bg-blue-100"
70
- : "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/template/templateform"), 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" }), "Template"] }) })] })] }));
71
+ : "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" }) })] })] })] })] }));
71
72
  };
72
73
  export default Template;
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { useState, useEffect, useRef, useMemo } from "react";
12
12
  import { addTemplateApi, fetchTemplateByIdApi, updateTemplateApi, } from "../api/template";
13
+ import toast from "react-hot-toast";
13
14
  import Editor from "./Editor";
14
15
  const TemplateForm = ({ url }) => {
15
16
  const [name, setName] = useState("");
@@ -23,7 +24,7 @@ const TemplateForm = ({ url }) => {
23
24
  }), [placeholder]);
24
25
  const validateForm = () => {
25
26
  if (!name || !content) {
26
- alert("Please fill in all required fields: Name and Content.");
27
+ toast.error("Please fill in all required fields: Name and Content.");
27
28
  return false;
28
29
  }
29
30
  return true;
@@ -56,18 +57,18 @@ const TemplateForm = ({ url }) => {
56
57
  try {
57
58
  if (isEditMode) {
58
59
  yield updateTemplateApi(url, id, name, content);
59
- alert("Template updated successfully");
60
+ toast.success("Template updated successfully");
60
61
  }
61
62
  else {
62
63
  yield addTemplateApi(url, name, content);
63
- alert("Template added successfully");
64
+ toast.success("Template added successfully");
64
65
  }
65
66
  window.history.pushState({}, "", "/admin/template");
66
67
  window.dispatchEvent(new PopStateEvent("popstate"));
67
68
  }
68
69
  catch (error) {
69
70
  console.error("Error adding/updating Template:", error);
70
- alert("Failed to add/update Template");
71
+ toast.error(isEditMode ? "Failed to update Template" : "Failed to add Template");
71
72
  }
72
73
  });
73
74
  const handleCancelClick = () => {
@@ -76,6 +77,6 @@ const TemplateForm = ({ url }) => {
76
77
  window.history.pushState({}, "", "/admin/template");
77
78
  window.dispatchEvent(new PopStateEvent("popstate"));
78
79
  };
79
- return (_jsx("div", { className: "w-full pr-16", children: _jsx("div", { className: "flex-grow p-6", 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 Template" : "Add Template" }), _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, type: "text", value: name, onChange: (e) => setName(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", placeholder: "Enter Name" })] }), _jsxs("div", { className: "mb-6 w-full", children: [_jsxs("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: ["Content ", _jsx("span", { className: "text-red-500", children: "*" })] }), _jsx(Editor, { content: content, setContent: setContent, config: config })] }), _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" })] })] }) }) }));
80
+ return (_jsx("div", { className: "w-full pr-16", children: _jsx("div", { className: "flex-grow p-6", children: _jsxs("form", { children: [_jsx("h1", { className: "text-3xl font-bold text-blue-600 capitalize dark:text-white mb-4", children: isEditMode ? "Edit Template" : "Add Template" }), _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, type: "text", value: name, onChange: (e) => setName(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", placeholder: "Enter Name" })] }), _jsxs("div", { className: "mb-6 w-full", children: [_jsxs("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: ["Content ", _jsx("span", { className: "text-red-500", children: "*" })] }), _jsx(Editor, { content: content, setContent: setContent, config: config })] }), _jsxs("div", { className: "flex space-x-4 mt-6 justify-start", 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" })] })] }) }) }));
80
81
  };
81
82
  export default TemplateForm;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleven-solutions-common-website-unique-web",
3
- "version": "22.0.2",
3
+ "version": "22.0.4",
4
4
  "main": "./dist/index.js",
5
5
  "files": [
6
6
  "dist"