eleven-solutions-common-website-unique-web 6.0.25 → 6.0.27

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,11 +13,30 @@ import { FaPlus } from "react-icons/fa";
13
13
  import { fetchTaxonomiessApi } from "../api/taxonomy";
14
14
  const Taxionomies = () => {
15
15
  const [taxonomy, setTaxonomy] = useState([]);
16
+ // const fetchTaxonomiesData = async () => {
17
+ // const data = await fetchTaxonomiessApi();
18
+ // if (data) {
19
+ // const uniqueTaxonomies = (data as any[]).reduce(
20
+ // (acc: any[], item: any) => {
21
+ // if (!acc.some((taxonomy) => taxonomy.type === item.type)) {
22
+ // acc.push(item);
23
+ // }
24
+ // return acc;
25
+ // },
26
+ // []
27
+ // );
28
+ // setTaxonomy(uniqueTaxonomies);
29
+ // } else {
30
+ // console.error("Failed to fetch taxonomies");
31
+ // }
32
+ // };
16
33
  const fetchTaxonomiesData = () => __awaiter(void 0, void 0, void 0, function* () {
17
34
  const data = yield fetchTaxonomiessApi();
18
35
  if (data) {
19
36
  const uniqueTaxonomies = data.reduce((acc, item) => {
20
- if (!acc.some((taxonomy) => taxonomy.type === item.type)) {
37
+ // Check if the taxonomy has no parentId and is unique by type
38
+ if (!item.parentId &&
39
+ !acc.some((taxonomy) => taxonomy.type === item.type)) {
21
40
  acc.push(item);
22
41
  }
23
42
  return acc;
@@ -291,7 +291,7 @@ const TaxonomyForm = () => {
291
291
  const hasChildren = allTaxonomies.some((item) => item.parentId === taxonomy.id);
292
292
  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: "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
293
  .filter((item) => item.parentId === taxonomy.id)
294
- .map((child) => (_jsxs("tr", { children: [_jsx("td", { className: "px-4 py-2 text-sm 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-2 text-sm text-gray-900 dark:text-white", children: child.value })] }, child.id))) })] }) }) }))] }, taxonomy.id));
294
+ .map((child) => (_jsxs("tr", { children: [_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
295
  }) })] }) }), 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
296
  const newTempTaxonomy = [...tempTaxonomy];
297
297
  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.25",
3
+ "version": "6.0.27",
4
4
  "main": "./dist/index.js",
5
5
  "scripts": {
6
6
  "build": "tsc",
@@ -7,12 +7,34 @@ import { fetchTaxonomiessApi } from "../api/taxonomy";
7
7
  const Taxionomies = () => {
8
8
  const [taxonomy, setTaxonomy] = useState<any[]>([]);
9
9
 
10
+ // const fetchTaxonomiesData = async () => {
11
+ // const data = await fetchTaxonomiessApi();
12
+ // if (data) {
13
+ // const uniqueTaxonomies = (data as any[]).reduce(
14
+ // (acc: any[], item: any) => {
15
+ // if (!acc.some((taxonomy) => taxonomy.type === item.type)) {
16
+ // acc.push(item);
17
+ // }
18
+ // return acc;
19
+ // },
20
+ // []
21
+ // );
22
+
23
+ // setTaxonomy(uniqueTaxonomies);
24
+ // } else {
25
+ // console.error("Failed to fetch taxonomies");
26
+ // }
27
+ // };
10
28
  const fetchTaxonomiesData = async () => {
11
29
  const data = await fetchTaxonomiessApi();
12
30
  if (data) {
13
31
  const uniqueTaxonomies = (data as any[]).reduce(
14
32
  (acc: any[], item: any) => {
15
- if (!acc.some((taxonomy) => taxonomy.type === item.type)) {
33
+ // Check if the taxonomy has no parentId and is unique by type
34
+ if (
35
+ !item.parentId &&
36
+ !acc.some((taxonomy) => taxonomy.type === item.type)
37
+ ) {
16
38
  acc.push(item);
17
39
  }
18
40
  return acc;
@@ -766,13 +766,13 @@ const TaxonomyForm = () => {
766
766
  )
767
767
  .map((child) => (
768
768
  <tr key={child.id}>
769
- <td className="px-4 py-2 text-sm text-gray-900 dark:text-white">
769
+ <td className="px-4 py-4 text-sm font-medium text-gray-900 dark:text-white">
770
770
  {child.type}
771
771
  </td>
772
772
  <td className="px-4 py-2 text-sm text-gray-500 dark:text-gray-400">
773
773
  {child.code}
774
774
  </td>
775
- <td className="px-4 py-2 text-sm text-gray-900 dark:text-white">
775
+ <td className="px-4 py-4 text-sm font-medium text-gray-900 dark:text-white">
776
776
  {child.value}
777
777
  </td>
778
778
  </tr>