@campxdev/shared 1.7.7 → 1.7.9

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.
Files changed (24) hide show
  1. package/package.json +1 -1
  2. package/src/components/Layout/Header/AppHeader.tsx +16 -25
  3. package/src/components/Layout/Header/{CogWheelMenu.tsx → HeaderActions/CogWheelMenu.tsx} +3 -3
  4. package/src/components/Layout/Header/HeaderActions/FreshDeskHelpButton.tsx +24 -0
  5. package/src/components/Layout/Header/HeaderActions/HeaderActions.tsx +18 -0
  6. package/src/components/Layout/Header/HeaderActions/UserBox.tsx +56 -0
  7. package/src/components/{TableComponent → Tables/BasicTable}/Table.tsx +13 -12
  8. package/src/components/{TableComponent/TableFooter → Tables/BasicTable}/TableFooter.tsx +2 -20
  9. package/src/components/{TableComponent → Tables/BasicTable}/index.tsx +0 -0
  10. package/src/components/{TableComponent → Tables/ReactTable}/BatchActionsHeader.tsx +2 -2
  11. package/src/components/{TableComponent → Tables/ReactTable}/ReactTable.tsx +5 -5
  12. package/src/components/{TableComponent → Tables/ReactTable}/RenderTableBody.tsx +4 -23
  13. package/src/components/Tables/ReactTable/index.tsx +1 -0
  14. package/src/components/{TableComponent → Tables/ReactTable}/react-table-config.d.ts +0 -0
  15. package/src/components/Tables/common/NoRecordsFound.tsx +27 -0
  16. package/src/components/Tables/common/TableStats.tsx +22 -0
  17. package/src/components/{TableComponent/Icons/index.tsx → Tables/common/icons.tsx} +0 -0
  18. package/src/components/{TableComponent → Tables/common}/no-data-illu.svg +0 -0
  19. package/src/components/{TableComponent → Tables/common}/styles.tsx +0 -0
  20. package/src/components/{TableComponent → Tables/common}/types.ts +0 -0
  21. package/src/components/index.ts +5 -3
  22. package/src/components/Layout/Header/UserBox.tsx +0 -61
  23. package/src/components/TableComponent/TableFooter/index.tsx +0 -1
  24. package/src/components/TableComponent/TableFooter/styles.tsx +0 -28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/shared",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
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
+ }
@@ -10,12 +10,12 @@ import {
10
10
  TableContainer,
11
11
  TableHead,
12
12
  TableRow,
13
- Typography,
14
13
  } from '@mui/material'
15
14
  import _ from 'lodash'
16
15
  import { useEffect, useState } from 'react'
17
- import Spinner from '../Spinner'
18
- import { SortAscIcon, SortDescIcon, SortIcon } from './Icons'
16
+ import Spinner from '../../Spinner'
17
+ import { SortAscIcon, SortDescIcon, SortIcon } from '../common/icons'
18
+ import NoRecordsFound from '../common/NoRecordsFound'
19
19
  import TableFooter from './TableFooter'
20
20
 
21
21
  export interface ColumnProps {
@@ -88,7 +88,7 @@ export default function Table({
88
88
  }, [sort])
89
89
 
90
90
  return (
91
- <TableContainer>
91
+ <StyledTableContainer>
92
92
  <>
93
93
  <MuiTable>
94
94
  <TableHead>
@@ -156,13 +156,9 @@ export default function Table({
156
156
  ))}
157
157
  </TableBody>
158
158
  ) : (
159
- <Box>
160
- {dataSource && (
161
- <Typography sx={{ padding: '10px' }}>
162
- No Records Found !..
163
- </Typography>
164
- )}
165
- </Box>
159
+ <>
160
+ <NoRecordsFound colLength={columns?.length} />
161
+ </>
166
162
  )}
167
163
  </>
168
164
  ) : (
@@ -181,10 +177,15 @@ export default function Table({
181
177
  />
182
178
  )}
183
179
  </>
184
- </TableContainer>
180
+ </StyledTableContainer>
185
181
  )
186
182
  }
187
183
 
184
+ const StyledTableContainer = styled(TableContainer)(({ theme }) => ({
185
+ width: '100%',
186
+ overflowX: 'auto',
187
+ }))
188
+
188
189
  const StyledTableRow = styled(TableRow, {
189
190
  shouldForwardProp: (prop) => prop !== 'canRowClick',
190
191
  })<{ canRowClick: boolean }>(({ canRowClick }) => ({
@@ -1,6 +1,7 @@
1
1
  import { Box, Typography } from '@mui/material'
2
2
  import DropDownButton from '../../DropDownButton/DropDownButton'
3
- import { StyledPagination, StyledTableFooter } from '../styles'
3
+ import { StyledPagination, StyledTableFooter } from '../common/styles'
4
+ import TableStats from '../common/TableStats'
4
5
 
5
6
  interface TableFooterProps {
6
7
  totalCount: number
@@ -39,25 +40,6 @@ export default function TableFooter({
39
40
  )
40
41
  }
41
42
 
42
- export const TableStats = ({
43
- limit,
44
- totalCount,
45
- page,
46
- }: {
47
- limit: number
48
- page: number
49
- totalCount: number
50
- }) => {
51
- const pageStart = (page - 1) * limit + 1
52
- const pageEnd = page * limit <= totalCount ? page * limit : totalCount
53
-
54
- return (
55
- <Box>
56
- <Typography variant="subtitle1">{`${pageStart} - ${pageEnd} of ${totalCount}`}</Typography>
57
- </Box>
58
- )
59
- }
60
-
61
43
  const LimitField = ({ handlePageLimit, limit }) => {
62
44
  return (
63
45
  <Box>
@@ -1,10 +1,10 @@
1
1
  import { Box, Typography } from '@mui/material'
2
- import DropDownButton from '../DropDownButton/DropDownButton'
2
+ import DropDownButton from '../../DropDownButton'
3
3
  import {
4
4
  StyledActionIconButton,
5
5
  StyledActionsRow,
6
6
  StyledTableActionsHeader,
7
- } from './styles'
7
+ } from '../common/styles'
8
8
 
9
9
  export default function BatchActionsHeader({
10
10
  selectedRowIds,
@@ -14,16 +14,16 @@ import {
14
14
  import { useEffect, useMemo, useState } from 'react'
15
15
  import { usePagination, useRowSelect, useTable } from 'react-table'
16
16
  import BatchActionsHeader from './BatchActionsHeader'
17
- import { SortAscIcon, SortDescIcon, SortIcon } from './Icons'
17
+ import { SortAscIcon, SortDescIcon, SortIcon } from '../common/icons'
18
18
  import { RenderTableBody } from './RenderTableBody'
19
19
  import {
20
20
  StyledLimitBox,
21
21
  StyledLimitMenu,
22
22
  StyledPagination,
23
23
  StyledTableFooter,
24
- } from './styles'
25
- import { TableStats } from './TableFooter/TableFooter'
26
- import { ColumnProps, Sort, TableProps } from './types'
24
+ } from '../common/styles'
25
+ import { ColumnProps, Sort, TableProps } from '../common/types'
26
+ import TableStats from '../common/TableStats'
27
27
 
28
28
  type ReactTableCell = {
29
29
  Header: any
@@ -73,7 +73,7 @@ const getTableCol = (headerItem: ColumnProps) => {
73
73
  return col
74
74
  }
75
75
 
76
- export default function TableComponent({
76
+ export default function ReactTable({
77
77
  columns,
78
78
  dataSource,
79
79
  loading,
@@ -1,7 +1,7 @@
1
1
  import { Box, TableBody, TableCell, Typography } from '@mui/material'
2
- import Spinner from '../Spinner'
3
- import noDataImage from './no-data-illu.svg'
4
- import { StyledTableRow } from './styles'
2
+ import Spinner from '../../Spinner'
3
+ import { StyledTableRow } from '../common/styles'
4
+ import NoRecordsFound from '../common/NoRecordsFound'
5
5
 
6
6
  export const RenderTableBody = ({
7
7
  getTableBodyProps,
@@ -19,26 +19,7 @@ export const RenderTableBody = ({
19
19
  )
20
20
 
21
21
  if (!loading && rows?.length < 1)
22
- return (
23
- <TableCell colSpan={colLength}>
24
- <Box
25
- sx={{
26
- display: 'flex',
27
- flexDirection: 'column',
28
- alignItems: 'center',
29
- justifyContent: 'center',
30
- }}
31
- >
32
- <img
33
- style={{ width: '200px', height: 'auto', textAlign: 'center' }}
34
- src={noDataImage}
35
- />
36
- <Typography variant="h6" align="center">
37
- No Records Found
38
- </Typography>
39
- </Box>
40
- </TableCell>
41
- )
22
+ return <NoRecordsFound colLength={colLength} />
42
23
 
43
24
  return (
44
25
  <TableBody {...getTableBodyProps()}>
@@ -0,0 +1 @@
1
+ export { default } from './ReactTable'
@@ -0,0 +1,27 @@
1
+ import { Box, TableCell, Typography } from '@mui/material'
2
+ import noDataImage from './no-data-illu.svg'
3
+
4
+ const NoRecordsFound = ({ colLength }) => {
5
+ return (
6
+ <TableCell colSpan={colLength}>
7
+ <Box
8
+ sx={{
9
+ display: 'flex',
10
+ flexDirection: 'column',
11
+ alignItems: 'center',
12
+ justifyContent: 'center',
13
+ }}
14
+ >
15
+ <img
16
+ style={{ width: '200px', height: 'auto', textAlign: 'center' }}
17
+ src={noDataImage}
18
+ />
19
+ <Typography variant="h6" align="center">
20
+ No Records Found
21
+ </Typography>
22
+ </Box>
23
+ </TableCell>
24
+ )
25
+ }
26
+
27
+ export default NoRecordsFound
@@ -0,0 +1,22 @@
1
+ import { Box, Typography } from '@mui/material'
2
+
3
+ const TableStats = ({
4
+ limit,
5
+ totalCount,
6
+ page,
7
+ }: {
8
+ limit: number
9
+ page: number
10
+ totalCount: number
11
+ }) => {
12
+ const pageStart = (page - 1) * limit + 1
13
+ const pageEnd = page * limit <= totalCount ? page * limit : totalCount
14
+
15
+ return (
16
+ <Box>
17
+ <Typography variant="subtitle1">{`${pageStart} - ${pageEnd} of ${totalCount}`}</Typography>
18
+ </Box>
19
+ )
20
+ }
21
+
22
+ export default TableStats
@@ -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'
@@ -36,7 +37,7 @@ export { default as PageHeader } from './PageHeader'
36
37
  export { PageContent } from './PageContent'
37
38
  export { default as ActionButton } from './ActionButton'
38
39
  export { default as Breadcrumbs } from './Breadcrumbs'
39
- export { default as Table } from './TableComponent'
40
+ export { default as Table } from './Tables/BasicTable'
40
41
  export { default as Spinner } from './Spinner'
41
42
  export { default as AutocompleteSearch } from './AutocompleteSearch'
42
43
  export { default as JsonPreview } from './JsonPreview'
@@ -50,8 +51,8 @@ export { default as ToastContainer } from './ToastContainer'
50
51
  export { default as Card } from './Card'
51
52
  export { default as CardsGrid } from './CardsGrid'
52
53
  export { default as DividerHeading } from './DividerHeading'
53
- export { default as ReactTable } from './TableComponent/ReactTable'
54
- export { default as TableFooter } from './TableComponent/TableFooter'
54
+ export { default as ReactTable } from './Tables/ReactTable'
55
+ export { default as TableFooter } from './Tables/BasicTable/TableFooter'
55
56
  export { default as DropDownButton } from './DropDownButton'
56
57
  export { default as useConfirm } from './PopupConfirm/useConfirm'
57
58
 
@@ -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
- }
@@ -1 +0,0 @@
1
- export { default } from './TableFooter'
@@ -1,28 +0,0 @@
1
- import { Box, Pagination, styled } from '@mui/material'
2
-
3
- export const StyledTableStats = styled(Box)(({}) => ({}))
4
-
5
- export const StyledTableFooter = styled(Box)(({ theme }) => ({
6
- paddingTop: '1rem',
7
- width: '100%',
8
- display: 'flex',
9
- justifyContent: 'space-between',
10
- alignItems: 'center',
11
- }))
12
-
13
- export const StyledPagination = styled(Pagination)(({ theme }) => ({
14
- '& .MuiPaginationItem-root': {
15
- border: 'none',
16
- background: theme.palette.secondary.dark,
17
- },
18
- '& .MuiPaginationItem-previousNext': {
19
- border: theme.borders.grayLight,
20
- background: theme.palette.common.white,
21
- },
22
- '& .Mui-selected': {
23
- border: `2px solid ${theme.palette.common.yellow}`,
24
- },
25
- '& .MuiPaginationItem-ellipsis': {
26
- background: theme.palette.common.white,
27
- },
28
- }))