eleven-solutions-common-website-unique-web 4.0.18 → 4.0.20
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/admin/Taxionomies.js +0 -18
- package/dist/components/admin/TaxonomyForm.js +2 -27
- package/dist/components/api/taxonomy.js +0 -12
- package/package.json +1 -1
- package/src/components/admin/Taxionomies.tsx +0 -21
- package/src/components/admin/TaxonomyForm.tsx +2 -31
- package/src/components/api/taxonomy.ts +0 -12
@@ -16,7 +16,6 @@ const Taxionomies = () => {
|
|
16
16
|
const fetchTaxonomiesData = () => __awaiter(void 0, void 0, void 0, function* () {
|
17
17
|
const data = yield fetchTaxonomiessApi();
|
18
18
|
if (data) {
|
19
|
-
// const uniqueTaxonomies = data.reduce((acc: any[], item: any) => {
|
20
19
|
const uniqueTaxonomies = data.reduce((acc, item) => {
|
21
20
|
if (!acc.some((taxonomy) => taxonomy.type === item.type)) {
|
22
21
|
acc.push(item);
|
@@ -49,33 +48,16 @@ const Taxionomies = () => {
|
|
49
48
|
setCurrentPage(pageNumber);
|
50
49
|
};
|
51
50
|
const paginatedTaxonomies = taxonomy.slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage);
|
52
|
-
// const navigate = useNavigate();
|
53
|
-
// const handleViewClick = (id: string, type: string) => {
|
54
|
-
// navigate("/admin/taxonomy/taxonomyform", { state: { id, type } });
|
55
|
-
// };
|
56
51
|
const handleNavigation = (event, path) => {
|
57
52
|
event.preventDefault();
|
58
53
|
window.history.pushState({}, "", path);
|
59
54
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
60
55
|
};
|
61
|
-
// const handleViewClick = (
|
62
|
-
// event: React.MouseEvent,
|
63
|
-
// path: string,
|
64
|
-
// id: string,
|
65
|
-
// type: string
|
66
|
-
// ) => {
|
67
|
-
// event.preventDefault();
|
68
|
-
// window.history.pushState({ id, type }, "", path);
|
69
|
-
// window.dispatchEvent(new PopStateEvent("popstate"));
|
70
|
-
// };
|
71
56
|
const handleViewClick = (event, path, id, type) => {
|
72
57
|
event.preventDefault();
|
73
|
-
// Add id and type as query parameters to the path
|
74
58
|
const queryParams = new URLSearchParams({ id, type });
|
75
59
|
const fullPath = `${path}${queryParams.toString()}`;
|
76
|
-
// Push the updated URL with the state
|
77
60
|
window.history.pushState({ id, type }, "", fullPath);
|
78
|
-
// Trigger popstate event to simulate navigation
|
79
61
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
80
62
|
};
|
81
63
|
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: "Taxonomy" }) }), _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 Taxonomies", 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 h-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: "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: "Type" })] }) }), _jsx("tbody", { className: "bg-white divide-y divide-gray-200 dark:divide-gray-700 dark:bg-gray-900", children: paginatedTaxonomies.map((taxonomy, index) => (_jsxs("tr", { children: [_jsx("td", { className: "px-4 py-4 text-sm whitespace-nowrap", children: _jsx("div", { className: "flex items-center gap-x-6", children: taxonomy.isEdit ? (_jsx("button", { type: "button", onClick: (event) => {
|
@@ -82,8 +82,7 @@ const TaxonomyForm = () => {
|
|
82
82
|
}, []);
|
83
83
|
const handleSubmit = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
84
84
|
event.preventDefault();
|
85
|
-
if (!validateForm())
|
86
|
-
return;
|
85
|
+
// if (!validateForm()) return;
|
87
86
|
try {
|
88
87
|
if (isEditMode) {
|
89
88
|
yield addMultipleTaxonomiesApi(tempTaxonomy);
|
@@ -94,8 +93,6 @@ const TaxonomyForm = () => {
|
|
94
93
|
yield addTaxonomyApi(inputType, Number(code), value);
|
95
94
|
alert("Taxonomy added successfully");
|
96
95
|
}
|
97
|
-
// window.history.pushState({}, "", "/admin/taxinomies");
|
98
|
-
// window.dispatchEvent(new PopStateEvent("popstate"));
|
99
96
|
console.log("Navigating to /admin/taxinomies");
|
100
97
|
window.history.pushState({}, "", "/admin/taxinomies");
|
101
98
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
@@ -139,26 +136,6 @@ const TaxonomyForm = () => {
|
|
139
136
|
});
|
140
137
|
fetchIsMultiple();
|
141
138
|
}, [type]);
|
142
|
-
// useEffect(() => {
|
143
|
-
// const fetchIsMultiple = async () => {
|
144
|
-
// try {
|
145
|
-
// const result = await isMultipleApi(type);
|
146
|
-
// setIsMultiple(typeof result === "boolean");
|
147
|
-
// } catch (error) {
|
148
|
-
// console.error("Error checking if taxonomy is multiple:", error);
|
149
|
-
// }
|
150
|
-
// };
|
151
|
-
// const handleLocationOrTypeChange = () => {
|
152
|
-
// if (window.location.pathname === "/taxonomy/taxonomyform") {
|
153
|
-
// fetchIsMultiple();
|
154
|
-
// }
|
155
|
-
// };
|
156
|
-
// handleLocationOrTypeChange();
|
157
|
-
// window.addEventListener("popstate", handleLocationOrTypeChange);
|
158
|
-
// return () => {
|
159
|
-
// window.removeEventListener("popstate", handleLocationOrTypeChange);
|
160
|
-
// };
|
161
|
-
// }, [type]);
|
162
139
|
const handleCancelClick = () => {
|
163
140
|
setType("");
|
164
141
|
setCode("");
|
@@ -181,7 +158,7 @@ const TaxonomyForm = () => {
|
|
181
158
|
alert("Please fill in all required fields: Code, and Value.");
|
182
159
|
return;
|
183
160
|
}
|
184
|
-
const newTaxonomyItem = { type:
|
161
|
+
const newTaxonomyItem = { type: type, code: newCode, value: newValue };
|
185
162
|
if (editTempTaxonomyItem) {
|
186
163
|
const updatedTempTaxonomy = tempTaxonomy.map((item) => item === editTempTaxonomyItem ? newTaxonomyItem : item);
|
187
164
|
setTempTaxonomy(updatedTempTaxonomy);
|
@@ -219,7 +196,6 @@ const TaxonomyForm = () => {
|
|
219
196
|
}
|
220
197
|
setIsModalOpen(false);
|
221
198
|
const response = yield fetchTaxonomiessApi();
|
222
|
-
// const filteredTaxonomies = response.filter(
|
223
199
|
const filteredTaxonomies = response.filter((taxonomy) => taxonomy.type === type);
|
224
200
|
setSimilarTaxonomies(filteredTaxonomies);
|
225
201
|
});
|
@@ -233,7 +209,6 @@ const TaxonomyForm = () => {
|
|
233
209
|
setTempTaxonomy([]);
|
234
210
|
alert("Multiple taxonomies added successfully");
|
235
211
|
const response = yield fetchTaxonomiessApi();
|
236
|
-
// const filteredTaxonomies = response.filter(
|
237
212
|
const filteredTaxonomies = response.filter((taxonomy) => taxonomy.type === inputType);
|
238
213
|
setSimilarTaxonomies(filteredTaxonomies);
|
239
214
|
}
|
@@ -48,18 +48,6 @@ export const fetchTaxonomiessApi = () => __awaiter(void 0, void 0, void 0, funct
|
|
48
48
|
export const deleteTaxonomyApi = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
49
49
|
const token = cookies.get("token");
|
50
50
|
try {
|
51
|
-
// const response = await axios.delete(`${apiUrl}/taxonomy/delete`, {
|
52
|
-
// headers: {
|
53
|
-
// Authorization: `Bearer ${token}`,
|
54
|
-
// },
|
55
|
-
// // data: {
|
56
|
-
// // id,
|
57
|
-
// // },
|
58
|
-
// params: {
|
59
|
-
// id,
|
60
|
-
// },
|
61
|
-
// });
|
62
|
-
// return response.data;
|
63
51
|
const response = yield axios.request({
|
64
52
|
method: "DELETE",
|
65
53
|
url: `${apiUrl}/taxonomy/delete`,
|
package/package.json
CHANGED
@@ -10,7 +10,6 @@ const Taxionomies = () => {
|
|
10
10
|
const fetchTaxonomiesData = async () => {
|
11
11
|
const data = await fetchTaxonomiessApi();
|
12
12
|
if (data) {
|
13
|
-
// const uniqueTaxonomies = data.reduce((acc: any[], item: any) => {
|
14
13
|
const uniqueTaxonomies = (data as any[]).reduce(
|
15
14
|
(acc: any[], item: any) => {
|
16
15
|
if (!acc.some((taxonomy) => taxonomy.type === item.type)) {
|
@@ -57,29 +56,12 @@ const Taxionomies = () => {
|
|
57
56
|
currentPage * itemsPerPage
|
58
57
|
);
|
59
58
|
|
60
|
-
// const navigate = useNavigate();
|
61
|
-
|
62
|
-
// const handleViewClick = (id: string, type: string) => {
|
63
|
-
// navigate("/admin/taxonomy/taxonomyform", { state: { id, type } });
|
64
|
-
// };
|
65
|
-
|
66
59
|
const handleNavigation = (event: React.MouseEvent, path: string) => {
|
67
60
|
event.preventDefault();
|
68
61
|
window.history.pushState({}, "", path);
|
69
62
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
70
63
|
};
|
71
64
|
|
72
|
-
// const handleViewClick = (
|
73
|
-
// event: React.MouseEvent,
|
74
|
-
// path: string,
|
75
|
-
// id: string,
|
76
|
-
// type: string
|
77
|
-
// ) => {
|
78
|
-
// event.preventDefault();
|
79
|
-
// window.history.pushState({ id, type }, "", path);
|
80
|
-
// window.dispatchEvent(new PopStateEvent("popstate"));
|
81
|
-
// };
|
82
|
-
|
83
65
|
const handleViewClick = (
|
84
66
|
event: React.MouseEvent,
|
85
67
|
path: string,
|
@@ -88,14 +70,11 @@ const Taxionomies = () => {
|
|
88
70
|
) => {
|
89
71
|
event.preventDefault();
|
90
72
|
|
91
|
-
// Add id and type as query parameters to the path
|
92
73
|
const queryParams = new URLSearchParams({ id, type });
|
93
74
|
const fullPath = `${path}${queryParams.toString()}`;
|
94
75
|
|
95
|
-
// Push the updated URL with the state
|
96
76
|
window.history.pushState({ id, type }, "", fullPath);
|
97
77
|
|
98
|
-
// Trigger popstate event to simulate navigation
|
99
78
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
100
79
|
};
|
101
80
|
|
@@ -114,7 +114,7 @@ const TaxonomyForm = () => {
|
|
114
114
|
|
115
115
|
const handleSubmit = async (event: React.MouseEvent<HTMLButtonElement>) => {
|
116
116
|
event.preventDefault();
|
117
|
-
if (!validateForm()) return;
|
117
|
+
// if (!validateForm()) return;
|
118
118
|
|
119
119
|
try {
|
120
120
|
if (isEditMode) {
|
@@ -125,8 +125,6 @@ const TaxonomyForm = () => {
|
|
125
125
|
await addTaxonomyApi(inputType, Number(code), value);
|
126
126
|
alert("Taxonomy added successfully");
|
127
127
|
}
|
128
|
-
// window.history.pushState({}, "", "/admin/taxinomies");
|
129
|
-
// window.dispatchEvent(new PopStateEvent("popstate"));
|
130
128
|
console.log("Navigating to /admin/taxinomies");
|
131
129
|
window.history.pushState({}, "", "/admin/taxinomies");
|
132
130
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
@@ -170,31 +168,6 @@ const TaxonomyForm = () => {
|
|
170
168
|
fetchIsMultiple();
|
171
169
|
}, [type]);
|
172
170
|
|
173
|
-
// useEffect(() => {
|
174
|
-
// const fetchIsMultiple = async () => {
|
175
|
-
// try {
|
176
|
-
// const result = await isMultipleApi(type);
|
177
|
-
// setIsMultiple(typeof result === "boolean");
|
178
|
-
// } catch (error) {
|
179
|
-
// console.error("Error checking if taxonomy is multiple:", error);
|
180
|
-
// }
|
181
|
-
// };
|
182
|
-
|
183
|
-
// const handleLocationOrTypeChange = () => {
|
184
|
-
// if (window.location.pathname === "/taxonomy/taxonomyform") {
|
185
|
-
// fetchIsMultiple();
|
186
|
-
// }
|
187
|
-
// };
|
188
|
-
|
189
|
-
// handleLocationOrTypeChange();
|
190
|
-
|
191
|
-
// window.addEventListener("popstate", handleLocationOrTypeChange);
|
192
|
-
|
193
|
-
// return () => {
|
194
|
-
// window.removeEventListener("popstate", handleLocationOrTypeChange);
|
195
|
-
// };
|
196
|
-
// }, [type]);
|
197
|
-
|
198
171
|
const handleCancelClick = () => {
|
199
172
|
setType("");
|
200
173
|
setCode("");
|
@@ -221,7 +194,7 @@ const TaxonomyForm = () => {
|
|
221
194
|
return;
|
222
195
|
}
|
223
196
|
|
224
|
-
const newTaxonomyItem = { type:
|
197
|
+
const newTaxonomyItem = { type: type, code: newCode, value: newValue };
|
225
198
|
|
226
199
|
if (editTempTaxonomyItem) {
|
227
200
|
const updatedTempTaxonomy = tempTaxonomy.map((item) =>
|
@@ -270,7 +243,6 @@ const TaxonomyForm = () => {
|
|
270
243
|
}
|
271
244
|
setIsModalOpen(false);
|
272
245
|
const response = await fetchTaxonomiessApi();
|
273
|
-
// const filteredTaxonomies = response.filter(
|
274
246
|
const filteredTaxonomies = (response as { type: string }[]).filter(
|
275
247
|
(taxonomy: { type: string }) => taxonomy.type === type
|
276
248
|
);
|
@@ -287,7 +259,6 @@ const TaxonomyForm = () => {
|
|
287
259
|
setTempTaxonomy([]);
|
288
260
|
alert("Multiple taxonomies added successfully");
|
289
261
|
const response = await fetchTaxonomiessApi();
|
290
|
-
// const filteredTaxonomies = response.filter(
|
291
262
|
const filteredTaxonomies = (response as { type: string }[]).filter(
|
292
263
|
(taxonomy: { type: string }) => taxonomy.type === inputType
|
293
264
|
);
|
@@ -52,18 +52,6 @@ export const deleteTaxonomyApi = async (id: string) => {
|
|
52
52
|
const token = cookies.get("token");
|
53
53
|
|
54
54
|
try {
|
55
|
-
// const response = await axios.delete(`${apiUrl}/taxonomy/delete`, {
|
56
|
-
// headers: {
|
57
|
-
// Authorization: `Bearer ${token}`,
|
58
|
-
// },
|
59
|
-
// // data: {
|
60
|
-
// // id,
|
61
|
-
// // },
|
62
|
-
// params: {
|
63
|
-
// id,
|
64
|
-
// },
|
65
|
-
// });
|
66
|
-
// return response.data;
|
67
55
|
const response = await axios.request({
|
68
56
|
method: "DELETE",
|
69
57
|
url: `${apiUrl}/taxonomy/delete`,
|