eleven-solutions-common-website-unique-web 21.0.29 → 21.0.30

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.
@@ -247,36 +247,75 @@ const TaxonomyForm = ({ url }) => {
247
247
  setIsModalOpen(true);
248
248
  setIsAddingSubType(true);
249
249
  };
250
- const handleEditTaxClick = () => __awaiter(void 0, void 0, void 0, function* () {
251
- try {
252
- yield updateTaxonomyApi(url, selectedTaxonomyId, type, Number(newCode), newValue);
253
- alert("Taxonomy updated successfully");
254
- }
255
- catch (error) {
256
- console.error("Error updating Taxonomy:", error);
257
- }
258
- setIsModalOpen(false);
259
- setNewCode("");
260
- setNewValue("");
261
- const response = yield fetchTaxonomiessApi(url);
262
- const filteredTaxonomies = response.filter((taxonomy) => taxonomy.type === type);
263
- setSimilarTaxonomies(filteredTaxonomies);
264
- });
265
- const addTaxonomyClick = () => __awaiter(void 0, void 0, void 0, function* () {
250
+ // const handleEditTaxClick = async () => {
251
+ // try {
252
+ // await updateTaxonomyApi(
253
+ // url,
254
+ // selectedTaxonomyId,
255
+ // type,
256
+ // Number(newCode),
257
+ // newValue
258
+ // );
259
+ // alert("Taxonomy updated successfully");
260
+ // } catch (error) {
261
+ // console.error("Error updating Taxonomy:", error);
262
+ // }
263
+ // setIsModalOpen(false);
264
+ // setNewCode("");
265
+ // setNewValue("");
266
+ // const response = await fetchTaxonomiessApi(url);
267
+ // const filteredTaxonomies = (response as { type: string }[]).filter(
268
+ // (taxonomy: { type: string }) => taxonomy.type === type
269
+ // );
270
+ // setSimilarTaxonomies(filteredTaxonomies);
271
+ // };
272
+ // const addTaxonomyClick = async () => {
273
+ // if (!newCode || !newValue) {
274
+ // alert("Please fill out both Code and Value fields before adding.");
275
+ // return;
276
+ // }
277
+ // try {
278
+ // await addTaxonomyApi(url, type, Number(newCode), newValue);
279
+ // alert("Value added successfully");
280
+ // const response = await fetchTaxonomiessApi(url);
281
+ // const filteredTaxonomies = (response as { type: string }[]).filter(
282
+ // (taxonomy: { type: string }) => taxonomy.type === type
283
+ // );
284
+ // setSimilarTaxonomies(filteredTaxonomies);
285
+ // } catch (error) {
286
+ // console.error("Error adding value:", error);
287
+ // }
288
+ // setIsModalOpen(false);
289
+ // setNewCode("");
290
+ // setNewValue("");
291
+ // };
292
+ const handleSubmitClick = () => __awaiter(void 0, void 0, void 0, function* () {
266
293
  if (!newCode || !newValue) {
267
- alert("Please fill out both Code and Value fields before adding.");
294
+ alert("Please fill out both Code and Value fields before submitting.");
268
295
  return;
269
296
  }
270
297
  try {
271
- yield addTaxonomyApi(url, type, Number(newCode), newValue);
272
- alert("Value added successfully");
298
+ if (editTaxonomyItem || editTempTaxonomyItem) {
299
+ // Edit taxonomy logic
300
+ yield updateTaxonomyApi(url, selectedTaxonomyId, type, Number(newCode), newValue);
301
+ alert("Taxonomy updated successfully");
302
+ }
303
+ else {
304
+ // Add taxonomy logic
305
+ yield addTaxonomyApi(url, type, Number(newCode), newValue);
306
+ alert("Value added successfully");
307
+ }
308
+ // Fetch and update similar taxonomies
273
309
  const response = yield fetchTaxonomiessApi(url);
274
310
  const filteredTaxonomies = response.filter((taxonomy) => taxonomy.type === type);
275
311
  setSimilarTaxonomies(filteredTaxonomies);
276
312
  }
277
313
  catch (error) {
278
- console.error("Error adding value:", error);
314
+ console.error(editTaxonomyItem || editTempTaxonomyItem
315
+ ? "Error updating Taxonomy:"
316
+ : "Error adding value:", error);
279
317
  }
318
+ // Reset modal and input fields
280
319
  setIsModalOpen(false);
281
320
  setNewCode("");
282
321
  setNewValue("");
@@ -304,12 +343,10 @@ const TaxonomyForm = ({ url }) => {
304
343
  : "Add SubType"
305
344
  : editTaxonomyItem
306
345
  ? "Edit Values"
307
- : "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", {
346
+ : "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", {
308
347
  // onClick={
309
- // editTaxonomyItem
310
- // ? handleSubTypeEditClick
311
- // : handleSubTypeAddClick
348
+ // editTaxonomyItem ? handleEditTaxClick : addTaxonomyClick
312
349
  // }
313
- 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: 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" })] })] }))] }) })] }));
350
+ 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" })] })] }))] }) })] }));
314
351
  };
315
352
  export default TaxonomyForm;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleven-solutions-common-website-unique-web",
3
- "version": "21.0.29",
3
+ "version": "21.0.30",
4
4
  "main": "./dist/index.js",
5
5
  "scripts": {
6
6
  "build": "tsc",
@@ -323,46 +323,90 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
323
323
  setIsAddingSubType(true);
324
324
  };
325
325
 
326
- const handleEditTaxClick = async () => {
327
- try {
328
- await updateTaxonomyApi(
329
- url,
330
- selectedTaxonomyId,
331
- type,
332
- Number(newCode),
333
- newValue
334
- );
335
- alert("Taxonomy updated successfully");
336
- } catch (error) {
337
- console.error("Error updating Taxonomy:", error);
338
- }
339
- setIsModalOpen(false);
340
- setNewCode("");
341
- setNewValue("");
342
- const response = await fetchTaxonomiessApi(url);
343
- const filteredTaxonomies = (response as { type: string }[]).filter(
344
- (taxonomy: { type: string }) => taxonomy.type === type
345
- );
346
- setSimilarTaxonomies(filteredTaxonomies);
347
- };
326
+ // const handleEditTaxClick = async () => {
327
+ // try {
328
+ // await updateTaxonomyApi(
329
+ // url,
330
+ // selectedTaxonomyId,
331
+ // type,
332
+ // Number(newCode),
333
+ // newValue
334
+ // );
335
+ // alert("Taxonomy updated successfully");
336
+ // } catch (error) {
337
+ // console.error("Error updating Taxonomy:", error);
338
+ // }
339
+ // setIsModalOpen(false);
340
+ // setNewCode("");
341
+ // setNewValue("");
342
+ // const response = await fetchTaxonomiessApi(url);
343
+ // const filteredTaxonomies = (response as { type: string }[]).filter(
344
+ // (taxonomy: { type: string }) => taxonomy.type === type
345
+ // );
346
+ // setSimilarTaxonomies(filteredTaxonomies);
347
+ // };
348
+
349
+ // const addTaxonomyClick = async () => {
350
+ // if (!newCode || !newValue) {
351
+ // alert("Please fill out both Code and Value fields before adding.");
352
+ // return;
353
+ // }
354
+ // try {
355
+ // await addTaxonomyApi(url, type, Number(newCode), newValue);
356
+
357
+ // alert("Value added successfully");
358
+ // const response = await fetchTaxonomiessApi(url);
359
+ // const filteredTaxonomies = (response as { type: string }[]).filter(
360
+ // (taxonomy: { type: string }) => taxonomy.type === type
361
+ // );
362
+ // setSimilarTaxonomies(filteredTaxonomies);
363
+ // } catch (error) {
364
+ // console.error("Error adding value:", error);
365
+ // }
366
+ // setIsModalOpen(false);
367
+ // setNewCode("");
368
+ // setNewValue("");
369
+ // };
348
370
 
349
- const addTaxonomyClick = async () => {
371
+ const handleSubmitClick = async () => {
350
372
  if (!newCode || !newValue) {
351
- alert("Please fill out both Code and Value fields before adding.");
373
+ alert("Please fill out both Code and Value fields before submitting.");
352
374
  return;
353
375
  }
376
+
354
377
  try {
355
- await addTaxonomyApi(url, type, Number(newCode), newValue);
378
+ if (editTaxonomyItem || editTempTaxonomyItem) {
379
+ // Edit taxonomy logic
380
+ await updateTaxonomyApi(
381
+ url,
382
+ selectedTaxonomyId,
383
+ type,
384
+ Number(newCode),
385
+ newValue
386
+ );
387
+ alert("Taxonomy updated successfully");
388
+ } else {
389
+ // Add taxonomy logic
390
+ await addTaxonomyApi(url, type, Number(newCode), newValue);
391
+ alert("Value added successfully");
392
+ }
356
393
 
357
- alert("Value added successfully");
394
+ // Fetch and update similar taxonomies
358
395
  const response = await fetchTaxonomiessApi(url);
359
396
  const filteredTaxonomies = (response as { type: string }[]).filter(
360
397
  (taxonomy: { type: string }) => taxonomy.type === type
361
398
  );
362
399
  setSimilarTaxonomies(filteredTaxonomies);
363
400
  } catch (error) {
364
- console.error("Error adding value:", error);
401
+ console.error(
402
+ editTaxonomyItem || editTempTaxonomyItem
403
+ ? "Error updating Taxonomy:"
404
+ : "Error adding value:",
405
+ error
406
+ );
365
407
  }
408
+
409
+ // Reset modal and input fields
366
410
  setIsModalOpen(false);
367
411
  setNewCode("");
368
412
  setNewValue("");
@@ -744,11 +788,6 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
744
788
  />
745
789
  <div className="flex space-x-4 justify-end">
746
790
  <button
747
- // onClick={
748
- // editTaxonomyItem
749
- // ? handleSubTypeEditClick
750
- // : handleSubTypeAddClick
751
- // }
752
791
  onClick={handleSubTypeSubmitClick}
753
792
  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"
754
793
  >
@@ -787,9 +826,10 @@ const TaxonomyForm = ({ url }: TaxionomyFormProps) => {
787
826
 
788
827
  <div className="flex space-x-4 justify-end">
789
828
  <button
790
- onClick={
791
- editTaxonomyItem ? handleEditTaxClick : addTaxonomyClick
792
- }
829
+ // onClick={
830
+ // editTaxonomyItem ? handleEditTaxClick : addTaxonomyClick
831
+ // }
832
+ onClick={handleSubmitClick}
793
833
  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"
794
834
  >
795
835
  {editTaxonomyItem || editTempTaxonomyItem ? "Edit" : "Add"}