eleven-solutions-common-website-unique-web 19.0.14 → 19.0.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -258,10 +258,10 @@ const TaxonomyForm = ({ url }) => {
258
258
  setSimilarTaxonomies(filteredTaxonomies);
259
259
  });
260
260
  const handleSaveClick = () => __awaiter(void 0, void 0, void 0, function* () {
261
- // if (tempTaxonomy.length === 0) {
262
- // alert("No taxonomies to add.");
263
- // return;
264
- // }
261
+ if (tempTaxonomy.length === 0) {
262
+ alert("No taxonomies to add.");
263
+ return;
264
+ }
265
265
  try {
266
266
  yield addMultipleTaxonomiesApi(url, tempTaxonomy);
267
267
  setTempTaxonomy([]);
@@ -275,6 +275,21 @@ const TaxonomyForm = ({ url }) => {
275
275
  alert("Failed to add multiple taxonomies");
276
276
  }
277
277
  });
278
+ const addTaxonomyClick = () => __awaiter(void 0, void 0, void 0, function* () {
279
+ try {
280
+ yield addTaxonomyApi(url, type, Number(newCode), newValue);
281
+ alert("Value added successfully");
282
+ const response = yield fetchTaxonomiessApi(url);
283
+ const filteredTaxonomies = response.filter((taxonomy) => taxonomy.type === type);
284
+ setSimilarTaxonomies(filteredTaxonomies);
285
+ }
286
+ catch (error) {
287
+ console.error("Error adding value:", error);
288
+ }
289
+ setIsModalOpen(false);
290
+ setNewCode("");
291
+ setNewValue("");
292
+ });
278
293
  const handleDeleteClick = (id) => __awaiter(void 0, void 0, void 0, function* () {
279
294
  try {
280
295
  yield deleteTaxonomyApi(url, id);
@@ -301,6 +316,6 @@ const TaxonomyForm = ({ url }) => {
301
316
  ? handleSubTypeEditClick
302
317
  : 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" }), _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:
303
318
  // editTaxonomyItem ? handleEditTaxClick : handleAddClick
304
- editTaxonomyItem ? handleEditTaxClick : handleSaveClick, 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" })] })] }))] }) })] }));
319
+ 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" })] })] }))] }) })] }));
305
320
  };
306
321
  export default TaxonomyForm;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleven-solutions-common-website-unique-web",
3
- "version": "19.0.14",
3
+ "version": "19.0.16",
4
4
  "main": "./dist/index.js",
5
5
  "scripts": {
6
6
  "build": "tsc",
@@ -341,10 +341,10 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
341
341
  };
342
342
 
343
343
  const handleSaveClick = async () => {
344
- // if (tempTaxonomy.length === 0) {
345
- // alert("No taxonomies to add.");
346
- // return;
347
- // }
344
+ if (tempTaxonomy.length === 0) {
345
+ alert("No taxonomies to add.");
346
+ return;
347
+ }
348
348
  try {
349
349
  await addMultipleTaxonomiesApi(url, tempTaxonomy);
350
350
  setTempTaxonomy([]);
@@ -360,6 +360,24 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
360
360
  }
361
361
  };
362
362
 
363
+ const addTaxonomyClick = async () => {
364
+ try {
365
+ await addTaxonomyApi(url, type, Number(newCode), newValue);
366
+
367
+ alert("Value added successfully");
368
+ const response = await fetchTaxonomiessApi(url);
369
+ const filteredTaxonomies = (response as { type: string }[]).filter(
370
+ (taxonomy: { type: string }) => taxonomy.type === type
371
+ );
372
+ setSimilarTaxonomies(filteredTaxonomies);
373
+ } catch (error) {
374
+ console.error("Error adding value:", error);
375
+ }
376
+ setIsModalOpen(false);
377
+ setNewCode("");
378
+ setNewValue("");
379
+ };
380
+
363
381
  const handleDeleteClick = async (id: string) => {
364
382
  try {
365
383
  await deleteTaxonomyApi(url, id);
@@ -898,7 +916,7 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
898
916
  <button
899
917
  onClick={
900
918
  // editTaxonomyItem ? handleEditTaxClick : handleAddClick
901
- editTaxonomyItem ? handleEditTaxClick : handleSaveClick
919
+ editTaxonomyItem ? handleEditTaxClick : addTaxonomyClick
902
920
  }
903
921
  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"
904
922
  >