ui-soxo-bootstrap-core 2.6.1-dev.17 → 2.6.1-dev.19

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.
@@ -3,61 +3,54 @@
3
3
  * Global header component
4
4
  */
5
5
 
6
- import React, { useState, useEffect, useContext,useRef } from "react";
6
+ import React, { useState, useEffect, useContext, useRef } from 'react';
7
7
 
8
- import { animationControls, motion, useAnimation } from "framer-motion";
8
+ import { motion, useAnimation, useReducedMotion } from 'framer-motion';
9
9
 
10
10
  import {
11
11
  boxVariants,
12
- } from "./animations"
12
+ contentRevealVariants,
13
+ headerActionItemVariants,
14
+ headerActionsVariants,
15
+ headerClusterVariants,
16
+ headerShellVariants,
17
+ } from './animations';
13
18
 
14
- import { GlobalContext } from "./../../Store";
19
+ import { GlobalContext } from './../../Store';
15
20
 
16
- import { Link, useLocation } from "react-router-dom";
21
+ import { Link, useLocation } from 'react-router-dom';
17
22
 
18
- import { Typography, Avatar ,Input} from "antd";
23
+ import { Typography, Avatar, Input } from 'antd';
19
24
 
25
+ import ProgressBar from '../progress-bar/progress-bar'; // Adjust the path as needed
20
26
 
27
+ import { Button } from '../../elements';
21
28
 
22
- import ProgressBar from "../progress-bar/progress-bar"; // Adjust the path as needed
29
+ import GenericHeader from '../header/generic-header';
23
30
 
24
- import { Button } from "../../elements";
31
+ import { MenuOutlined, UserOutlined, SettingOutlined } from '@ant-design/icons';
25
32
 
33
+ import { Drawer } from 'antd';
26
34
 
35
+ import { ReloadOutlined, SearchOutlined } from '@ant-design/icons';
27
36
 
28
- import GenericHeader from "../header/generic-header";
37
+ import SideMenu from './../sidemenu/sidemenu';
29
38
 
30
- import {
31
- MenuOutlined,
32
- UserOutlined,
33
- SettingOutlined,
34
- } from "@ant-design/icons";
35
-
36
- import { Drawer } from "antd";
37
-
38
- import { ReloadOutlined, SearchOutlined } from "@ant-design/icons";
39
-
40
- import SideMenu from "./../sidemenu/sidemenu";
41
-
42
- import "./global-header.scss";
39
+ import './global-header.scss';
43
40
 
44
- import LanguageSwitcher from "../language-switcher/language-switcher";
41
+ import LanguageSwitcher from '../language-switcher/language-switcher';
45
42
 
46
- import { useTranslation } from "react-i18next";
47
-
48
-
49
- import BorderStyle from "pdf-lib/cjs/core/annotation/BorderStyle";
50
-
51
- import SettingsUtil from "../../../utils/settings.utils";
52
- import SpotlightSearch from "../spotlight-search/spotlight-search.component";
43
+ import { useTranslation } from 'react-i18next';
53
44
 
45
+ import BorderStyle from 'pdf-lib/cjs/core/annotation/BorderStyle';
54
46
 
47
+ import SettingsUtil from '../../../utils/settings.utils';
48
+ import SpotlightSearch from '../spotlight-search/spotlight-search.component';
49
+ import { LicenseAlert } from '../../../components';
50
+ import { MenusAPI } from '../../../models';
55
51
 
56
52
  const { Title } = Typography;
57
53
 
58
-
59
-
60
-
61
54
  export default function GlobalHeader({
62
55
  loading,
63
56
  appSettings,
@@ -70,46 +63,45 @@ export default function GlobalHeader({
70
63
  meta = {},
71
64
  ...props
72
65
  }) {
73
-
74
66
  let location = useLocation();
75
67
  // let location = {};
76
68
 
77
-
78
-
79
69
  const { isMobile, user = { locations: [] }, kiosk, state } = useContext(GlobalContext);
80
70
 
81
-
82
-
83
71
  const [visible, setVisible] = useState(false);
84
72
 
85
73
  // Variable to handle toggling of menu
86
74
  const [collapsed, setCollapsed] = useState(false);
87
75
  // varibale handle branch switcher
88
76
 
89
-
90
-
91
77
  // const [searchModalVisible, setSearchModalVisible] = useState(false);
92
78
 
93
-
94
- const { globalCustomerHeader = () => { } } = appSettings;
79
+ const { globalCustomerHeader = () => {} } = appSettings;
95
80
 
96
81
  const { t, i18n } = useTranslation();
97
-
82
+ const reduceMotion = useReducedMotion();
83
+ const shouldAnimate = !reduceMotion;
84
+ const [licenseData, setLicenseData] = useState({});
85
+
86
+ const fetchSummary = async () => {
87
+ console.log('fetching summary');
88
+ try {
89
+ const res = await MenusAPI.getSummary();
90
+ if (res?.data) {
91
+ setLicenseData(res?.data);
92
+ }
93
+ } catch (err) {
94
+ console.error(err);
95
+ }
96
+ };
98
97
  const spotlightRef = useRef();
99
98
 
100
99
  useEffect(() => {
101
-
102
100
  setTimeout(() => {
103
-
104
101
  i18n.changeLanguage(localStorage.selectedLanguage);
105
-
106
- }, 0)
107
-
108
-
102
+ }, 0);
103
+ fetchSummary();
109
104
  }, []);
110
-
111
-
112
-
113
105
 
114
106
  /**
115
107
  * Function to handle toggling of menu
@@ -125,9 +117,6 @@ export default function GlobalHeader({
125
117
  // input to avoid typing
126
118
  SettingsUtil.openSpotlightModal();
127
119
  };
128
-
129
-
130
-
131
120
 
132
121
  /**
133
122
  * Function to remove toggling on mobile view
@@ -156,79 +145,49 @@ export default function GlobalHeader({
156
145
  const boxControls = useAnimation();
157
146
 
158
147
  async function animate() {
159
- await boxControls.start("entered");
148
+ if (!shouldAnimate) {
149
+ boxControls.set('entered');
150
+ return;
151
+ }
152
+
153
+ await boxControls.start('entered');
160
154
 
161
155
  //await boxControls.start("show");
162
156
  }
163
157
 
164
158
  useEffect(() => {
165
-
166
159
  animate();
167
- }, [])
160
+ }, [shouldAnimate]);
168
161
 
169
- useEffect(() => {
170
-
171
- }, [state.theme]);
172
-
173
-
174
-
175
-
176
-
162
+ useEffect(() => {}, [state.theme]);
177
163
 
164
+ const motionProps = shouldAnimate ? { initial: 'hidden', animate: 'visible' } : { initial: false, animate: false };
178
165
 
179
166
  return (
180
- <div
181
- className={`global-header ${process.env.REACT_APP_THEME} ${isConnected && !kiosk ? "connected" : ""
182
- }`}
183
- style={{
184
-
185
- // background: state.theme.colors.bodyBackground,
186
-
187
- height: 10,
188
-
189
- }}
190
- >
191
- {/* <MenuOutlined style={{left:'1%',top:'1%', fontSize:18, position:'absolute', zIndex:999}} onClick={showSidebar}/> */}
192
-
193
- <div className="layout-content">
194
- <div
195
-
196
- //whileHover="hover"
197
- //whileTap="tap"
198
- className={`left-bar ${!isConnected && !isMobile ? "" : "hide"}${!collapsed ? "open" : "close"}${kiosk && !isConnected ? "kioskon" : ""}`}
199
- // style={{ background: state.theme.colors.leftSectionBackground }}
200
- >
201
-
202
- {!isMobile && !isConnected ? (
203
- <motion.div
204
- variants={boxVariants}
205
- initial={["entering"]}
206
- animate={boxControls}
207
- className={`sidebar-container ${!collapsed ? "open" : "close"}${kiosk ? "" : "kioskon"}`}
208
-
209
- >
210
-
211
- <SideMenu
212
- // isOpen={isOpen}
213
- collapsed={collapsed}
214
- setCollapsed={setCollapsed}
215
- loading={loading}
216
- appSettings={appSettings}
217
- callback={onClose}
218
- modules={modules}
219
- history={history}
220
- />
221
-
222
- </motion.div>
223
- ) : (
224
- <Drawer
225
- placement="left"
226
- onClose={onClose}
227
- visible={visible}
228
- className="side-drawer-content"
229
- >
230
- <div
231
- className={`sidebar-container ${!collapsed ? "open" : "close"}`}
167
+ <>
168
+ <div
169
+ className={`global-header ${process.env.REACT_APP_THEME} ${isConnected && !kiosk ? 'connected' : ''}`}
170
+ style={{
171
+ // background: state.theme.colors.bodyBackground,
172
+
173
+ height: 10,
174
+ }}
175
+ >
176
+ {/* <MenuOutlined style={{left:'1%',top:'1%', fontSize:18, position:'absolute', zIndex:999}} onClick={showSidebar}/> */}
177
+
178
+ <div className="layout-content">
179
+ <div
180
+ //whileHover="hover"
181
+ //whileTap="tap"
182
+ className={`left-bar ${!isConnected && !isMobile ? '' : 'hide'}${!collapsed ? 'open' : 'close'}${kiosk && !isConnected ? 'kioskon' : ''}`}
183
+ // style={{ background: state.theme.colors.leftSectionBackground }}
184
+ >
185
+ {!isMobile && !isConnected ? (
186
+ <motion.div
187
+ variants={boxVariants}
188
+ initial={['entering']}
189
+ animate={boxControls}
190
+ className={`sidebar-container ${!collapsed ? 'open' : 'close'}${kiosk ? '' : 'kioskon'}`}
232
191
  >
233
192
  <SideMenu
234
193
  // isOpen={isOpen}
@@ -240,168 +199,188 @@ export default function GlobalHeader({
240
199
  modules={modules}
241
200
  history={history}
242
201
  />
243
- </div>
244
- </Drawer>
245
- )}
246
- </div>
202
+ </motion.div>
203
+ ) : (
204
+ <Drawer placement="left" onClose={onClose} visible={visible} className="side-drawer-content">
205
+ <div className={`sidebar-container ${!collapsed ? 'open' : 'close'}`}>
206
+ <SideMenu
207
+ // isOpen={isOpen}
208
+ collapsed={collapsed}
209
+ setCollapsed={setCollapsed}
210
+ loading={loading}
211
+ appSettings={appSettings}
212
+ callback={onClose}
213
+ modules={modules}
214
+ history={history}
215
+ />
216
+ </div>
217
+ </Drawer>
218
+ )}
219
+ </div>
220
+
221
+ {/* Right Section of the Component Loader */}
222
+ <div
223
+ className={`right-section ${!collapsed ? 'open' : 'close'} ${kiosk ? 'kioskon' : ''}`}
224
+ style={{ background: state.theme.colors.bodyBackground }}
225
+ >
226
+ {/* For not connected section */}
227
+ {!isConnected && !kiosk ? (
228
+ <motion.div
229
+ variants={headerShellVariants}
230
+ {...motionProps}
231
+ className={`page-wrapper ${!collapsed ? 'open' : 'close'}`}
232
+ // style={{ background: state.theme.colors.headerBg }}
233
+ >
234
+ {/* */}
235
+ <motion.div className="page-header-name" variants={headerClusterVariants}>
236
+ <ProgressBar isLoading={loading} />
247
237
 
248
- {/* Right Section of the Component Loader */}
249
- <div className={`right-section ${!collapsed ? "open" : "close"} ${kiosk ? "kioskon" : ""}`} style={{ background: state.theme.colors.bodyBackground }}>
250
- {/* For not connected section */}
251
- {!isConnected && !kiosk ? (
252
-
253
- <div className={`page-wrapper ${!collapsed ? "open" : "close"}`}
254
- // style={{ background: state.theme.colors.headerBg }}
255
- >
256
- {/* */}
257
- <div className="page-header-name">
258
-
259
- <ProgressBar isLoading={loading} />
260
-
261
- <span type
262
- onClick={!isMobile ? toggleCollapsed : hideToggle}
263
- className="toggle-box toggle-menu"
264
- >
265
- <MenuOutlined />
266
-
267
- </span>
268
-
269
- {/* Back Button */}
270
- {location.pathname !== "/" ? (
271
- <span
272
- className="toggle-box"
273
- onClick={() => {
274
- history && history.goBack();
275
- }}
276
- >
277
- <GenericHeader />
238
+ <span type onClick={!isMobile ? toggleCollapsed : hideToggle} className="toggle-box toggle-menu">
239
+ <MenuOutlined />
278
240
  </span>
279
- ) : null}
280
- {/* Back Button Ends */}
281
-
282
241
 
283
- {location.pathname !== "/" ? (
284
- <h4 className="menu-caption header-caption" style={{ color: state.theme.colors.headerColor }}>
285
- {menu.caption}
286
- </h4>
287
- ) : null}
288
- </div>
289
-
290
- {/* Page Menu Actions */}
291
-
292
- {user.role || user.id ? (
293
- <div className="page-menu">
294
- {/* Search Input in header start */}
295
- { !isMobile && (
296
-
297
- <div>
298
- <Input
299
- placeholder="Search (Shift + F)"
300
- prefix={<SearchOutlined />}
301
- onClick={openSearchModal}
302
-
303
- readOnly
304
- style={{ width: 250 }}
305
- />
306
-
307
-
308
- <SpotlightSearch ref={(elem) => SettingsUtil.registerModal(elem)} props={props}/>
309
-
310
- </div>
311
- )}
312
- {/* Search Input in header start */}
313
-
314
- {/** branchswitcher Option */}
315
- {/* branch switcher controlled with env for matria and nura */}
316
- {!process.env.REACT_APP_SHOW_BRANCH_SWITCHER ? (
317
- <div className="branch-switcher">{globalCustomerHeader()}</div>
318
- ):null}
319
- {/* <div className="branch-switcher">{globalCustomerHeader()}</div> */}
320
-
321
-
322
- {/* Search Option */}
323
-
324
- {/* <ModalSearch /> */}
325
-
326
- {/* Search Option Ends */}
327
-
328
- {/* Configurator Actions */}
329
- {user.isAdmin ? (
330
- <>
331
- {/* Models */}
332
- {menu && menu.id ? (
333
- <Link to={`/menus/${menu.id}`}>
334
-
335
- <Button type="default" size={"small"} icon={<SettingOutlined />}>
336
-
337
- </Button>
338
- </Link>
339
- ) : null}
340
- {/* Models Ends */}
341
- </>
242
+ {/* Back Button */}
243
+ {location.pathname !== '/' ? (
244
+ <span
245
+ className="toggle-box"
246
+ onClick={() => {
247
+ history && history.goBack();
248
+ }}
249
+ >
250
+ <GenericHeader />
251
+ </span>
342
252
  ) : null}
343
- {/* Configurator Actions Ends */}
344
-
345
-
253
+ {/* Back Button Ends */}
346
254
 
255
+ {location.pathname !== '/' ? (
256
+ <h4 className="menu-caption header-caption" style={{ color: state.theme.colors.headerColor }}>
257
+ {menu.caption}
258
+ </h4>
259
+ ) : null}
260
+ </motion.div>
347
261
 
262
+ {/* Page Menu Actions */}
348
263
 
264
+ {user.role || user.id ? (
265
+ <motion.div className="page-menu" variants={headerActionsVariants}>
266
+ {/* Search Input in header start */}
267
+ {!isMobile && (
268
+ <motion.div className="header-action header-action-search" variants={headerActionItemVariants}>
269
+ <Input
270
+ placeholder="Search (Shift + F)"
271
+ prefix={<SearchOutlined />}
272
+ onClick={openSearchModal}
273
+ readOnly
274
+ style={{ width: 250 }}
275
+ />
276
+
277
+ <SpotlightSearch ref={(elem) => SettingsUtil.registerModal(elem)} props={props} />
278
+ </motion.div>
279
+ )}
280
+ {/* Search Input in header start */}
349
281
 
350
- {/* Reload Button */}
351
-
352
- <Button onClick={reload} icon={<ReloadOutlined />} type="default" size={"small"} >
353
-
354
- </Button>
355
-
356
- {/* Reload Button Ends */}
357
-
358
- {/** Switch Languages starts */}
359
- {process.env.REACT_APP_ENABLE_LANGUAGE_SWITCHER ? <LanguageSwitcher /> : null}
360
- {/** Switch Languages ends */}
361
-
362
- {/* User Profile */}
363
- <div style={{ padding: "10px" }}>
364
- <ProfileAvatar />
365
- <span style={{ color: state.theme.colors.colorText }}> {user.name} </span>
366
- </div>
367
- {/* User Profile Ends */}
368
- </div>
369
- ) : null}
282
+ {/** branchswitcher Option */}
283
+ {/* branch switcher controlled with env for matria and nura */}
284
+ {!process.env.REACT_APP_SHOW_BRANCH_SWITCHER ? (
285
+ <motion.div className="branch-switcher header-action" variants={headerActionItemVariants}>
286
+ {globalCustomerHeader()}
287
+ </motion.div>
288
+ ) : null}
289
+ {/* <div className="branch-switcher">{globalCustomerHeader()}</div> */}
290
+
291
+ {/* Search Option */}
292
+
293
+ {/* <ModalSearch /> */}
294
+
295
+ {/* Search Option Ends */}
296
+
297
+ {/* Configurator Actions */}
298
+ {user.isAdmin ? (
299
+ <>
300
+ {/* Models */}
301
+ {menu && menu.id ? (
302
+ <motion.div className="header-action" variants={headerActionItemVariants}>
303
+ <Link to={`/menus/${menu.id}`}>
304
+ <Button type="default" size={'small'} icon={<SettingOutlined />}></Button>
305
+ </Link>
306
+ </motion.div>
307
+ ) : null}
308
+ {/* Models Ends */}
309
+ </>
310
+ ) : null}
311
+ {/* Configurator Actions Ends */}
312
+
313
+ {/* Reload Button */}
314
+
315
+ <motion.div className="header-action" variants={headerActionItemVariants}>
316
+ <Button onClick={reload} icon={<ReloadOutlined />} type="default" size={'small'}></Button>
317
+ </motion.div>
318
+
319
+ {/* Reload Button Ends */}
320
+
321
+ {/** Switch Languages starts */}
322
+ {process.env.REACT_APP_ENABLE_LANGUAGE_SWITCHER ? (
323
+ <motion.div className="header-action" variants={headerActionItemVariants}>
324
+ <LanguageSwitcher />
325
+ </motion.div>
326
+ ) : null}
327
+ {/** Switch Languages ends */}
328
+
329
+ {/* User Profile */}
330
+ <motion.div className="header-profile-wrap header-action" variants={headerActionItemVariants}>
331
+ <ProfileAvatar />
332
+ <span className="header-profile-name" style={{ color: state.theme.colors.colorText }}>
333
+ {' '}
334
+ {user.name}{' '}
335
+ </span>
336
+ </motion.div>
337
+ {/* User Profile Ends */}
338
+ </motion.div>
339
+ ) : null}
370
340
 
371
- {/* Page Menu Actions Ends */}
372
- </div>
373
- ) : null}
341
+ {/* Page Menu Actions Ends */}
342
+ </motion.div>
343
+ ) : null}
374
344
 
375
- {/* The children is rendered */}
376
- {children}
377
- {/* The children is rendered */}
345
+ {/* The children is rendered */}
346
+ <motion.div className="page-content-stage" variants={contentRevealVariants} {...motionProps}>
347
+ {children}
348
+ </motion.div>
349
+ {/* The children is rendered */}
350
+ </div>
351
+ {/* Right Section of the Component Loader Ends */}
378
352
  </div>
379
- {/* Right Section of the Component Loader Ends */}
380
353
  </div>
381
- </div>
354
+ {licenseData && (
355
+ <div
356
+ style={{
357
+ marginTop: '3rem',
358
+ right: '2%',
359
+ position: 'absolute',
360
+ zIndex: 999,
361
+ }}
362
+ >
363
+ <LicenseAlert data={licenseData} />
364
+ </div>
365
+ )}
366
+ </>
382
367
  );
383
368
  }
384
369
 
385
-
386
370
  /**
387
- *
388
- * @returns
371
+ *
372
+ * @returns
389
373
  */
390
374
  function ProfileAvatar() {
391
-
392
375
  const { user = { locations: [] } } = useContext(GlobalContext);
393
376
 
394
- useEffect(() => { }, []);
377
+ useEffect(() => {}, []);
395
378
 
396
379
  return (
397
380
  <Link className="profile-avatar" to="/profile">
398
381
  {user.photograph ? (
399
382
  <>
400
- <img
401
- className="profile-picture"
402
- src={user.photograph}
403
- alt={"user photograph"}
404
- />
383
+ <img className="profile-picture" src={user.photograph} alt={'user photograph'} />
405
384
  </>
406
385
  ) : (
407
386
  <Avatar shape="square" size="small" icon={<UserOutlined />} />