eleven-solutions-common-website-unique-web 21.0.36 → 21.0.38
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.
@@ -59,6 +59,7 @@ const TaxonomyForm = ({ url }) => {
|
|
59
59
|
}
|
60
60
|
catch (error) {
|
61
61
|
console.error("Error deleting Taxonomy:", error);
|
62
|
+
alert("Error deleting Taxonomy: " + error.message);
|
62
63
|
}
|
63
64
|
});
|
64
65
|
const [editTaxonomyItem, setEditTaxonomyItem] = useState(null);
|
@@ -107,24 +108,6 @@ const TaxonomyForm = ({ url }) => {
|
|
107
108
|
setIsSimilarTaxonomyOpen(true);
|
108
109
|
}
|
109
110
|
}, []);
|
110
|
-
// const handleSubmit = async (event: React.MouseEvent<HTMLButtonElement>) => {
|
111
|
-
// event.preventDefault();
|
112
|
-
// try {
|
113
|
-
// if (isEditMode) {
|
114
|
-
// await addMultipleTaxonomiesApi(url, tempTaxonomy);
|
115
|
-
// setTempTaxonomy([]);
|
116
|
-
// alert("Taxonomies saved successfully");
|
117
|
-
// } else {
|
118
|
-
// await addTaxonomyApi(url, inputType, Number(code), value);
|
119
|
-
// alert("Taxonomy added successfully");
|
120
|
-
// }
|
121
|
-
// window.history.pushState({}, "", "/admin/taxinomies");
|
122
|
-
// window.dispatchEvent(new PopStateEvent("popstate"));
|
123
|
-
// } catch (error) {
|
124
|
-
// console.error("Error adding/updating Taxonomy:", error);
|
125
|
-
// alert("Failed to add/update Taxonomy");
|
126
|
-
// }
|
127
|
-
// };
|
128
111
|
const handleCancelClick = () => {
|
129
112
|
setType("");
|
130
113
|
setCode("");
|
@@ -168,7 +151,6 @@ const TaxonomyForm = ({ url }) => {
|
|
168
151
|
setIsAddingSubType(true);
|
169
152
|
};
|
170
153
|
const handleSubTypeSubmitClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
171
|
-
var _a;
|
172
154
|
if (!subCode || !subValue) {
|
173
155
|
alert("Please fill out both Code and Value fields before proceeding.");
|
174
156
|
return;
|
@@ -188,81 +170,13 @@ const TaxonomyForm = ({ url }) => {
|
|
188
170
|
}
|
189
171
|
}
|
190
172
|
catch (error) {
|
191
|
-
|
192
|
-
|
193
|
-
// Extract the inner exception details, if available
|
194
|
-
let innerExceptionDetails = "";
|
195
|
-
if (error.innerException) {
|
196
|
-
// If the error has an `innerException` property
|
197
|
-
innerExceptionDetails = JSON.stringify(error.innerException, null, 2);
|
198
|
-
}
|
199
|
-
else if ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) {
|
200
|
-
// If using Axios or similar libraries, look for response data
|
201
|
-
innerExceptionDetails = JSON.stringify(error.response.data, null, 2);
|
202
|
-
}
|
203
|
-
else if (error.details) {
|
204
|
-
// Look for a generic `details` property
|
205
|
-
innerExceptionDetails = JSON.stringify(error.details, null, 2);
|
206
|
-
}
|
207
|
-
// Format the final error message
|
208
|
-
const detailedMessage = innerExceptionDetails
|
209
|
-
? `${errorMessage}\n\nInner Exception Details:\n${innerExceptionDetails}`
|
210
|
-
: errorMessage;
|
211
|
-
// Display the error details
|
212
|
-
alert("Error while adding SubType: " + detailedMessage);
|
213
|
-
// Log full error object for debugging
|
214
|
-
console.error("Error object:", error);
|
173
|
+
console.error(`Error ${editTaxonomyItem ? "editing" : "adding"} SubType:`, error);
|
174
|
+
alert("Error while adding SubType: " + error.message);
|
215
175
|
}
|
216
176
|
setIsModalOpen(false);
|
217
177
|
setSubCode("");
|
218
178
|
setSubValue("");
|
219
179
|
});
|
220
|
-
// const handleSubTypeAddClick = async () => {
|
221
|
-
// if (!subCode || !subValue) {
|
222
|
-
// alert("Please fill out both Code and Value fields before adding.");
|
223
|
-
// return;
|
224
|
-
// }
|
225
|
-
// try {
|
226
|
-
// await addSubTypeApi(
|
227
|
-
// url,
|
228
|
-
// selectedTaxonomyId,
|
229
|
-
// type,
|
230
|
-
// Number(subCode),
|
231
|
-
// subValue
|
232
|
-
// );
|
233
|
-
// alert("SubType added successfully");
|
234
|
-
// const fetchedTaxonomies = await fetchTaxonomiessApi(url);
|
235
|
-
// if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
236
|
-
// setAllTaxonomies(fetchedTaxonomies);
|
237
|
-
// }
|
238
|
-
// } catch (error) {
|
239
|
-
// console.error("Error adding SubType:", error);
|
240
|
-
// }
|
241
|
-
// setIsModalOpen(false);
|
242
|
-
// setSubCode("");
|
243
|
-
// setSubValue("");
|
244
|
-
// };
|
245
|
-
// const handleSubTypeEditClick = async () => {
|
246
|
-
// try {
|
247
|
-
// await updateTaxonomyApi(
|
248
|
-
// url,
|
249
|
-
// selectedTaxonomyId,
|
250
|
-
// type,
|
251
|
-
// Number(subCode),
|
252
|
-
// subValue
|
253
|
-
// );
|
254
|
-
// alert("SubType edited successfully");
|
255
|
-
// const fetchedTaxonomies = await fetchTaxonomiessApi(url);
|
256
|
-
// if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
257
|
-
// setAllTaxonomies(fetchedTaxonomies);
|
258
|
-
// }
|
259
|
-
// } catch (error) {
|
260
|
-
// console.error("Error editing SubType:", error);
|
261
|
-
// }
|
262
|
-
// setIsModalOpen(false);
|
263
|
-
// setSubCode("");
|
264
|
-
// setSubValue("");
|
265
|
-
// };
|
266
180
|
const handleSubEdit = (child) => {
|
267
181
|
setSelectedTaxonomyId(child.id);
|
268
182
|
setEditTaxonomyItem(child);
|
@@ -271,48 +185,6 @@ const TaxonomyForm = ({ url }) => {
|
|
271
185
|
setIsModalOpen(true);
|
272
186
|
setIsAddingSubType(true);
|
273
187
|
};
|
274
|
-
// const handleEditTaxClick = async () => {
|
275
|
-
// try {
|
276
|
-
// await updateTaxonomyApi(
|
277
|
-
// url,
|
278
|
-
// selectedTaxonomyId,
|
279
|
-
// type,
|
280
|
-
// Number(newCode),
|
281
|
-
// newValue
|
282
|
-
// );
|
283
|
-
// alert("Taxonomy updated successfully");
|
284
|
-
// } catch (error) {
|
285
|
-
// console.error("Error updating Taxonomy:", error);
|
286
|
-
// }
|
287
|
-
// setIsModalOpen(false);
|
288
|
-
// setNewCode("");
|
289
|
-
// setNewValue("");
|
290
|
-
// const response = await fetchTaxonomiessApi(url);
|
291
|
-
// const filteredTaxonomies = (response as { type: string }[]).filter(
|
292
|
-
// (taxonomy: { type: string }) => taxonomy.type === type
|
293
|
-
// );
|
294
|
-
// setSimilarTaxonomies(filteredTaxonomies);
|
295
|
-
// };
|
296
|
-
// const addTaxonomyClick = async () => {
|
297
|
-
// if (!newCode || !newValue) {
|
298
|
-
// alert("Please fill out both Code and Value fields before adding.");
|
299
|
-
// return;
|
300
|
-
// }
|
301
|
-
// try {
|
302
|
-
// await addTaxonomyApi(url, type, Number(newCode), newValue);
|
303
|
-
// alert("Value added successfully");
|
304
|
-
// const response = await fetchTaxonomiessApi(url);
|
305
|
-
// const filteredTaxonomies = (response as { type: string }[]).filter(
|
306
|
-
// (taxonomy: { type: string }) => taxonomy.type === type
|
307
|
-
// );
|
308
|
-
// setSimilarTaxonomies(filteredTaxonomies);
|
309
|
-
// } catch (error) {
|
310
|
-
// console.error("Error adding value:", error);
|
311
|
-
// }
|
312
|
-
// setIsModalOpen(false);
|
313
|
-
// setNewCode("");
|
314
|
-
// setNewValue("");
|
315
|
-
// };
|
316
188
|
const handleSubmitClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
317
189
|
if (!newCode || !newValue) {
|
318
190
|
alert("Please fill out both Code and Value fields before submitting.");
|
@@ -320,16 +192,13 @@ const TaxonomyForm = ({ url }) => {
|
|
320
192
|
}
|
321
193
|
try {
|
322
194
|
if (editTaxonomyItem || editTempTaxonomyItem) {
|
323
|
-
// Edit taxonomy logic
|
324
195
|
yield updateTaxonomyApi(url, selectedTaxonomyId, type, Number(newCode), newValue);
|
325
196
|
alert("Taxonomy updated successfully");
|
326
197
|
}
|
327
198
|
else {
|
328
|
-
// Add taxonomy logic
|
329
199
|
yield addTaxonomyApi(url, type, Number(newCode), newValue);
|
330
200
|
alert("Value added successfully");
|
331
201
|
}
|
332
|
-
// Fetch and update similar taxonomies
|
333
202
|
const response = yield fetchTaxonomiessApi(url);
|
334
203
|
const filteredTaxonomies = response.filter((taxonomy) => taxonomy.type === type);
|
335
204
|
setSimilarTaxonomies(filteredTaxonomies);
|
@@ -338,8 +207,10 @@ const TaxonomyForm = ({ url }) => {
|
|
338
207
|
console.error(editTaxonomyItem || editTempTaxonomyItem
|
339
208
|
? "Error updating Taxonomy:"
|
340
209
|
: "Error adding value:", error);
|
210
|
+
alert(editTaxonomyItem
|
211
|
+
? "Error updating Taxonomy: "
|
212
|
+
: "Error adding value: " + error.message);
|
341
213
|
}
|
342
|
-
// Reset modal and input fields
|
343
214
|
setIsModalOpen(false);
|
344
215
|
setNewCode("");
|
345
216
|
setNewValue("");
|
@@ -367,10 +238,6 @@ const TaxonomyForm = ({ url }) => {
|
|
367
238
|
: "Add SubType"
|
368
239
|
: editTaxonomyItem
|
369
240
|
? "Edit Values"
|
370
|
-
: "Add Values" }), _jsx("button", { onClick: handleCloseModal, className: "text-xl text-gray-600 dark:text-gray-400 h-6 w-6", children: "\u00D7" })] }), isAddingSubType ? (_jsxs(_Fragment, { children: [_jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Code" }), _jsx("input", { type: "number", value: subCode, onChange: (e) => setSubCode(e.target.value), placeholder: "Enter Code", className: "w-full px-4 py-2 mt-2 mb-4 border border-gray-300 rounded-md" }), _jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Value" }), _jsx("input", { type: "text", value: subValue, onChange: (e) => setSubValue(e.target.value), placeholder: "Enter Value", className: "w-full px-4 py-2 mt-2 mb-4 border border-gray-300 rounded-md" }), _jsxs("div", { className: "flex space-x-4 justify-end", children: [_jsx("button", { onClick: handleSubTypeSubmitClick, 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: editTaxonomyItem ? "Edit" : "Add" }), _jsx("button", { onClick: handleCloseModal, className: "px-8 py-2.5 leading-5 bg-gray-300 rounded-md", children: "Cancel" })] })] })) : (_jsxs(_Fragment, { children: [_jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Code" }), _jsx("input", { type: "number", value: newCode, onChange: (e) => setNewCode(e.target.value), placeholder: "Enter Code", className: "w-full px-4 py-2 mt-2 mb-4 border border-gray-300 rounded-md" }), _jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Value" }), _jsx("input", { type: "text", value: newValue, onChange: (e) => setNewValue(e.target.value), placeholder: "Enter Value", className: "w-full px-4 py-2 mt-2 mb-4 border border-gray-300 rounded-md" }), _jsxs("div", { className: "flex space-x-4 justify-end", children: [_jsx("button", {
|
371
|
-
// onClick={
|
372
|
-
// editTaxonomyItem ? handleEditTaxClick : addTaxonomyClick
|
373
|
-
// }
|
374
|
-
onClick: handleSubmitClick, 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: editTaxonomyItem || editTempTaxonomyItem ? "Edit" : "Add" }), _jsx("button", { onClick: handleCloseModal, className: "px-8 py-2.5 leading-5 bg-gray-300 rounded-md", children: "Cancel" })] })] }))] }) })] }));
|
241
|
+
: "Add Values" }), _jsx("button", { onClick: handleCloseModal, className: "text-xl text-gray-600 dark:text-gray-400 h-6 w-6", children: "\u00D7" })] }), isAddingSubType ? (_jsxs(_Fragment, { children: [_jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Code" }), _jsx("input", { type: "number", value: subCode, onChange: (e) => setSubCode(e.target.value), placeholder: "Enter Code", className: "w-full px-4 py-2 mt-2 mb-4 border border-gray-300 rounded-md" }), _jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Value" }), _jsx("input", { type: "text", value: subValue, onChange: (e) => setSubValue(e.target.value), placeholder: "Enter Value", className: "w-full px-4 py-2 mt-2 mb-4 border border-gray-300 rounded-md" }), _jsxs("div", { className: "flex space-x-4 justify-end", children: [_jsx("button", { onClick: handleSubTypeSubmitClick, 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: editTaxonomyItem ? "Edit" : "Add" }), _jsx("button", { onClick: handleCloseModal, className: "px-8 py-2.5 leading-5 bg-gray-300 rounded-md", children: "Cancel" })] })] })) : (_jsxs(_Fragment, { children: [_jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Code" }), _jsx("input", { type: "number", value: newCode, onChange: (e) => setNewCode(e.target.value), placeholder: "Enter Code", className: "w-full px-4 py-2 mt-2 mb-4 border border-gray-300 rounded-md" }), _jsx("label", { className: "text-gray-900 dark:text-gray-200 font-semibold", children: "Value" }), _jsx("input", { type: "text", value: newValue, onChange: (e) => setNewValue(e.target.value), placeholder: "Enter Value", className: "w-full px-4 py-2 mt-2 mb-4 border border-gray-300 rounded-md" }), _jsxs("div", { className: "flex space-x-4 justify-end", children: [_jsx("button", { onClick: handleSubmitClick, 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: editTaxonomyItem || editTempTaxonomyItem ? "Edit" : "Add" }), _jsx("button", { onClick: handleCloseModal, className: "px-8 py-2.5 leading-5 bg-gray-300 rounded-md", children: "Cancel" })] })] }))] }) })] }));
|
375
242
|
};
|
376
243
|
export default TaxonomyForm;
|
@@ -65,7 +65,7 @@ export const fetchUserByIdApi = (url, userId) => __awaiter(void 0, void 0, void
|
|
65
65
|
}
|
66
66
|
});
|
67
67
|
export const deleteUserApi = (url, id) => __awaiter(void 0, void 0, void 0, function* () {
|
68
|
-
const token = cookies.get("
|
68
|
+
const token = cookies.get("authToken");
|
69
69
|
try {
|
70
70
|
const response = yield axios.request({
|
71
71
|
method: "DELETE",
|
package/package.json
CHANGED
@@ -73,6 +73,7 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
73
73
|
}
|
74
74
|
} catch (error) {
|
75
75
|
console.error("Error deleting Taxonomy:", error);
|
76
|
+
alert("Error deleting Taxonomy: " + error.message);
|
76
77
|
}
|
77
78
|
};
|
78
79
|
|
@@ -144,26 +145,6 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
144
145
|
}
|
145
146
|
}, []);
|
146
147
|
|
147
|
-
// const handleSubmit = async (event: React.MouseEvent<HTMLButtonElement>) => {
|
148
|
-
// event.preventDefault();
|
149
|
-
|
150
|
-
// try {
|
151
|
-
// if (isEditMode) {
|
152
|
-
// await addMultipleTaxonomiesApi(url, tempTaxonomy);
|
153
|
-
// setTempTaxonomy([]);
|
154
|
-
// alert("Taxonomies saved successfully");
|
155
|
-
// } else {
|
156
|
-
// await addTaxonomyApi(url, inputType, Number(code), value);
|
157
|
-
// alert("Taxonomy added successfully");
|
158
|
-
// }
|
159
|
-
// window.history.pushState({}, "", "/admin/taxinomies");
|
160
|
-
// window.dispatchEvent(new PopStateEvent("popstate"));
|
161
|
-
// } catch (error) {
|
162
|
-
// console.error("Error adding/updating Taxonomy:", error);
|
163
|
-
// alert("Failed to add/update Taxonomy");
|
164
|
-
// }
|
165
|
-
// };
|
166
|
-
|
167
148
|
const handleCancelClick = () => {
|
168
149
|
setType("");
|
169
150
|
setCode("");
|
@@ -248,34 +229,12 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
248
229
|
if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
249
230
|
setAllTaxonomies(fetchedTaxonomies);
|
250
231
|
}
|
251
|
-
} catch (error
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
if (error.innerException) {
|
259
|
-
// If the error has an `innerException` property
|
260
|
-
innerExceptionDetails = JSON.stringify(error.innerException, null, 2);
|
261
|
-
} else if (error.response?.data) {
|
262
|
-
// If using Axios or similar libraries, look for response data
|
263
|
-
innerExceptionDetails = JSON.stringify(error.response.data, null, 2);
|
264
|
-
} else if (error.details) {
|
265
|
-
// Look for a generic `details` property
|
266
|
-
innerExceptionDetails = JSON.stringify(error.details, null, 2);
|
267
|
-
}
|
268
|
-
|
269
|
-
// Format the final error message
|
270
|
-
const detailedMessage = innerExceptionDetails
|
271
|
-
? `${errorMessage}\n\nInner Exception Details:\n${innerExceptionDetails}`
|
272
|
-
: errorMessage;
|
273
|
-
|
274
|
-
// Display the error details
|
275
|
-
alert("Error while adding SubType: " + detailedMessage);
|
276
|
-
|
277
|
-
// Log full error object for debugging
|
278
|
-
console.error("Error object:", error);
|
232
|
+
} catch (error) {
|
233
|
+
console.error(
|
234
|
+
`Error ${editTaxonomyItem ? "editing" : "adding"} SubType:`,
|
235
|
+
error
|
236
|
+
);
|
237
|
+
alert("Error while adding SubType: " + error.message);
|
279
238
|
}
|
280
239
|
|
281
240
|
setIsModalOpen(false);
|
@@ -283,55 +242,6 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
283
242
|
setSubValue("");
|
284
243
|
};
|
285
244
|
|
286
|
-
// const handleSubTypeAddClick = async () => {
|
287
|
-
// if (!subCode || !subValue) {
|
288
|
-
// alert("Please fill out both Code and Value fields before adding.");
|
289
|
-
// return;
|
290
|
-
// }
|
291
|
-
// try {
|
292
|
-
// await addSubTypeApi(
|
293
|
-
// url,
|
294
|
-
// selectedTaxonomyId,
|
295
|
-
// type,
|
296
|
-
// Number(subCode),
|
297
|
-
// subValue
|
298
|
-
// );
|
299
|
-
// alert("SubType added successfully");
|
300
|
-
// const fetchedTaxonomies = await fetchTaxonomiessApi(url);
|
301
|
-
// if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
302
|
-
// setAllTaxonomies(fetchedTaxonomies);
|
303
|
-
// }
|
304
|
-
// } catch (error) {
|
305
|
-
// console.error("Error adding SubType:", error);
|
306
|
-
// }
|
307
|
-
// setIsModalOpen(false);
|
308
|
-
// setSubCode("");
|
309
|
-
// setSubValue("");
|
310
|
-
// };
|
311
|
-
|
312
|
-
// const handleSubTypeEditClick = async () => {
|
313
|
-
// try {
|
314
|
-
// await updateTaxonomyApi(
|
315
|
-
// url,
|
316
|
-
// selectedTaxonomyId,
|
317
|
-
// type,
|
318
|
-
// Number(subCode),
|
319
|
-
// subValue
|
320
|
-
// );
|
321
|
-
|
322
|
-
// alert("SubType edited successfully");
|
323
|
-
// const fetchedTaxonomies = await fetchTaxonomiessApi(url);
|
324
|
-
// if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
325
|
-
// setAllTaxonomies(fetchedTaxonomies);
|
326
|
-
// }
|
327
|
-
// } catch (error) {
|
328
|
-
// console.error("Error editing SubType:", error);
|
329
|
-
// }
|
330
|
-
// setIsModalOpen(false);
|
331
|
-
// setSubCode("");
|
332
|
-
// setSubValue("");
|
333
|
-
// };
|
334
|
-
|
335
245
|
const handleSubEdit = (child: {
|
336
246
|
id: string;
|
337
247
|
type: string;
|
@@ -346,51 +256,6 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
346
256
|
setIsAddingSubType(true);
|
347
257
|
};
|
348
258
|
|
349
|
-
// const handleEditTaxClick = async () => {
|
350
|
-
// try {
|
351
|
-
// await updateTaxonomyApi(
|
352
|
-
// url,
|
353
|
-
// selectedTaxonomyId,
|
354
|
-
// type,
|
355
|
-
// Number(newCode),
|
356
|
-
// newValue
|
357
|
-
// );
|
358
|
-
// alert("Taxonomy updated successfully");
|
359
|
-
// } catch (error) {
|
360
|
-
// console.error("Error updating Taxonomy:", error);
|
361
|
-
// }
|
362
|
-
// setIsModalOpen(false);
|
363
|
-
// setNewCode("");
|
364
|
-
// setNewValue("");
|
365
|
-
// const response = await fetchTaxonomiessApi(url);
|
366
|
-
// const filteredTaxonomies = (response as { type: string }[]).filter(
|
367
|
-
// (taxonomy: { type: string }) => taxonomy.type === type
|
368
|
-
// );
|
369
|
-
// setSimilarTaxonomies(filteredTaxonomies);
|
370
|
-
// };
|
371
|
-
|
372
|
-
// const addTaxonomyClick = async () => {
|
373
|
-
// if (!newCode || !newValue) {
|
374
|
-
// alert("Please fill out both Code and Value fields before adding.");
|
375
|
-
// return;
|
376
|
-
// }
|
377
|
-
// try {
|
378
|
-
// await addTaxonomyApi(url, type, Number(newCode), newValue);
|
379
|
-
|
380
|
-
// alert("Value added successfully");
|
381
|
-
// const response = await fetchTaxonomiessApi(url);
|
382
|
-
// const filteredTaxonomies = (response as { type: string }[]).filter(
|
383
|
-
// (taxonomy: { type: string }) => taxonomy.type === type
|
384
|
-
// );
|
385
|
-
// setSimilarTaxonomies(filteredTaxonomies);
|
386
|
-
// } catch (error) {
|
387
|
-
// console.error("Error adding value:", error);
|
388
|
-
// }
|
389
|
-
// setIsModalOpen(false);
|
390
|
-
// setNewCode("");
|
391
|
-
// setNewValue("");
|
392
|
-
// };
|
393
|
-
|
394
259
|
const handleSubmitClick = async () => {
|
395
260
|
if (!newCode || !newValue) {
|
396
261
|
alert("Please fill out both Code and Value fields before submitting.");
|
@@ -399,7 +264,6 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
399
264
|
|
400
265
|
try {
|
401
266
|
if (editTaxonomyItem || editTempTaxonomyItem) {
|
402
|
-
// Edit taxonomy logic
|
403
267
|
await updateTaxonomyApi(
|
404
268
|
url,
|
405
269
|
selectedTaxonomyId,
|
@@ -409,12 +273,10 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
409
273
|
);
|
410
274
|
alert("Taxonomy updated successfully");
|
411
275
|
} else {
|
412
|
-
// Add taxonomy logic
|
413
276
|
await addTaxonomyApi(url, type, Number(newCode), newValue);
|
414
277
|
alert("Value added successfully");
|
415
278
|
}
|
416
279
|
|
417
|
-
// Fetch and update similar taxonomies
|
418
280
|
const response = await fetchTaxonomiessApi(url);
|
419
281
|
const filteredTaxonomies = (response as { type: string }[]).filter(
|
420
282
|
(taxonomy: { type: string }) => taxonomy.type === type
|
@@ -427,9 +289,13 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
427
289
|
: "Error adding value:",
|
428
290
|
error
|
429
291
|
);
|
292
|
+
alert(
|
293
|
+
editTaxonomyItem
|
294
|
+
? "Error updating Taxonomy: "
|
295
|
+
: "Error adding value: " + error.message
|
296
|
+
);
|
430
297
|
}
|
431
298
|
|
432
|
-
// Reset modal and input fields
|
433
299
|
setIsModalOpen(false);
|
434
300
|
setNewCode("");
|
435
301
|
setNewValue("");
|
@@ -850,9 +716,6 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
850
716
|
|
851
717
|
<div className="flex space-x-4 justify-end">
|
852
718
|
<button
|
853
|
-
// onClick={
|
854
|
-
// editTaxonomyItem ? handleEditTaxClick : addTaxonomyClick
|
855
|
-
// }
|
856
719
|
onClick={handleSubmitClick}
|
857
720
|
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"
|
858
721
|
>
|
@@ -74,7 +74,7 @@ export const fetchUserByIdApi = async (url: string, userId: string) => {
|
|
74
74
|
};
|
75
75
|
|
76
76
|
export const deleteUserApi = async (url: string, id: string) => {
|
77
|
-
const token = cookies.get("
|
77
|
+
const token = cookies.get("authToken");
|
78
78
|
|
79
79
|
try {
|
80
80
|
const response = await axios.request({
|