ui-soxo-bootstrap-core 2.5.1 → 2.5.3

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.
@@ -1,7 +1,7 @@
1
1
  /**
2
- * ExtraInfoDetail component contains the button and the data for corresponding to script mode and will open extrainfo
2
+ * ExtraInfoDetail component contains the button and the data for corresponding to script mode and will open extrainfo
3
3
  *
4
- * @description
4
+ * @description
5
5
  * @author Sneha T
6
6
  */
7
7
 
@@ -21,152 +21,135 @@ import ExtraInfo from './extra-info';
21
21
 
22
22
  const { TabPane } = Tabs;
23
23
 
24
- export default function ExtraInfoDetail({ modeValue, icon, title, tabPosition='left',showDrawerData,dbPtr,callback,...record}) {
25
- // State to control drawer
26
- const [open, setOpen] = useState(false);
24
+ export default function ExtraInfoDetail({ modeValue, icon, title, tabPosition = 'left', showDrawerData, dbPtr, callback, ...record }) {
25
+ // State to control drawer
26
+ const [open, setOpen] = useState(false);
27
27
 
28
- // To set extra info data
29
- const [info, setInfo] = useState([]);
30
- //Setting active key for tabs
31
- const [activeKey, setActiveKey] = useState(null);
28
+ // To set extra info data
29
+ const [info, setInfo] = useState([]);
30
+ //Setting active key for tabs
31
+ const [activeKey, setActiveKey] = useState(null);
32
32
 
33
- // To strore selected item
34
- const [selectedItem, setSelectedItem] = useState(null);
33
+ // To strore selected item
34
+ const [selectedItem, setSelectedItem] = useState(null);
35
35
 
36
- const [loading, setLoading] = useState(true);
36
+ const [loading, setLoading] = useState(true);
37
37
 
38
- /**
39
- * Show Drawer
40
- */
41
- const showDrawer = () => {
42
-
43
- setActiveKey(null); // Reset activeKey before fetching new info
44
-
45
- getExtraInfo();
38
+ /**
39
+ * Show Drawer
40
+ */
41
+ const showDrawer = () => {
42
+ setActiveKey(null); // Reset activeKey before fetching new info
46
43
 
47
- setOpen(true);
44
+ getExtraInfo();
48
45
 
49
- };
46
+ setOpen(true);
47
+ };
50
48
 
51
- /**
52
- * Function to close
53
- */
54
- const onClose = () => {
55
- if (typeof callback === 'function') {
56
- // Only call if it exists
57
- callback(false);
58
- }
59
- setOpen(false);
60
- };
49
+ /**
50
+ * Function to close
51
+ */
52
+ const onClose = () => {
53
+ if (typeof callback === 'function') {
54
+ // Only call if it exists
55
+ callback(false);
56
+ }
57
+ setOpen(false);
58
+ };
61
59
 
62
- /**
63
- * Function to get Info
64
- */
65
- async function getExtraInfo() {
60
+ /**
61
+ * Function to get Info
62
+ */
63
+ async function getExtraInfo() {
64
+ setSelectedItem();
66
65
 
67
- setSelectedItem()
66
+ setLoading(true);
68
67
 
69
- setLoading(true);
68
+ let mode = modeValue;
70
69
 
71
- let mode = modeValue
70
+ const result = await Dashboard.getExtraInfo(mode);
72
71
 
73
- const result = await Dashboard.getExtraInfo(mode);
72
+ setInfo(result);
74
73
 
75
- setInfo(result);
74
+ setSelectedItem(result[0]);
76
75
 
77
- setSelectedItem(result[0])
76
+ setActiveKey(result[0].id.toString()); // Set activeKey to the first item's id
78
77
 
79
- setActiveKey(result[0].id.toString()); // Set activeKey to the first item's id
78
+ setLoading(false);
79
+ }
80
80
 
81
- setLoading(false);
81
+ useEffect(() => {
82
+ // If showDrawerData is true then call showDrawer function
83
+ if (showDrawerData) {
84
+ showDrawer();
82
85
  }
86
+ }, [showDrawerData]);
83
87
 
84
- useEffect(() => {
85
- // If showDrawerData is true then call showDrawer function
86
- if (showDrawerData) {
87
- showDrawer();
88
- }
89
- }, [showDrawerData]);
90
-
91
- /**
88
+ /**
92
89
  * Function to render icon or button
93
90
  */
94
- const renderIconOrButton = () => {
95
- switch (icon) {
96
- case 'InfoCircleFilled':
97
- return <InfoCircleFilled onClick={showDrawer} />;
98
- case 'Button':
99
- return <Button size="small" onClick={showDrawer}>Show Info</Button>;
100
- default:
101
- return null;
102
- }
103
- };
104
-
105
-
106
-
107
- return (
108
- <>
109
- {/* {loading ? (
91
+ const renderIconOrButton = () => {
92
+ switch (icon) {
93
+ case 'InfoCircleFilled':
94
+ return <InfoCircleFilled onClick={showDrawer} />;
95
+ case 'Button':
96
+ return (
97
+ <Button size="small" onClick={showDrawer}>
98
+ Show Info
99
+ </Button>
100
+ );
101
+ default:
102
+ return null;
103
+ }
104
+ };
105
+
106
+ return (
107
+ <>
108
+ {/* {loading ? (
110
109
  <>
111
110
  <Skeleton active />
112
111
  </>
113
112
  ) : ( */}
114
- <>
115
- {/* */}
116
- {/* <Button onClick={showDrawer}> */}
117
-
118
- {/* <InfoCircleFilled onMouseEnter={showDrawer} /> */}
119
-
120
- {renderIconOrButton()}
121
- {/* </Button> */}
122
- {/* */}
123
-
124
- {/* */}
125
- <Drawer
126
-
127
- width={'85%'}
128
-
129
- title={title} onClose={onClose} open={open}>
130
-
131
- <div className="main-drawer-content">
132
-
133
- <div className="drawer-container">
134
-
135
- <div className="drawer-click"> {/* Flexbox approach */}
136
- <Tabs
137
- tabPosition={tabPosition}
138
-
139
- activeKey={activeKey} // Set activeKey to control the active tab
140
-
141
- onChange={(key) => {
142
-
143
- const selectedItem = info.find(item => item.id.toString() === key);
144
-
145
- setSelectedItem(selectedItem);
146
-
147
- setActiveKey(key);
148
- }}
149
- >
150
- {info.map(item => (
151
- <TabPane tab={item.caption} key={item.id.toString()} />
152
- ))}
153
- </Tabs>
154
- </div>
155
-
156
- <div className="right-drawer">
157
-
158
- {selectedItem && !loading ? <ExtraInfo item={selectedItem} record={record} dbPtr={dbPtr}/> : null}
159
-
160
- </div>
161
-
162
- </div>
163
-
164
- </div>
165
-
166
- </Drawer>
167
-
168
- </>
169
- {/* )} */}
170
- </>
171
- );
113
+ <>
114
+ {/* */}
115
+ {/* <Button onClick={showDrawer}> */}
116
+
117
+ {/* <InfoCircleFilled onMouseEnter={showDrawer} /> */}
118
+
119
+ {renderIconOrButton()}
120
+ {/* </Button> */}
121
+ {/* */}
122
+
123
+ {/* */}
124
+ <Drawer width={'35%'} title={title} onClose={onClose} open={open}>
125
+ <div className="main-drawer-content">
126
+ <div className="drawer-container">
127
+ <div className="drawer-click">
128
+ {' '}
129
+ {/* Flexbox approach */}
130
+ <Tabs
131
+ tabPosition={tabPosition}
132
+ activeKey={activeKey} // Set activeKey to control the active tab
133
+ onChange={(key) => {
134
+ const selectedItem = info.find((item) => item.id.toString() === key);
135
+
136
+ setSelectedItem(selectedItem);
137
+
138
+ setActiveKey(key);
139
+ }}
140
+ >
141
+ {info.map((item) => (
142
+ <TabPane tab={item.caption} key={item.id.toString()} />
143
+ ))}
144
+ </Tabs>
145
+ </div>
146
+
147
+ <div className="right-drawer">{selectedItem && !loading ? <ExtraInfo item={selectedItem} record={record} dbPtr={dbPtr} /> : null}</div>
148
+ </div>
149
+ </div>
150
+ </Drawer>
151
+ </>
152
+ {/* )} */}
153
+ </>
154
+ );
172
155
  }