eleven-solutions-common-website-unique-web 6.0.14 → 6.0.16
Sign up to get free protection for your applications and to get access to all the features.
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
});
|
9
9
|
};
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
11
|
+
import React from "react";
|
11
12
|
import { useState, useEffect } from "react";
|
12
13
|
import { addTaxonomyApi, fetchTaxonomyByIdApi, updateTaxonomyApi, fetchTaxonomiessApi, addMultipleTaxonomiesApi, deleteTaxonomyApi, isMultipleApi, addSubTypeApi, } from "../api/taxonomy";
|
13
14
|
import { FaPlus } from "react-icons/fa";
|
@@ -49,6 +50,12 @@ const TaxonomyForm = () => {
|
|
49
50
|
const getChildTaxonomies = (parentId) => {
|
50
51
|
return allTaxonomies.filter((taxonomy) => taxonomy.parentId === parentId);
|
51
52
|
};
|
53
|
+
const toggleRowExpansion = (taxonomyId) => {
|
54
|
+
setExpandedRows((prevExpandedRows) => prevExpandedRows.indexOf(taxonomyId) !== -1
|
55
|
+
? prevExpandedRows.filter((id) => id !== taxonomyId) // Collapse row
|
56
|
+
: [...prevExpandedRows, taxonomyId] // Expand row
|
57
|
+
);
|
58
|
+
};
|
52
59
|
const [editTaxonomyItem, setEditTaxonomyItem] = useState(null);
|
53
60
|
const [editTempTaxonomyItem, setEditTempTaxonomyItem] = useState(null);
|
54
61
|
const [selectedTaxonomyId, setSelectedTaxonomyId] = useState("");
|
@@ -281,7 +288,10 @@ const TaxonomyForm = () => {
|
|
281
288
|
window.location.href = "/admin/taxinomies";
|
282
289
|
}, 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: "Delete" })) })) }), _jsxs("div", { className: "flex space-x-4 justify-end", children: [similarTaxonomies.some((taxonomy) => taxonomy.isEdit) && (_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" })), !similarTaxonomies.some((taxonomy) => taxonomy.isEdit) &&
|
283
290
|
!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) => {
|
284
|
-
|
291
|
+
const hasChildren = allTaxonomies.some((item) => item.parentId === taxonomy.id);
|
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-2 text-sm font-normal text-left text-gray-500 dark:text-gray-400", children: "Child Code" }), _jsx("th", { className: "px-4 py-2 text-sm font-normal text-left text-gray-500 dark:text-gray-400", children: "Child Value" })] }) }), _jsx("tbody", { children: allTaxonomies
|
293
|
+
.filter((item) => item.parentId === taxonomy.id)
|
294
|
+
.map((child) => (_jsxs("tr", { children: [_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));
|
285
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: () => {
|
286
296
|
const newTempTaxonomy = [...tempTaxonomy];
|
287
297
|
newTempTaxonomy.splice(index, 1);
|
package/package.json
CHANGED
@@ -60,6 +60,14 @@ const TaxonomyForm = () => {
|
|
60
60
|
const getChildTaxonomies = (parentId: number) => {
|
61
61
|
return allTaxonomies.filter((taxonomy) => taxonomy.parentId === parentId);
|
62
62
|
};
|
63
|
+
const toggleRowExpansion = (taxonomyId: number) => {
|
64
|
+
setExpandedRows(
|
65
|
+
(prevExpandedRows) =>
|
66
|
+
prevExpandedRows.indexOf(taxonomyId) !== -1
|
67
|
+
? prevExpandedRows.filter((id) => id !== taxonomyId) // Collapse row
|
68
|
+
: [...prevExpandedRows, taxonomyId] // Expand row
|
69
|
+
);
|
70
|
+
};
|
63
71
|
|
64
72
|
const [editTaxonomyItem, setEditTaxonomyItem] = useState<{
|
65
73
|
id: string;
|
@@ -485,7 +493,7 @@ const TaxonomyForm = () => {
|
|
485
493
|
</th>
|
486
494
|
</tr>
|
487
495
|
</thead>
|
488
|
-
<tbody className="divide-y divide-gray-200">
|
496
|
+
{/* <tbody className="divide-y divide-gray-200">
|
489
497
|
{similarTaxonomies.map((taxonomy, index) => {
|
490
498
|
return (
|
491
499
|
<tr key={index}>
|
@@ -600,6 +608,188 @@ const TaxonomyForm = () => {
|
|
600
608
|
</tr>
|
601
609
|
);
|
602
610
|
})}
|
611
|
+
</tbody> */}
|
612
|
+
<tbody className="divide-y divide-gray-200">
|
613
|
+
{similarTaxonomies.map((taxonomy, index) => {
|
614
|
+
const hasChildren = allTaxonomies.some(
|
615
|
+
(item) => item.parentId === taxonomy.id
|
616
|
+
);
|
617
|
+
return (
|
618
|
+
<React.Fragment key={taxonomy.id}>
|
619
|
+
<tr key={index}>
|
620
|
+
{/* <td className="px-4 py-4 text-sm whitespace-nowrap"> */}
|
621
|
+
{/* <div className="flex items-center gap-x-6">
|
622
|
+
<button
|
623
|
+
type="button"
|
624
|
+
onClick={() =>
|
625
|
+
console.log("Edit clicked", taxonomy.id)
|
626
|
+
}
|
627
|
+
className="text-gray-500 transition-colors duration-200 dark:hover:text-yellow-500 dark:text-gray-300 hover:text-yellow-500 focus:outline-none"
|
628
|
+
>
|
629
|
+
Edit
|
630
|
+
</button>
|
631
|
+
</div> */}
|
632
|
+
<td className="px-4 py-4 text-sm whitespace-nowrap">
|
633
|
+
<div className="flex items-center gap-x-6">
|
634
|
+
<button
|
635
|
+
type="button"
|
636
|
+
onClick={() => handleDeleteClick(taxonomy.id)}
|
637
|
+
className="text-gray-500 transition-colors duration-200 dark:hover:text-red-600 dark:text-gray-300 hover:text-red-500 focus:outline-none"
|
638
|
+
>
|
639
|
+
<svg
|
640
|
+
xmlns="http://www.w3.org/2000/svg"
|
641
|
+
fill="none"
|
642
|
+
viewBox="0 0 24 24"
|
643
|
+
strokeWidth="1.5"
|
644
|
+
stroke="currentColor"
|
645
|
+
className="w-5 h-5"
|
646
|
+
>
|
647
|
+
<path
|
648
|
+
strokeLinecap="round"
|
649
|
+
strokeLinejoin="round"
|
650
|
+
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"
|
651
|
+
/>
|
652
|
+
</svg>
|
653
|
+
</button>
|
654
|
+
|
655
|
+
<button
|
656
|
+
type="button"
|
657
|
+
onClick={() =>
|
658
|
+
handleEditClick(index, taxonomy.id)
|
659
|
+
}
|
660
|
+
className="text-gray-500 transition-colors duration-200 dark:hover:text-yellow-500 dark:text-gray-300 hover:text-yellow-500 focus:outline-none"
|
661
|
+
>
|
662
|
+
<svg
|
663
|
+
xmlns="http://www.w3.org/2000/svg"
|
664
|
+
fill="none"
|
665
|
+
viewBox="0 0 24 24"
|
666
|
+
strokeWidth="1.5"
|
667
|
+
stroke="currentColor"
|
668
|
+
className="w-5 h-5"
|
669
|
+
>
|
670
|
+
<path
|
671
|
+
strokeLinecap="round"
|
672
|
+
strokeLinejoin="round"
|
673
|
+
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"
|
674
|
+
/>
|
675
|
+
</svg>
|
676
|
+
</button>
|
677
|
+
|
678
|
+
<button
|
679
|
+
type="button"
|
680
|
+
onClick={() =>
|
681
|
+
handleAddSubType(index, taxonomy.id)
|
682
|
+
}
|
683
|
+
className="text-gray-500 transition-colors duration-200 dark:hover:text-blue-500 dark:text-gray-300 hover:text-blue-500 focus:outline-none"
|
684
|
+
>
|
685
|
+
<svg
|
686
|
+
xmlns="http://www.w3.org/2000/svg"
|
687
|
+
fill="none"
|
688
|
+
viewBox="0 0 24 24"
|
689
|
+
strokeWidth="1.5"
|
690
|
+
stroke="currentColor"
|
691
|
+
className="w-5 h-5"
|
692
|
+
>
|
693
|
+
<path
|
694
|
+
strokeLinecap="round"
|
695
|
+
strokeLinejoin="round"
|
696
|
+
d="M12 4.5v15m7.5-7.5h-15"
|
697
|
+
/>
|
698
|
+
</svg>
|
699
|
+
</button>
|
700
|
+
</div>
|
701
|
+
</td>
|
702
|
+
{/* </td> */}
|
703
|
+
<td className="px-4 py-4 text-sm text-gray-500 dark:text-gray-400">
|
704
|
+
{taxonomy.code}
|
705
|
+
</td>
|
706
|
+
<td className="px-4 py-4 text-sm font-medium text-gray-900 dark:text-white">
|
707
|
+
<div className="flex justify-between items-center">
|
708
|
+
<span>{taxonomy.value}</span>
|
709
|
+
{hasChildren && (
|
710
|
+
<button
|
711
|
+
type="button"
|
712
|
+
onClick={() =>
|
713
|
+
toggleRowExpansion(taxonomy.id)
|
714
|
+
}
|
715
|
+
className="text-gray-500 transition-colors duration-200 dark:hover:text-blue-600 dark:text-gray-300 hover:text-blue-500 focus:outline-none"
|
716
|
+
>
|
717
|
+
{expandedRows.indexOf(taxonomy.id) !== -1 ? (
|
718
|
+
<svg
|
719
|
+
xmlns="http://www.w3.org/2000/svg"
|
720
|
+
fill="none"
|
721
|
+
viewBox="0 0 24 24"
|
722
|
+
strokeWidth="1.5"
|
723
|
+
stroke="currentColor"
|
724
|
+
className="w-5 h-5"
|
725
|
+
>
|
726
|
+
<path
|
727
|
+
strokeLinecap="round"
|
728
|
+
strokeLinejoin="round"
|
729
|
+
d="M19.5 8.25l-7.5 7.5-7.5-7.5"
|
730
|
+
/>
|
731
|
+
</svg>
|
732
|
+
) : (
|
733
|
+
<svg
|
734
|
+
xmlns="http://www.w3.org/2000/svg"
|
735
|
+
fill="none"
|
736
|
+
viewBox="0 0 24 24"
|
737
|
+
strokeWidth="1.5"
|
738
|
+
stroke="currentColor"
|
739
|
+
className="w-5 h-5"
|
740
|
+
>
|
741
|
+
<path
|
742
|
+
strokeLinecap="round"
|
743
|
+
strokeLinejoin="round"
|
744
|
+
d="M19.5 15.75l-7.5-7.5-7.5 7.5"
|
745
|
+
/>
|
746
|
+
</svg>
|
747
|
+
)}
|
748
|
+
</button>
|
749
|
+
)}
|
750
|
+
</div>
|
751
|
+
</td>
|
752
|
+
</tr>
|
753
|
+
{expandedRows.indexOf(taxonomy.id) !== -1 && (
|
754
|
+
<tr>
|
755
|
+
<td
|
756
|
+
colSpan={3}
|
757
|
+
className="bg-gray-100 dark:bg-gray-900"
|
758
|
+
>
|
759
|
+
<table className="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
|
760
|
+
<thead>
|
761
|
+
<tr>
|
762
|
+
<th className="px-4 py-2 text-sm font-normal text-left text-gray-500 dark:text-gray-400">
|
763
|
+
Child Code
|
764
|
+
</th>
|
765
|
+
<th className="px-4 py-2 text-sm font-normal text-left text-gray-500 dark:text-gray-400">
|
766
|
+
Child Value
|
767
|
+
</th>
|
768
|
+
</tr>
|
769
|
+
</thead>
|
770
|
+
<tbody>
|
771
|
+
{allTaxonomies
|
772
|
+
.filter(
|
773
|
+
(item) => item.parentId === taxonomy.id
|
774
|
+
)
|
775
|
+
.map((child) => (
|
776
|
+
<tr key={child.id}>
|
777
|
+
<td className="px-4 py-2 text-sm text-gray-500 dark:text-gray-400">
|
778
|
+
{child.code}
|
779
|
+
</td>
|
780
|
+
<td className="px-4 py-2 text-sm text-gray-900 dark:text-white">
|
781
|
+
{child.value}
|
782
|
+
</td>
|
783
|
+
</tr>
|
784
|
+
))}
|
785
|
+
</tbody>
|
786
|
+
</table>
|
787
|
+
</td>
|
788
|
+
</tr>
|
789
|
+
)}
|
790
|
+
</React.Fragment>
|
791
|
+
);
|
792
|
+
})}
|
603
793
|
</tbody>
|
604
794
|
</table>
|
605
795
|
</div>
|