@campxdev/shared 1.7.7 → 1.7.8

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/shared",
3
- "version": "1.7.7",
3
+ "version": "1.7.8",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -13,16 +13,17 @@ import {
13
13
  peoplex,
14
14
  } from './assets'
15
15
 
16
- import CogWheelMenu from './CogWheelMenu'
17
- import HelpWidgetButton from '../Tickets/HelpWidget/HelpWidget'
16
+ import { HelpOutline } from '@mui/icons-material'
17
+ import CogWheelMenu from './HeaderActions/CogWheelMenu'
18
18
  import {
19
19
  StyledHeader,
20
20
  StyledImageWrapper,
21
21
  StyledLogosWrapper,
22
22
  StyledRouterLink,
23
23
  } from './styles'
24
- import UserBox from './UserBox'
25
- import { HelpOutline } from '@mui/icons-material'
24
+ import UserBox from './HeaderActions/UserBox'
25
+ import FreshDeskHelpButton from './HeaderActions/FreshDeskHelpButton'
26
+ import HeaderActions from './HeaderActions/HeaderActions'
26
27
 
27
28
  const imageMap = {
28
29
  ums: collegex,
@@ -43,6 +44,7 @@ interface AppHeaderProps {
43
44
  icon?: ReactNode
44
45
  onClick: any
45
46
  }[]
47
+ customHeaderActions?: ReactNode
46
48
  cogWheelMenu?: { label: string; path: string }[]
47
49
  }
48
50
 
@@ -51,15 +53,8 @@ export default function AppHeader({
51
53
  fullName,
52
54
  userBoxActions = [],
53
55
  cogWheelMenu = [],
56
+ customHeaderActions,
54
57
  }: AppHeaderProps) {
55
- const handleOpenFreshDeskWidget = () => {
56
- try {
57
- ;(window as any)?.openFreshDeskWidget()
58
- } catch (error) {
59
- // eslint-disable-next-line no-console
60
- console.error('Error launching Freshdesk')
61
- }
62
- }
63
58
  return (
64
59
  <StyledHeader>
65
60
  <Box sx={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
@@ -67,19 +62,15 @@ export default function AppHeader({
67
62
  <AppLogo clientLogo={clientLogo} />
68
63
  </Box>
69
64
  <Box className="actions">
70
- {/* <HelpWidgetButton /> */}
71
-
72
- <Button
73
- variant="text"
74
- color="secondary"
75
- startIcon={<HelpOutline />}
76
- onClick={handleOpenFreshDeskWidget}
77
- sx={{ padding: '20px' }}
78
- >
79
- Help
80
- </Button>
81
- {cogWheelMenu?.length ? <CogWheelMenu menu={cogWheelMenu} /> : null}
82
- <UserBox fullName={fullName} actions={userBoxActions} />
65
+ {customHeaderActions ? (
66
+ customHeaderActions
67
+ ) : (
68
+ <HeaderActions
69
+ cogWheelMenu={cogWheelMenu}
70
+ fullName={fullName}
71
+ userBoxActions={userBoxActions}
72
+ />
73
+ )}
83
74
  </Box>
84
75
  </StyledHeader>
85
76
  )
@@ -1,7 +1,7 @@
1
1
  import { SettingsOutlined } from '@mui/icons-material'
2
2
  import { IconButton } from '@mui/material'
3
- import { useHistory } from '../../../hooks/useRouter'
4
- import DropDownButton from '../../DropDownButton/DropDownButton'
3
+ import { useHistory } from '../../../../hooks/useRouter'
4
+ import DropDownButton from '../../../DropDownButton/DropDownButton'
5
5
 
6
6
  const CogWheelMenu = ({ menu }) => {
7
7
  const history = useHistory()
@@ -20,7 +20,7 @@ const CogWheelMenu = ({ menu }) => {
20
20
  },
21
21
  }))}
22
22
  menuProps={{
23
- PaperProps: { sx: { top: '64px !important' } },
23
+ PaperProps: { sx: { top: '56px !important' } },
24
24
  transformOrigin: {
25
25
  horizontal: 'center',
26
26
  vertical: 'top',
@@ -0,0 +1,24 @@
1
+ import { HelpOutline } from '@mui/icons-material'
2
+ import { Button } from '@mui/material'
3
+
4
+ export default function FreshDeskHelpButton() {
5
+ const handleOpenFreshDeskWidget = () => {
6
+ try {
7
+ ;(window as any)?.openFreshDeskWidget()
8
+ } catch (error) {
9
+ // eslint-disable-next-line no-console
10
+ console.error('Error launching Freshdesk')
11
+ }
12
+ }
13
+ return (
14
+ <Button
15
+ variant="text"
16
+ color="secondary"
17
+ startIcon={<HelpOutline />}
18
+ onClick={handleOpenFreshDeskWidget}
19
+ sx={{ padding: '20px' }}
20
+ >
21
+ Help
22
+ </Button>
23
+ )
24
+ }
@@ -0,0 +1,18 @@
1
+ import { Box } from '@mui/material'
2
+ import UserBox from './UserBox'
3
+ import CogWheelMenu from './CogWheelMenu'
4
+ import FreshDeskHelpButton from './FreshDeskHelpButton'
5
+
6
+ export default function HeaderActions({
7
+ cogWheelMenu,
8
+ fullName,
9
+ userBoxActions,
10
+ }) {
11
+ return (
12
+ <>
13
+ <FreshDeskHelpButton />
14
+ {cogWheelMenu?.length ? <CogWheelMenu menu={cogWheelMenu} /> : null}
15
+ <UserBox fullName={fullName} actions={userBoxActions} />
16
+ </>
17
+ )
18
+ }
@@ -0,0 +1,56 @@
1
+ import { ExitToAppOutlined, HttpsOutlined } from '@mui/icons-material'
2
+ import logout from '../../../../utils/logout'
3
+ import ChangePassword from '../../../ChangePassword'
4
+ import DropDownButton from '../../../DropDownButton/DropDownButton'
5
+ import { IMenuItemProps } from '../../../DropDownButton/DropdownMenuItem'
6
+ import { StyledAvatar } from '../styles'
7
+
8
+ const getStartingLetters = (text: string) => {
9
+ if (!text) return ''
10
+ return text
11
+ .split(' ')
12
+ ?.map((w) => w[0])
13
+ ?.join('')
14
+ }
15
+
16
+ export default function UserBox({
17
+ fullName,
18
+ actions,
19
+ customActions = [],
20
+ }: {
21
+ fullName: string
22
+ actions: IMenuItemProps[] | []
23
+ customActions?: IMenuItemProps[] | []
24
+ }) {
25
+ return (
26
+ <DropDownButton
27
+ anchor={({ open }) => (
28
+ <StyledAvatar onClick={open}>
29
+ {getStartingLetters(fullName)}
30
+ </StyledAvatar>
31
+ )}
32
+ menu={
33
+ customActions?.length
34
+ ? customActions
35
+ : [
36
+ ...actions,
37
+ {
38
+ label: 'Change Password',
39
+ actionType: 'dialog',
40
+ icon: <HttpsOutlined />,
41
+ content: ({ close }) => <ChangePassword close={close} />,
42
+ contentTitle: 'Change Password',
43
+ },
44
+ {
45
+ label: 'Logout',
46
+ icon: <ExitToAppOutlined />,
47
+ onClick: logout,
48
+ },
49
+ ]
50
+ }
51
+ menuProps={{
52
+ PaperProps: { sx: { top: '56px !important' } },
53
+ }}
54
+ />
55
+ )
56
+ }
@@ -29,6 +29,7 @@ import FilterButton from './FilterComponents/FilterButton'
29
29
  import Helmet from './Layout/Helmet'
30
30
  import NavigationTabs from './Tabs/NavigationTabs'
31
31
  import GlobalNetworkLoadingIndicator from './ErrorBoundary/GlobalNetworkLoadingIndicator'
32
+ import UserBox from './Layout/Header/HeaderActions/UserBox'
32
33
  import { CustomDialog } from './ModalButtons/DialogButton'
33
34
  import { CustomDrawer } from './ModalButtons/DrawerButton'
34
35
  export { default as Image } from './Image'
@@ -90,6 +91,7 @@ export {
90
91
  CustomDialog,
91
92
  CustomDrawer,
92
93
  GlobalNetworkLoadingIndicator,
94
+ UserBox,
93
95
  }
94
96
 
95
97
  export * from './UploadButton/types'
@@ -1,61 +0,0 @@
1
- import {
2
- ConfirmationNumberOutlined,
3
- ExitToAppOutlined,
4
- HttpsOutlined,
5
- } from '@mui/icons-material'
6
- import ConfirmationNumberOutlinedIcon from '@mui/icons-material/ConfirmationNumberOutlined'
7
- import { ReactNode } from 'react'
8
- import logout from '../../../utils/logout'
9
- import ChangePassword from '../../ChangePassword'
10
- import DropDownButton from '../../DropDownButton/DropDownButton'
11
- import { IMenuItemProps } from '../../DropDownButton/DropdownMenuItem'
12
- import { DialogButton } from '../../ModalButtons'
13
- import MyTickets from '../Tickets/MyTickets'
14
- import { StyledAvatar } from './styles'
15
-
16
- const getStartingLetters = (text: string) => {
17
- if (!text) return ''
18
- return text
19
- .split(' ')
20
- ?.map((w) => w[0])
21
- ?.join('')
22
- }
23
-
24
- export default function UserBox({
25
- fullName,
26
- actions,
27
- }: {
28
- fullName: string
29
- actions: IMenuItemProps[] | []
30
- }) {
31
- return (
32
- <>
33
- <DropDownButton
34
- anchor={({ open }) => (
35
- <StyledAvatar onClick={open}>
36
- {getStartingLetters(fullName)}
37
- </StyledAvatar>
38
- )}
39
- menu={[
40
- ...actions,
41
-
42
- {
43
- label: 'Change Password',
44
- actionType: 'dialog',
45
- icon: <HttpsOutlined />,
46
- content: ({ close }) => <ChangePassword close={close} />,
47
- contentTitle: 'Change Password',
48
- },
49
- {
50
- label: 'Logout',
51
- icon: <ExitToAppOutlined />,
52
- onClick: logout,
53
- },
54
- ]}
55
- menuProps={{
56
- PaperProps: { sx: { top: '64px !important' } },
57
- }}
58
- />
59
- </>
60
- )
61
- }