eleven-solutions-common-website-unique-web 6.0.29 → 6.0.31

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,9 +47,6 @@ const TaxonomyForm = () => {
47
47
  fetchAllTaxonomies();
48
48
  }, []);
49
49
  // Fetch child taxonomies for a parentId
50
- const getChildTaxonomies = (parentId) => {
51
- return allTaxonomies.filter((taxonomy) => taxonomy.parentId === parentId);
52
- };
53
50
  const toggleRowExpansion = (taxonomyId) => {
54
51
  setExpandedRows((prevExpandedRows) => prevExpandedRows.indexOf(taxonomyId) !== -1
55
52
  ? prevExpandedRows.filter((id) => id !== taxonomyId) // Collapse row
@@ -230,12 +227,29 @@ const TaxonomyForm = () => {
230
227
  try {
231
228
  yield addSubTypeApi(selectedTaxonomyId, subType, Number(subCode), subValue);
232
229
  alert("SubType added successfully");
230
+ const fetchedTaxonomies = yield fetchTaxonomiessApi();
231
+ if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
232
+ setAllTaxonomies(fetchedTaxonomies);
233
+ }
233
234
  }
234
235
  catch (error) {
235
236
  console.error("Error adding SubType:", error);
236
237
  }
237
238
  setIsModalOpen(false);
239
+ setSubType("");
240
+ setSubCode("");
241
+ setSubValue("");
238
242
  });
243
+ const handleSubEdit = (index, id) => {
244
+ setIsAddingSubType(false);
245
+ const item = similarTaxonomies[index];
246
+ setSelectedTaxonomyId(id);
247
+ setEditTaxonomyItem(item);
248
+ setSubType(item.type);
249
+ setSubCode(item.code);
250
+ setSubValue(item.value);
251
+ setIsModalOpen(true);
252
+ };
239
253
  const handleEditTaxClick = () => __awaiter(void 0, void 0, void 0, function* () {
240
254
  try {
241
255
  yield updateTaxonomyApi(selectedTaxonomyId, type, Number(newCode), newValue);
@@ -291,7 +305,7 @@ const TaxonomyForm = () => {
291
305
  const hasChildren = allTaxonomies.some((item) => item.parentId === taxonomy.id);
292
306
  return (_jsxs(React.Fragment, { children: [_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: () => 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", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "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: () => handleEditClick(index, taxonomy.id), 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", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "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: () => handleAddSubType(index, taxonomy.id), 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", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "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: _jsxs("div", { className: "flex justify-between items-center", children: [_jsx("span", { children: taxonomy.value }), hasChildren && (_jsx("button", { type: "button", onClick: () => toggleRowExpansion(taxonomy.id), className: "text-gray-500 transition-colors duration-200 dark:hover:text-blue-600 dark:text-gray-300 hover:text-blue-500 focus:outline-none", children: expandedRows.indexOf(taxonomy.id) !== -1 ? (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" }) })) : (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 15.75l-7.5-7.5-7.5 7.5" }) })) }))] }) })] }, index), expandedRows.indexOf(taxonomy.id) !== -1 && (_jsx("tr", { children: _jsx("td", { colSpan: 3, className: "bg-gray-100 dark:bg-gray-900", children: _jsxs("table", { className: "min-w-full divide-y divide-gray-200 dark:divide-gray-700", children: [_jsx("thead", { children: _jsxs("tr", { children: [_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: "Sub Type" }), _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", { children: allTaxonomies
293
307
  .filter((item) => item.parentId === taxonomy.id)
294
- .map((child) => (_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: () => 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", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "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: () => handleEditClick(index, taxonomy.id), 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", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "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("td", { className: "px-4 py-4 text-sm font-medium text-gray-900 dark:text-white", children: child.type }), _jsx("td", { className: "px-4 py-2 text-sm text-gray-500 dark:text-gray-400", children: child.code }), _jsx("td", { className: "px-4 py-4 text-sm font-medium text-gray-900 dark:text-white", children: child.value })] }, child.id))) })] }) }) }))] }, taxonomy.id));
308
+ .map((child) => (_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: () => 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", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "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: () => handleSubEdit(index, taxonomy.id), 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", strokeWidth: "1.5", stroke: "currentColor", className: "w-5 h-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "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("td", { className: "px-4 py-4 text-sm font-medium text-gray-900 dark:text-white", children: child.type }), _jsx("td", { className: "px-4 py-2 text-sm text-gray-500 dark:text-gray-400", children: child.code }), _jsx("td", { className: "px-4 py-4 text-sm font-medium text-gray-900 dark:text-white", children: child.value })] }, child.id))) })] }) }) }))] }, taxonomy.id));
295
309
  }) })] }) }), 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: () => {
296
310
  const newTempTaxonomy = [...tempTaxonomy];
297
311
  newTempTaxonomy.splice(index, 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleven-solutions-common-website-unique-web",
3
- "version": "6.0.29",
3
+ "version": "6.0.31",
4
4
  "main": "./dist/index.js",
5
5
  "scripts": {
6
6
  "build": "tsc",
@@ -57,9 +57,7 @@ const TaxonomyForm = () => {
57
57
  }, []);
58
58
 
59
59
  // Fetch child taxonomies for a parentId
60
- const getChildTaxonomies = (parentId: number) => {
61
- return allTaxonomies.filter((taxonomy) => taxonomy.parentId === parentId);
62
- };
60
+
63
61
  const toggleRowExpansion = (taxonomyId: number) => {
64
62
  setExpandedRows(
65
63
  (prevExpandedRows) =>
@@ -286,10 +284,30 @@ const TaxonomyForm = () => {
286
284
  subValue
287
285
  );
288
286
  alert("SubType added successfully");
287
+ const fetchedTaxonomies = await fetchTaxonomiessApi();
288
+ if (fetchedTaxonomies && Array.isArray(fetchedTaxonomies)) {
289
+ setAllTaxonomies(fetchedTaxonomies);
290
+ }
289
291
  } catch (error) {
290
292
  console.error("Error adding SubType:", error);
291
293
  }
292
294
  setIsModalOpen(false);
295
+ setSubType("");
296
+ setSubCode("");
297
+ setSubValue("");
298
+ };
299
+
300
+ const handleSubEdit = (index: number, id: string) => {
301
+ setIsAddingSubType(false);
302
+
303
+ const item = similarTaxonomies[index];
304
+ setSelectedTaxonomyId(id);
305
+
306
+ setEditTaxonomyItem(item);
307
+ setSubType(item.type);
308
+ setSubCode(item.code);
309
+ setSubValue(item.value);
310
+ setIsModalOpen(true);
293
311
  };
294
312
 
295
313
  const handleEditTaxClick = async () => {
@@ -493,122 +511,7 @@ const TaxonomyForm = () => {
493
511
  </th>
494
512
  </tr>
495
513
  </thead>
496
- {/* <tbody className="divide-y divide-gray-200">
497
- {similarTaxonomies.map((taxonomy, index) => {
498
- return (
499
- <tr key={index}>
500
- {similarTaxonomies.some(
501
- (taxonomy) => taxonomy.isEdit
502
- ) && (
503
- <td className="px-4 py-4 text-sm whitespace-nowrap">
504
- <div className="flex items-center gap-x-6">
505
- <button
506
- type="button"
507
- onClick={() => handleDeleteClick(taxonomy.id)}
508
- className="text-gray-500 transition-colors duration-200 dark:hover:text-red-600 dark:text-gray-300 hover:text-red-500 focus:outline-none"
509
- >
510
- <svg
511
- xmlns="http://www.w3.org/2000/svg"
512
- fill="none"
513
- viewBox="0 0 24 24"
514
- strokeWidth="1.5"
515
- stroke="currentColor"
516
- className="w-5 h-5"
517
- >
518
- <path
519
- strokeLinecap="round"
520
- strokeLinejoin="round"
521
- 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"
522
- />
523
- </svg>
524
- </button>
525
-
526
- <button
527
- type="button"
528
- onClick={() =>
529
- handleEditClick(index, taxonomy.id)
530
- }
531
- className="text-gray-500 transition-colors duration-200 dark:hover:text-yellow-500 dark:text-gray-300 hover:text-yellow-500 focus:outline-none"
532
- >
533
- <svg
534
- xmlns="http://www.w3.org/2000/svg"
535
- fill="none"
536
- viewBox="0 0 24 24"
537
- strokeWidth="1.5"
538
- stroke="currentColor"
539
- className="w-5 h-5"
540
- >
541
- <path
542
- strokeLinecap="round"
543
- strokeLinejoin="round"
544
- 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"
545
- />
546
- </svg>
547
- </button>
548
514
 
549
- <button
550
- type="button"
551
- onClick={() =>
552
- handleAddSubType(index, taxonomy.id)
553
- }
554
- className="text-gray-500 transition-colors duration-200 dark:hover:text-blue-500 dark:text-gray-300 hover:text-blue-500 focus:outline-none"
555
- >
556
- <svg
557
- xmlns="http://www.w3.org/2000/svg"
558
- fill="none"
559
- viewBox="0 0 24 24"
560
- strokeWidth="1.5"
561
- stroke="currentColor"
562
- className="w-5 h-5"
563
- >
564
- <path
565
- strokeLinecap="round"
566
- strokeLinejoin="round"
567
- d="M12 4.5v15m7.5-7.5h-15"
568
- />
569
- </svg>
570
- </button>
571
- </div>
572
- </td>
573
- )}
574
-
575
- <td className="px-4 py-4 text-sm text-gray-500 dark:text-gray-400">
576
- {taxonomy.code}
577
- </td>
578
-
579
- <td className="px-4 py-4 text-sm font-medium text-gray-900 dark:text-white">
580
- <div className="flex justify-between items-center">
581
- <span>{taxonomy.value}</span>
582
-
583
- {allTaxonomies.some(
584
- (item) => item.parentId === taxonomy.id
585
- ) && (
586
- <button
587
- type="button"
588
- className="text-gray-500 transition-colors duration-200 dark:hover:text-blue-600 dark:text-gray-300 hover:text-blue-500 focus:outline-none"
589
- >
590
- <svg
591
- xmlns="http://www.w3.org/2000/svg"
592
- fill="none"
593
- viewBox="0 0 24 24"
594
- strokeWidth="1.5"
595
- stroke="currentColor"
596
- className="w-5 h-5"
597
- >
598
- <path
599
- strokeLinecap="round"
600
- strokeLinejoin="round"
601
- d="M19.5 8.25l-7.5 7.5-7.5-7.5"
602
- />
603
- </svg>
604
- </button>
605
- )}
606
- </div>
607
- </td>
608
- </tr>
609
- );
610
- })}
611
- </tbody> */}
612
515
  <tbody className="divide-y divide-gray-200">
613
516
  {similarTaxonomies.map((taxonomy, index) => {
614
517
  const hasChildren = allTaxonomies.some(
@@ -797,7 +700,7 @@ const TaxonomyForm = () => {
797
700
  <button
798
701
  type="button"
799
702
  onClick={() =>
800
- handleEditClick(
703
+ handleSubEdit(
801
704
  index,
802
705
  taxonomy.id
803
706
  )