eleven-solutions-common-website-unique-web 4.0.30 → 4.0.32
Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
};
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
11
11
|
import { useState, useEffect } from "react";
|
12
|
-
import { addTaxonomyApi, fetchTaxonomyByIdApi, updateTaxonomyApi, fetchTaxonomiessApi, addMultipleTaxonomiesApi, deleteTaxonomyApi, isMultipleApi, } from "../api/taxonomy";
|
12
|
+
import { addTaxonomyApi, fetchTaxonomyByIdApi, updateTaxonomyApi, fetchTaxonomiessApi, addMultipleTaxonomiesApi, deleteTaxonomyApi, isMultipleApi, addSubTypeApi, } from "../api/taxonomy";
|
13
13
|
import { FaPlus } from "react-icons/fa";
|
14
14
|
const TaxonomyForm = () => {
|
15
15
|
const [type, setType] = useState("");
|
@@ -156,6 +156,9 @@ const TaxonomyForm = () => {
|
|
156
156
|
setIsModalOpen(false);
|
157
157
|
setNewCode("");
|
158
158
|
setNewValue("");
|
159
|
+
setSubType("");
|
160
|
+
setSubCode("");
|
161
|
+
setSubValue("");
|
159
162
|
};
|
160
163
|
const handleAddClick = () => {
|
161
164
|
if (newCode === "" || newValue === "") {
|
@@ -190,7 +193,7 @@ const TaxonomyForm = () => {
|
|
190
193
|
setNewValue(item.value);
|
191
194
|
setIsModalOpen(true);
|
192
195
|
};
|
193
|
-
const
|
196
|
+
const handleAddSubType = (index, id) => {
|
194
197
|
const item = similarTaxonomies[index];
|
195
198
|
setSelectedTaxonomyId(id);
|
196
199
|
setNewCode(item.code);
|
@@ -198,6 +201,16 @@ const TaxonomyForm = () => {
|
|
198
201
|
setIsModalOpen(true);
|
199
202
|
setIsAddingSubType(true);
|
200
203
|
};
|
204
|
+
const handleSubTypeClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
205
|
+
try {
|
206
|
+
yield addSubTypeApi(selectedTaxonomyId, subType, Number(subCode), subValue);
|
207
|
+
alert("Taxonomy updated successfully");
|
208
|
+
}
|
209
|
+
catch (error) {
|
210
|
+
console.error("Error updating Taxonomy:", error);
|
211
|
+
}
|
212
|
+
setIsModalOpen(false);
|
213
|
+
});
|
201
214
|
const handleEditTaxClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
202
215
|
try {
|
203
216
|
yield updateTaxonomyApi(selectedTaxonomyId, type, Number(newCode), newValue);
|
@@ -246,7 +259,7 @@ const TaxonomyForm = () => {
|
|
246
259
|
!isEditMode && (_jsx("button", { type: "submit", onClick: handleSave, 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 ? "Save" : "Add" })), _jsx("button", { onClick: handleCancelClick, type: "button", 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" })] })] })] })), isSimilarTaxonomyOpen && isMultiple && 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: [similarTaxonomies.some((taxonomy) => taxonomy.isEdit) && (_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: "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: similarTaxonomies.map((taxonomy, index) => (_jsxs("tr", { children: [similarTaxonomies.some((taxonomy) => taxonomy.isEdit) && (_jsx("td", { className: "px-4 py-4 text-sm whitespace-nowrap", children: _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", "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", { type: "button", onClick: () => {
|
247
260
|
handleEditClick(index, taxonomy.id);
|
248
261
|
}, 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", "stroke-width": "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "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: () => {
|
249
|
-
|
262
|
+
handleAddSubType(index, taxonomy.id);
|
250
263
|
}, 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", "stroke-width": "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M12 4.5v15m7.5-7.5h-15" }) }) })] }) })), _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: taxonomy.value })] }, index))) })] }) }), similarTaxonomies.some((taxonomy) => taxonomy.isEdit) && (_jsx("div", { className: "flex space-x-4 mt-6 justify-start", children: _jsxs("button", { type: "button", onClick: handleOpenModal, 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" }), "Add Multiple Values"] }) }))] })), isEditMode && (_jsx(_Fragment, { children: tempTaxonomy.length > 0 && (_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", children: "Edit/Delete" }), _jsx("th", { scope: "col", className: "px-4 py-3.5 text-md font-normal text-left text-gray-500 dark:text-gray-400", children: "Code" }), _jsx("th", { scope: "col", className: "px-4 py-3.5 text-md font-normal text-left text-gray-500 dark:text-gray-400", children: "Value" })] }) }), _jsx("tbody", { className: "bg-white divide-y divide-gray-200 dark:bg-gray-800 dark:divide-gray-700", children: [...tempTaxonomy].map((item, 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", { type: "button", onClick: () => {
|
251
264
|
const newTempTaxonomy = [...tempTaxonomy];
|
252
265
|
newTempTaxonomy.splice(index, 1);
|
@@ -257,6 +270,16 @@ const TaxonomyForm = () => {
|
|
257
270
|
? "Add SubType"
|
258
271
|
: editTaxonomyItem || editTempTaxonomyItem
|
259
272
|
? "Edit Values"
|
260
|
-
: "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(_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", {
|
273
|
+
: "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(_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", {
|
274
|
+
// onClick={editTaxonomyItem ? handleEditTaxClick : handleAddClick}
|
275
|
+
onClick: isAddingSubType
|
276
|
+
? handleSubTypeClick
|
277
|
+
: editTaxonomyItem
|
278
|
+
? handleEditTaxClick
|
279
|
+
: 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: isAddingSubType
|
280
|
+
? "Add SubType"
|
281
|
+
: editTaxonomyItem || editTempTaxonomyItem
|
282
|
+
? "Edit"
|
283
|
+
: "Add" })] })] }) })] }));
|
261
284
|
};
|
262
285
|
export default TaxonomyForm;
|
@@ -11,3 +11,4 @@ export declare const addMultipleTaxonomiesApi: (taxonomies: {
|
|
11
11
|
value: string;
|
12
12
|
}[]) => Promise<Axios.AxiosXHR<unknown>>;
|
13
13
|
export declare const isMultipleApi: (type: string) => Promise<unknown>;
|
14
|
+
export declare const addSubTypeApi: (parentid: string, type: string, code: number, value: string) => Promise<Axios.AxiosXHR<unknown>>;
|
@@ -133,3 +133,23 @@ export const isMultipleApi = (type) => __awaiter(void 0, void 0, void 0, functio
|
|
133
133
|
throw error;
|
134
134
|
}
|
135
135
|
});
|
136
|
+
export const addSubTypeApi = (parentid, type, code, value) => __awaiter(void 0, void 0, void 0, function* () {
|
137
|
+
const token = cookies.get("token");
|
138
|
+
try {
|
139
|
+
const response = yield axios.post(`${apiUrl}/taxonomy/add`, {
|
140
|
+
ParentId: parentid,
|
141
|
+
Type: type,
|
142
|
+
Code: code,
|
143
|
+
Value: value,
|
144
|
+
}, {
|
145
|
+
headers: {
|
146
|
+
Authorization: `Bearer ${token}`,
|
147
|
+
},
|
148
|
+
});
|
149
|
+
return response;
|
150
|
+
}
|
151
|
+
catch (error) {
|
152
|
+
console.error(error);
|
153
|
+
throw error;
|
154
|
+
}
|
155
|
+
});
|
package/package.json
CHANGED
@@ -8,6 +8,7 @@ import {
|
|
8
8
|
addMultipleTaxonomiesApi,
|
9
9
|
deleteTaxonomyApi,
|
10
10
|
isMultipleApi,
|
11
|
+
addSubTypeApi,
|
11
12
|
} from "../api/taxonomy";
|
12
13
|
import { FaPlus } from "react-icons/fa";
|
13
14
|
|
@@ -192,6 +193,9 @@ const TaxonomyForm = () => {
|
|
192
193
|
setIsModalOpen(false);
|
193
194
|
setNewCode("");
|
194
195
|
setNewValue("");
|
196
|
+
setSubType("");
|
197
|
+
setSubCode("");
|
198
|
+
setSubValue("");
|
195
199
|
};
|
196
200
|
|
197
201
|
const handleAddClick = () => {
|
@@ -235,7 +239,7 @@ const TaxonomyForm = () => {
|
|
235
239
|
setIsModalOpen(true);
|
236
240
|
};
|
237
241
|
|
238
|
-
const
|
242
|
+
const handleAddSubType = (index: number, id: string) => {
|
239
243
|
const item = similarTaxonomies[index];
|
240
244
|
setSelectedTaxonomyId(id);
|
241
245
|
|
@@ -245,6 +249,21 @@ const TaxonomyForm = () => {
|
|
245
249
|
setIsAddingSubType(true);
|
246
250
|
};
|
247
251
|
|
252
|
+
const handleSubTypeClick = async () => {
|
253
|
+
try {
|
254
|
+
await addSubTypeApi(
|
255
|
+
selectedTaxonomyId,
|
256
|
+
subType,
|
257
|
+
Number(subCode),
|
258
|
+
subValue
|
259
|
+
);
|
260
|
+
alert("Taxonomy updated successfully");
|
261
|
+
} catch (error) {
|
262
|
+
console.error("Error updating Taxonomy:", error);
|
263
|
+
}
|
264
|
+
setIsModalOpen(false);
|
265
|
+
};
|
266
|
+
|
248
267
|
const handleEditTaxClick = async () => {
|
249
268
|
try {
|
250
269
|
await updateTaxonomyApi(
|
@@ -494,7 +513,7 @@ const TaxonomyForm = () => {
|
|
494
513
|
<button
|
495
514
|
type="button"
|
496
515
|
onClick={() => {
|
497
|
-
|
516
|
+
handleAddSubType(index, taxonomy.id);
|
498
517
|
}}
|
499
518
|
className="text-gray-500 transition-colors duration-200 dark:hover:text-blue-500 dark:text-gray-300 hover:text-blue-500 focus:outline-none"
|
500
519
|
>
|
@@ -785,10 +804,22 @@ const TaxonomyForm = () => {
|
|
785
804
|
Cancel
|
786
805
|
</button>
|
787
806
|
<button
|
788
|
-
onClick={editTaxonomyItem ? handleEditTaxClick : handleAddClick}
|
807
|
+
// onClick={editTaxonomyItem ? handleEditTaxClick : handleAddClick}
|
808
|
+
onClick={
|
809
|
+
isAddingSubType
|
810
|
+
? handleSubTypeClick
|
811
|
+
: editTaxonomyItem
|
812
|
+
? handleEditTaxClick
|
813
|
+
: handleAddClick
|
814
|
+
}
|
789
815
|
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"
|
790
816
|
>
|
791
|
-
{editTaxonomyItem || editTempTaxonomyItem ? "Edit" : "Add"}
|
817
|
+
{/* {editTaxonomyItem || editTempTaxonomyItem ? "Edit" : "Add"} */}
|
818
|
+
{isAddingSubType
|
819
|
+
? "Add SubType"
|
820
|
+
: editTaxonomyItem || editTempTaxonomyItem
|
821
|
+
? "Edit"
|
822
|
+
: "Add"}
|
792
823
|
</button>
|
793
824
|
</div>
|
794
825
|
</div>
|
@@ -164,3 +164,34 @@ export const isMultipleApi = async (type: string) => {
|
|
164
164
|
throw error;
|
165
165
|
}
|
166
166
|
};
|
167
|
+
|
168
|
+
export const addSubTypeApi = async (
|
169
|
+
parentid: string,
|
170
|
+
type: string,
|
171
|
+
code: number,
|
172
|
+
value: string
|
173
|
+
) => {
|
174
|
+
const token = cookies.get("token");
|
175
|
+
|
176
|
+
try {
|
177
|
+
const response = await axios.post(
|
178
|
+
`${apiUrl}/taxonomy/add`,
|
179
|
+
{
|
180
|
+
ParentId: parentid,
|
181
|
+
Type: type,
|
182
|
+
Code: code,
|
183
|
+
Value: value,
|
184
|
+
},
|
185
|
+
{
|
186
|
+
headers: {
|
187
|
+
Authorization: `Bearer ${token}`,
|
188
|
+
},
|
189
|
+
}
|
190
|
+
);
|
191
|
+
return response;
|
192
|
+
} catch (error) {
|
193
|
+
console.error(error);
|
194
|
+
|
195
|
+
throw error;
|
196
|
+
}
|
197
|
+
};
|