eleven-solutions-common-website-unique-web 7.0.0 → 7.0.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -234,7 +234,7 @@ const TaxonomyForm = () => {
|
|
234
234
|
setIsModalOpen(true);
|
235
235
|
setIsAddingSubType(true);
|
236
236
|
};
|
237
|
-
const
|
237
|
+
const handleSubTypeAddClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
238
238
|
try {
|
239
239
|
yield addSubTypeApi(selectedTaxonomyId, subType, Number(subCode), subValue);
|
240
240
|
alert("SubType added successfully");
|
@@ -251,6 +251,23 @@ const TaxonomyForm = () => {
|
|
251
251
|
setSubCode("");
|
252
252
|
setSubValue("");
|
253
253
|
});
|
254
|
+
const handleSubTypeEditClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
255
|
+
try {
|
256
|
+
yield updateTaxonomyApi(selectedTaxonomyId, subType, Number(subCode), subValue);
|
257
|
+
alert("SubType edited successfully");
|
258
|
+
const fetchedTaxonomies = yield fetchTaxonomiessApi();
|
259
|
+
if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
260
|
+
setAllTaxonomies(fetchedTaxonomies);
|
261
|
+
}
|
262
|
+
}
|
263
|
+
catch (error) {
|
264
|
+
console.error("Error editing SubType:", error);
|
265
|
+
}
|
266
|
+
setIsModalOpen(false);
|
267
|
+
setSubType("");
|
268
|
+
setSubCode("");
|
269
|
+
setSubValue("");
|
270
|
+
});
|
254
271
|
const handleSubEdit = (child) => {
|
255
272
|
// setIsAddingSubType(false);
|
256
273
|
setSelectedTaxonomyId(child.id);
|
@@ -327,6 +344,10 @@ const TaxonomyForm = () => {
|
|
327
344
|
: "Add SubType"
|
328
345
|
: editTaxonomyItem
|
329
346
|
? "Edit Values"
|
330
|
-
: "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: "Type" }), _jsx("input", { type: "text", value: subType, onChange: (e) => setSubType(e.target.value), placeholder: "Enter Type", 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: "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: handleCloseModal, className: "px-8 py-2.5 leading-5 bg-gray-300 rounded-md", children: "Cancel" }), _jsx("button", {
|
347
|
+
: "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: "Type" }), _jsx("input", { type: "text", value: subType, onChange: (e) => setSubType(e.target.value), placeholder: "Enter Type", 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: "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: handleCloseModal, className: "px-8 py-2.5 leading-5 bg-gray-300 rounded-md", children: "Cancel" }), _jsx("button", {
|
348
|
+
// onClick={handleSubTypeAddClick}
|
349
|
+
onClick: editTaxonomyItem
|
350
|
+
? handleSubTypeEditClick
|
351
|
+
: handleSubTypeAddClick, 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 SubType" : "Add SubType" })] })] })) : (_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: handleCloseModal, className: "px-8 py-2.5 leading-5 bg-gray-300 rounded-md", children: "Cancel" }), _jsx("button", { onClick: editTaxonomyItem ? handleEditTaxClick : handleAddClick, 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" })] })] }))] }) })] }));
|
331
352
|
};
|
332
353
|
export default TaxonomyForm;
|
package/package.json
CHANGED
@@ -286,7 +286,7 @@ const TaxonomyForm = () => {
|
|
286
286
|
setIsAddingSubType(true);
|
287
287
|
};
|
288
288
|
|
289
|
-
const
|
289
|
+
const handleSubTypeAddClick = async () => {
|
290
290
|
try {
|
291
291
|
await addSubTypeApi(
|
292
292
|
selectedTaxonomyId,
|
@@ -308,6 +308,29 @@ const TaxonomyForm = () => {
|
|
308
308
|
setSubValue("");
|
309
309
|
};
|
310
310
|
|
311
|
+
const handleSubTypeEditClick = async () => {
|
312
|
+
try {
|
313
|
+
await updateTaxonomyApi(
|
314
|
+
selectedTaxonomyId,
|
315
|
+
subType,
|
316
|
+
Number(subCode),
|
317
|
+
subValue
|
318
|
+
);
|
319
|
+
|
320
|
+
alert("SubType edited successfully");
|
321
|
+
const fetchedTaxonomies = await fetchTaxonomiessApi();
|
322
|
+
if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
|
323
|
+
setAllTaxonomies(fetchedTaxonomies);
|
324
|
+
}
|
325
|
+
} catch (error) {
|
326
|
+
console.error("Error editing SubType:", error);
|
327
|
+
}
|
328
|
+
setIsModalOpen(false);
|
329
|
+
setSubType("");
|
330
|
+
setSubCode("");
|
331
|
+
setSubValue("");
|
332
|
+
};
|
333
|
+
|
311
334
|
const handleSubEdit = (child: {
|
312
335
|
id: string;
|
313
336
|
type: string;
|
@@ -967,7 +990,12 @@ const TaxonomyForm = () => {
|
|
967
990
|
Cancel
|
968
991
|
</button>
|
969
992
|
<button
|
970
|
-
onClick={
|
993
|
+
// onClick={handleSubTypeAddClick}
|
994
|
+
onClick={
|
995
|
+
editTaxonomyItem
|
996
|
+
? handleSubTypeEditClick
|
997
|
+
: handleSubTypeAddClick
|
998
|
+
}
|
971
999
|
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"
|
972
1000
|
>
|
973
1001
|
{editTaxonomyItem ? "Edit SubType" : "Add SubType"}
|