eleven-solutions-common-website-unique-web 21.0.24 → 21.0.26
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.
@@ -10,11 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
11
11
|
import React from "react";
|
12
12
|
import { useState, useEffect } from "react";
|
13
|
-
import { addTaxonomyApi, fetchTaxonomyByIdApi, updateTaxonomyApi, fetchTaxonomiessApi,
|
13
|
+
import { addTaxonomyApi, fetchTaxonomyByIdApi, updateTaxonomyApi, fetchTaxonomiessApi, deleteTaxonomyApi, addSubTypeApi, } from "../api/taxonomy";
|
14
14
|
import { FaPlus } from "react-icons/fa";
|
15
15
|
const TaxonomyForm = ({ url }) => {
|
16
16
|
const [type, setType] = useState("");
|
17
|
-
const [inputType] = useState("");
|
17
|
+
// const [inputType] = useState<string>("");
|
18
18
|
const [code, setCode] = useState("");
|
19
19
|
const [value, setValue] = useState("");
|
20
20
|
const [isEditMode, setIsEditMode] = useState(false);
|
@@ -24,7 +24,6 @@ const TaxonomyForm = ({ url }) => {
|
|
24
24
|
const [subCode, setSubCode] = useState("");
|
25
25
|
const [subValue, setSubValue] = useState("");
|
26
26
|
const [isAddingSubType, setIsAddingSubType] = useState(false);
|
27
|
-
const [tempTaxonomy, setTempTaxonomy] = useState([]);
|
28
27
|
const [similarTaxonomies, setSimilarTaxonomies] = useState([]);
|
29
28
|
const [isSimilarTaxonomyOpen, setIsSimilarTaxonomyOpen] = useState(true);
|
30
29
|
//for child taxonomies
|
@@ -109,26 +108,24 @@ const TaxonomyForm = ({ url }) => {
|
|
109
108
|
setIsSimilarTaxonomyOpen(true);
|
110
109
|
}
|
111
110
|
}, []);
|
112
|
-
const handleSubmit = (event) =>
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
}
|
131
|
-
});
|
111
|
+
// const handleSubmit = async (event: React.MouseEvent<HTMLButtonElement>) => {
|
112
|
+
// event.preventDefault();
|
113
|
+
// try {
|
114
|
+
// if (isEditMode) {
|
115
|
+
// await addMultipleTaxonomiesApi(url, tempTaxonomy);
|
116
|
+
// setTempTaxonomy([]);
|
117
|
+
// alert("Taxonomies saved successfully");
|
118
|
+
// } else {
|
119
|
+
// await addTaxonomyApi(url, inputType, Number(code), value);
|
120
|
+
// alert("Taxonomy added successfully");
|
121
|
+
// }
|
122
|
+
// window.history.pushState({}, "", "/admin/taxinomies");
|
123
|
+
// window.dispatchEvent(new PopStateEvent("popstate"));
|
124
|
+
// } catch (error) {
|
125
|
+
// console.error("Error adding/updating Taxonomy:", error);
|
126
|
+
// alert("Failed to add/update Taxonomy");
|
127
|
+
// }
|
128
|
+
// };
|
132
129
|
const handleCancelClick = () => {
|
133
130
|
setType("");
|
134
131
|
setCode("");
|
@@ -274,6 +271,6 @@ const TaxonomyForm = ({ url }) => {
|
|
274
271
|
? "Edit Values"
|
275
272
|
: "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: editTaxonomyItem
|
276
273
|
? handleSubTypeEditClick
|
277
|
-
: 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" : "
|
274
|
+
: 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" : "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: editTaxonomyItem ? handleEditTaxClick : addTaxonomyClick, 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" })] })] }))] }) })] }));
|
278
275
|
};
|
279
276
|
export default TaxonomyForm;
|
package/package.json
CHANGED
@@ -17,7 +17,7 @@ interface TaxionomyFormProps {
|
|
17
17
|
|
18
18
|
const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
19
19
|
const [type, setType] = useState<string>("");
|
20
|
-
const [inputType] = useState<string>("");
|
20
|
+
// const [inputType] = useState<string>("");
|
21
21
|
const [code, setCode] = useState<number | string>("");
|
22
22
|
const [value, setValue] = useState<string>("");
|
23
23
|
|
@@ -33,8 +33,6 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
33
33
|
|
34
34
|
const [isAddingSubType, setIsAddingSubType] = useState(false);
|
35
35
|
|
36
|
-
const [tempTaxonomy, setTempTaxonomy] = useState<any[]>([]);
|
37
|
-
|
38
36
|
const [similarTaxonomies, setSimilarTaxonomies] = useState<any[]>([]);
|
39
37
|
const [isSimilarTaxonomyOpen, setIsSimilarTaxonomyOpen] = useState(true);
|
40
38
|
|
@@ -148,25 +146,25 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
148
146
|
}
|
149
147
|
}, []);
|
150
148
|
|
151
|
-
const handleSubmit = async (event: React.MouseEvent<HTMLButtonElement>) => {
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
};
|
149
|
+
// const handleSubmit = async (event: React.MouseEvent<HTMLButtonElement>) => {
|
150
|
+
// event.preventDefault();
|
151
|
+
|
152
|
+
// try {
|
153
|
+
// if (isEditMode) {
|
154
|
+
// await addMultipleTaxonomiesApi(url, tempTaxonomy);
|
155
|
+
// setTempTaxonomy([]);
|
156
|
+
// alert("Taxonomies saved successfully");
|
157
|
+
// } else {
|
158
|
+
// await addTaxonomyApi(url, inputType, Number(code), value);
|
159
|
+
// alert("Taxonomy added successfully");
|
160
|
+
// }
|
161
|
+
// window.history.pushState({}, "", "/admin/taxinomies");
|
162
|
+
// window.dispatchEvent(new PopStateEvent("popstate"));
|
163
|
+
// } catch (error) {
|
164
|
+
// console.error("Error adding/updating Taxonomy:", error);
|
165
|
+
// alert("Failed to add/update Taxonomy");
|
166
|
+
// }
|
167
|
+
// };
|
170
168
|
|
171
169
|
const handleCancelClick = () => {
|
172
170
|
setType("");
|
@@ -724,7 +722,7 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
|
|
724
722
|
}
|
725
723
|
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"
|
726
724
|
>
|
727
|
-
{editTaxonomyItem ? "Edit" : "
|
725
|
+
{editTaxonomyItem ? "Edit" : "Add"}
|
728
726
|
</button>
|
729
727
|
<button
|
730
728
|
onClick={handleCloseModal}
|