inboxlookup_screen 1.0.15 → 1.0.17
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.
package/package.json
CHANGED
|
@@ -13,23 +13,13 @@ import CustomStore from 'devextreme/data/custom_store';
|
|
|
13
13
|
import Popup from 'devextreme-react/popup';
|
|
14
14
|
import 'devextreme/dist/css/dx.light.css';
|
|
15
15
|
|
|
16
|
-
const STORAGE_KEY = "ORDERS_MASTER_DETAIL_SEARCH_HISTORY";
|
|
17
|
-
|
|
18
16
|
|
|
19
17
|
const OrdersMasterDetail = ({ dataSource, keyExpr, token, BaseUrl, ProjectId }) => {
|
|
20
|
-
const DEFAULT_SERVICE = {
|
|
21
|
-
projectId: ProjectId,
|
|
22
|
-
id: 4,
|
|
23
|
-
status: "Active" // optional for left list rendering
|
|
24
|
-
};
|
|
25
|
-
console.log("token, BaseUrl, ProjectId", token, BaseUrl, ProjectId);
|
|
26
18
|
const [orders, setOrders] = useState([]);
|
|
27
19
|
const [selectedOrder, setSelectedOrder] = useState(null);
|
|
28
|
-
const [selectedService, setSelectedService] = useState(DEFAULT_SERVICE);
|
|
29
20
|
const saveButtonRef = useRef(null);
|
|
30
21
|
const [rowDetailsVisible, setRowDetailsVisible] = useState(false);
|
|
31
22
|
const [selectedRow, setSelectedRow] = useState(null);
|
|
32
|
-
const [searchPopupVisible, setSearchPopupVisible] = useState(false);
|
|
33
23
|
const [searchText, setSearchText] = useState("");
|
|
34
24
|
const [category, setCategory] = useState(0);
|
|
35
25
|
const [status, setStatus] = useState(0);
|
|
@@ -68,8 +58,6 @@ const OrdersMasterDetail = ({ dataSource, keyExpr, token, BaseUrl, ProjectId })
|
|
|
68
58
|
useEffect(() => {
|
|
69
59
|
if (!ProjectId) return; // ⛔ guard
|
|
70
60
|
|
|
71
|
-
console.log("ProjectId", ProjectId, BaseUrl);
|
|
72
|
-
|
|
73
61
|
axios.get(
|
|
74
62
|
`${BaseUrl}api/LookupSheetMaster/GetLatestSheetsByProject/${ProjectId}`,
|
|
75
63
|
{
|
|
@@ -97,6 +85,37 @@ const OrdersMasterDetail = ({ dataSource, keyExpr, token, BaseUrl, ProjectId })
|
|
|
97
85
|
|
|
98
86
|
}, [ProjectId, BaseUrl, token]); // ✅ FIXED
|
|
99
87
|
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
// ⛔ Project changed → FULL RESET
|
|
90
|
+
|
|
91
|
+
setOrders([]);
|
|
92
|
+
setFilteredOrders([]);
|
|
93
|
+
|
|
94
|
+
setSelectedOrder(null);
|
|
95
|
+
setSelectedService(null);
|
|
96
|
+
|
|
97
|
+
setGridStore(null);
|
|
98
|
+
setColumns([]);
|
|
99
|
+
|
|
100
|
+
setSelectedRow(null);
|
|
101
|
+
setRowDetailsVisible(false);
|
|
102
|
+
|
|
103
|
+
setSearchText("");
|
|
104
|
+
setGridSearchText("");
|
|
105
|
+
|
|
106
|
+
setSelectedRowKeys([]);
|
|
107
|
+
setExcludedKeys([]);
|
|
108
|
+
setSelectAll(false);
|
|
109
|
+
setWasFullyDeselected(false);
|
|
110
|
+
setFinalCount(0);
|
|
111
|
+
|
|
112
|
+
if (gridInstance) {
|
|
113
|
+
gridInstance.clearSelection();
|
|
114
|
+
gridInstance.searchByText("");
|
|
115
|
+
gridInstance.pageIndex(0);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
}, [ProjectId]); // 🔥 THIS is the key
|
|
100
119
|
|
|
101
120
|
useEffect(() => {
|
|
102
121
|
if (!orders) return;
|
|
@@ -123,7 +142,6 @@ const OrdersMasterDetail = ({ dataSource, keyExpr, token, BaseUrl, ProjectId })
|
|
|
123
142
|
|
|
124
143
|
if (!sheet) return;
|
|
125
144
|
setSelectedOrder(sheet);
|
|
126
|
-
setSelectedService(sheet);
|
|
127
145
|
|
|
128
146
|
await loadColumns(sheet.id);
|
|
129
147
|
|
|
@@ -522,53 +540,6 @@ const OrdersMasterDetail = ({ dataSource, keyExpr, token, BaseUrl, ProjectId })
|
|
|
522
540
|
};
|
|
523
541
|
|
|
524
542
|
|
|
525
|
-
useEffect(() => {
|
|
526
|
-
fetch(`/api/search-history/1`)
|
|
527
|
-
.then(res => res.ok ? res.json() : [])
|
|
528
|
-
.then(data => {
|
|
529
|
-
if (data.length) {
|
|
530
|
-
setSearchHistory(data);
|
|
531
|
-
searchHistoryRef.current = data;
|
|
532
|
-
sessionStorage.setItem(STORAGE_KEY, JSON.stringify(data));
|
|
533
|
-
} else {
|
|
534
|
-
const stored = JSON.parse(sessionStorage.getItem(STORAGE_KEY)) || [];
|
|
535
|
-
setSearchHistory(stored);
|
|
536
|
-
searchHistoryRef.current = stored;
|
|
537
|
-
}
|
|
538
|
-
})
|
|
539
|
-
.catch(() => {
|
|
540
|
-
const stored = JSON.parse(sessionStorage.getItem(STORAGE_KEY)) || [];
|
|
541
|
-
setSearchHistory(stored);
|
|
542
|
-
searchHistoryRef.current = stored;
|
|
543
|
-
});
|
|
544
|
-
}, []);
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
useEffect(() => {
|
|
549
|
-
const handleStorageChange = (e) => {
|
|
550
|
-
if (e.key === STORAGE_KEY) {
|
|
551
|
-
const updated = JSON.parse(e.newValue) || [];
|
|
552
|
-
setSearchHistory(updated);
|
|
553
|
-
searchHistoryRef.current = updated;
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
window.addEventListener("storage", handleStorageChange);
|
|
557
|
-
return () => window.removeEventListener("storage", handleStorageChange);
|
|
558
|
-
}, []);
|
|
559
|
-
|
|
560
|
-
const updateSearchHistoryAPI = () => {
|
|
561
|
-
if (!searchHistoryRef.current.length) return;
|
|
562
|
-
|
|
563
|
-
navigator.sendBeacon(
|
|
564
|
-
"/api/search-history",
|
|
565
|
-
JSON.stringify({
|
|
566
|
-
userId: 1,
|
|
567
|
-
history: searchHistoryRef.current
|
|
568
|
-
})
|
|
569
|
-
);
|
|
570
|
-
};
|
|
571
|
-
|
|
572
543
|
useEffect(() => {
|
|
573
544
|
const handleVisibilityChange = () => {
|
|
574
545
|
if (document.visibilityState === "hidden") {
|
|
@@ -637,7 +608,6 @@ const OrdersMasterDetail = ({ dataSource, keyExpr, token, BaseUrl, ProjectId })
|
|
|
637
608
|
|
|
638
609
|
// ✅ Update selected service
|
|
639
610
|
setSelectedOrder(sheet);
|
|
640
|
-
setSelectedService(sheet);
|
|
641
611
|
await loadColumns(sheet.id);
|
|
642
612
|
|
|
643
613
|
// ✅ Reset grid state BEFORE assigning new store
|
|
@@ -720,10 +690,7 @@ const OrdersMasterDetail = ({ dataSource, keyExpr, token, BaseUrl, ProjectId })
|
|
|
720
690
|
showBorders={true}
|
|
721
691
|
allowColumnReordering={true}
|
|
722
692
|
onColumnReordered={(e) => {
|
|
723
|
-
|
|
724
|
-
console.log("From:", e.fromIndex);
|
|
725
|
-
console.log("To:", e.toIndex);
|
|
726
|
-
console.log("Field:", e.column.dataField);
|
|
693
|
+
|
|
727
694
|
}}
|
|
728
695
|
// onColumnReordered={handleColumnReorder}
|
|
729
696
|
columnHidingEnabled={false}
|
|
@@ -822,92 +789,6 @@ const OrdersMasterDetail = ({ dataSource, keyExpr, token, BaseUrl, ProjectId })
|
|
|
822
789
|
</div>
|
|
823
790
|
</Popup>
|
|
824
791
|
)}
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
<Popup
|
|
828
|
-
visible={searchPopupVisible}
|
|
829
|
-
onHiding={() => setSearchPopupVisible(false)}
|
|
830
|
-
showTitle
|
|
831
|
-
title="Search History"
|
|
832
|
-
width={360}
|
|
833
|
-
height="100%"
|
|
834
|
-
dragEnabled={false}
|
|
835
|
-
closeOnOutsideClick
|
|
836
|
-
showCloseButton
|
|
837
|
-
position={{
|
|
838
|
-
my: "right top",
|
|
839
|
-
at: "right top",
|
|
840
|
-
of: window
|
|
841
|
-
}}
|
|
842
|
-
wrapperAttr={{ class: "right-search-popup" }}
|
|
843
|
-
>
|
|
844
|
-
<div style={{ padding: 16, height: "100%" }}>
|
|
845
|
-
{searchHistory.length > 0 ? (
|
|
846
|
-
<ul
|
|
847
|
-
style={{
|
|
848
|
-
listStyle: "none",
|
|
849
|
-
padding: 0,
|
|
850
|
-
margin: 0,
|
|
851
|
-
height: "100%",
|
|
852
|
-
overflowY: "auto"
|
|
853
|
-
}}
|
|
854
|
-
>
|
|
855
|
-
{searchHistory.map((s, i) => (
|
|
856
|
-
<li
|
|
857
|
-
key={i}
|
|
858
|
-
onClick={() => {
|
|
859
|
-
setGridSearchText(s);
|
|
860
|
-
setSearchPopupVisible(false);
|
|
861
|
-
}}
|
|
862
|
-
style={{
|
|
863
|
-
display: "flex",
|
|
864
|
-
alignItems: "center",
|
|
865
|
-
gap: 10,
|
|
866
|
-
padding: "10px 12px",
|
|
867
|
-
marginBottom: 8,
|
|
868
|
-
borderRadius: 8,
|
|
869
|
-
cursor: "pointer",
|
|
870
|
-
backgroundColor: "#f5f7fa",
|
|
871
|
-
transition: "all 0.2s ease"
|
|
872
|
-
}}
|
|
873
|
-
onMouseEnter={e => e.currentTarget.style.background = "#e6f0ff"}
|
|
874
|
-
onMouseLeave={e => e.currentTarget.style.background = "#f5f7fa"}
|
|
875
|
-
>
|
|
876
|
-
<span style={{ fontSize: 16, color: "#1976d2" }}>🔍</span>
|
|
877
|
-
<span
|
|
878
|
-
style={{
|
|
879
|
-
fontSize: 14,
|
|
880
|
-
color: "#333",
|
|
881
|
-
overflow: "hidden",
|
|
882
|
-
textOverflow: "ellipsis",
|
|
883
|
-
whiteSpace: "nowrap"
|
|
884
|
-
}}
|
|
885
|
-
title={s}
|
|
886
|
-
>
|
|
887
|
-
{s}
|
|
888
|
-
</span>
|
|
889
|
-
</li>
|
|
890
|
-
))}
|
|
891
|
-
</ul>
|
|
892
|
-
) : (
|
|
893
|
-
<div
|
|
894
|
-
style={{
|
|
895
|
-
height: "100%",
|
|
896
|
-
display: "flex",
|
|
897
|
-
alignItems: "center",
|
|
898
|
-
justifyContent: "center",
|
|
899
|
-
color: "#999",
|
|
900
|
-
fontSize: 14
|
|
901
|
-
}}
|
|
902
|
-
>
|
|
903
|
-
🔍 No search history available
|
|
904
|
-
</div>
|
|
905
|
-
)}
|
|
906
|
-
</div>
|
|
907
|
-
</Popup>
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
792
|
</div>
|
|
912
793
|
)}
|
|
913
794
|
</div>
|