@campxdev/shared 1.4.23 → 1.4.25

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.4.23",
3
+ "version": "1.4.25",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -1,6 +1,8 @@
1
1
  import { MoreVert } from '@mui/icons-material'
2
2
  import {
3
3
  ButtonProps,
4
+ DialogProps,
5
+ DrawerProps,
4
6
  IconButtonProps,
5
7
  MenuListProps,
6
8
  MenuProps,
@@ -43,6 +45,7 @@ interface IModalState {
43
45
  open: boolean
44
46
  content: any
45
47
  type: MenuItemType
48
+ props: Omit<DialogProps, 'open'> | Omit<DrawerProps, 'open'>
46
49
  }
47
50
 
48
51
  const DropDownButton = ({
@@ -61,6 +64,7 @@ const DropDownButton = ({
61
64
  open: false,
62
65
  content: null,
63
66
  type: 'drawer',
67
+ props: null,
64
68
  })
65
69
 
66
70
  const handleClick = (event: any) => {
@@ -79,11 +83,12 @@ const DropDownButton = ({
79
83
  s.content = null
80
84
  })
81
85
  }
82
- const onModalOpen = (item) => {
86
+ const onModalOpen = (item, props) => {
83
87
  setModalState((s) => {
84
88
  s.content = item.content
85
89
  s.open = true
86
90
  s.type = item.actionType
91
+ s.props = props
87
92
  })
88
93
  }
89
94
 
@@ -121,13 +126,11 @@ const DropDownButton = ({
121
126
  {menu.map((item, index) => (
122
127
  <RenderMenuItem
123
128
  key={index}
124
- onModalOpen={() => onModalOpen(item)}
129
+ onModalOpen={(props) => onModalOpen(item, props)}
125
130
  modalState={modalState}
126
131
  handleClose={handleClose}
127
132
  actionType={item?.actionType}
128
- label={item.label}
129
- onClick={item?.onClick}
130
- link={item?.link}
133
+ {...item}
131
134
  />
132
135
  ))}
133
136
  </StyledMenu>
@@ -160,6 +163,7 @@ const RenderContent = ({
160
163
  open={modalState.open}
161
164
  content={modalState.content}
162
165
  title="Dialog Button"
166
+ dialogProps={modalState?.props}
163
167
  />
164
168
  )
165
169
 
@@ -170,6 +174,7 @@ const RenderContent = ({
170
174
  open={modalState.open}
171
175
  content={modalState.content}
172
176
  title="Dialog Button"
177
+ drawerProps={modalState?.props}
173
178
  />
174
179
  )
175
180
  return <></>
@@ -1,4 +1,10 @@
1
- import { ListItemIcon, ListItemText, styled } from '@mui/material'
1
+ import {
2
+ DialogProps,
3
+ DrawerProps,
4
+ ListItemIcon,
5
+ ListItemText,
6
+ styled,
7
+ } from '@mui/material'
2
8
  import { ReactNode } from 'react'
3
9
  import { Link } from 'react-router-dom'
4
10
  import { DrawerButtonProps } from '../ModalButtons/DrawerButton'
@@ -45,12 +51,14 @@ export type IMenuItemProps = Omit<MenuItemButtonProps, 'onClick'> & {
45
51
  contentTitle?: ReactNode
46
52
  actionType?: MenuItemType
47
53
  onClick?: () => void
54
+ dialogProps?: Omit<DialogProps, 'open'>
55
+ drawerProps?: Omit<DrawerProps, 'open'>
48
56
  }
49
57
 
50
58
  export interface IRenderMenuItemProps extends IMenuItemProps {
51
59
  handleClose: () => void
52
60
  modalState: any
53
- onModalOpen: () => void
61
+ onModalOpen: (props: any) => void
54
62
  }
55
63
 
56
64
  export const RenderMenuItem = ({
@@ -60,6 +68,8 @@ export const RenderMenuItem = ({
60
68
  modalState,
61
69
  onModalOpen,
62
70
  link,
71
+ drawerProps,
72
+ dialogProps,
63
73
  ...props
64
74
  }: IRenderMenuItemProps) => {
65
75
  const renderMenuItem: Record<MenuItemType, ReactNode> = {
@@ -76,7 +86,7 @@ export const RenderMenuItem = ({
76
86
  <MenuItemButton
77
87
  {...props}
78
88
  onClick={() => {
79
- onModalOpen()
89
+ onModalOpen(dialogProps)
80
90
  handleClose()
81
91
  }}
82
92
  />
@@ -85,7 +95,7 @@ export const RenderMenuItem = ({
85
95
  <MenuItemButton
86
96
  {...props}
87
97
  onClick={() => {
88
- onModalOpen()
98
+ onModalOpen(drawerProps)
89
99
  handleClose()
90
100
  }}
91
101
  />
@@ -8,6 +8,7 @@ const StyledButtonWrapper = styled(Box)<{ size: 'regular' | 'large' }>(
8
8
  flexShrink: 0,
9
9
  border: theme.borders.grayLight,
10
10
  display: 'flex',
11
+ position: 'relative',
11
12
  alignItems: 'center',
12
13
  justifyContent: 'center',
13
14
  borderRadius: '10px',
@@ -19,12 +20,24 @@ const StyledButtonWrapper = styled(Box)<{ size: 'regular' | 'large' }>(
19
20
  }),
20
21
  )
21
22
 
23
+ const StyledNotify = styled(Box)({
24
+ height: '5px',
25
+ width: '5px',
26
+ backgroundColor: 'red',
27
+ position: 'absolute',
28
+ borderRadius: '50%',
29
+ top: 3,
30
+ right: 3,
31
+ })
32
+
22
33
  export default function FilterButton({
23
34
  onClick,
24
35
  size = 'large',
36
+ filtersApplied,
25
37
  ...props
26
38
  }: {
27
39
  onClick: (e: any) => void
40
+ filtersApplied?: boolean
28
41
  size?: 'regular' | 'large'
29
42
  }) {
30
43
  const handleClick = (e) => {
@@ -34,6 +47,7 @@ export default function FilterButton({
34
47
  }
35
48
  return (
36
49
  <StyledButtonWrapper size={size} {...props} onClick={handleClick}>
50
+ {filtersApplied && <StyledNotify />}
37
51
  <Tune />
38
52
  </StyledButtonWrapper>
39
53
  )
@@ -1,9 +1,14 @@
1
- import { ExitToAppOutlined, HttpsOutlined } from '@mui/icons-material'
1
+ import {
2
+ ConfirmationNumberOutlined,
3
+ ExitToAppOutlined,
4
+ HttpsOutlined,
5
+ } from '@mui/icons-material'
2
6
  import ConfirmationNumberOutlinedIcon from '@mui/icons-material/ConfirmationNumberOutlined'
3
7
  import { ReactNode } from 'react'
4
8
  import logout from '../../../utils/logout'
5
9
  import ChangePassword from '../../ChangePassword'
6
10
  import DropDownButton from '../../DropDownButton/DropDownButton'
11
+ import { IMenuItemProps } from '../../DropDownButton/DropdownMenuItem'
7
12
  import { DialogButton } from '../../ModalButtons'
8
13
  import MyTickets from '../Tickets/MyTickets'
9
14
  import { StyledAvatar } from './styles'
@@ -21,7 +26,7 @@ export default function UserBox({
21
26
  actions,
22
27
  }: {
23
28
  fullName: string
24
- actions: { label: ReactNode; icon?: ReactNode; onClick: any }[]
29
+ actions: IMenuItemProps[] | []
25
30
  }) {
26
31
  return (
27
32
  <>
@@ -33,39 +38,23 @@ export default function UserBox({
33
38
  )}
34
39
  menu={[
35
40
  ...actions,
36
- // {
37
- // customButton: (
38
- // <DialogButton
39
- // dialogProps={{
40
- // maxWidth: 'xl',
41
- // }}
42
- // title="My Tickets"
43
- // anchor={({ open }) => (
44
- // <DropDownButton.MenuItem
45
- // onClick={open}
46
- // icon={<ConfirmationNumberOutlinedIcon />}
47
- // label="My Tickets"
48
- // />
49
- // )}
50
- // content={({ close }) => <MyTickets close={close} />}
51
- // />
52
- // ),
53
- // },
54
- // {
55
- // customButton: (
56
- // <DialogButton
57
- // title="Change Password"
58
- // anchor={({ open }) => (
59
- // <DropDownButton.MenuItem
60
- // onClick={open}
61
- // icon={<HttpsOutlined />}
62
- // label="Change Password"
63
- // />
64
- // )}
65
- // content={({ close }) => <ChangePassword close={close} />}
66
- // />
67
- // ),
68
- // },
41
+ {
42
+ label: 'My Tickets',
43
+ actionType: 'dialog',
44
+ content: ({ close }) => <MyTickets close={close} />,
45
+ contentTitle: 'My Tickets',
46
+ icon: <ConfirmationNumberOutlined />,
47
+ dialogProps: {
48
+ maxWidth: 'xl',
49
+ },
50
+ },
51
+ {
52
+ label: 'Change Password',
53
+ actionType: 'dialog',
54
+ icon: <HttpsOutlined />,
55
+ content: ({ close }) => <ChangePassword close={close} />,
56
+ contentTitle: 'Change Password',
57
+ },
69
58
  {
70
59
  label: 'Logout',
71
60
  icon: <ExitToAppOutlined />,
@@ -42,7 +42,7 @@ export const Transition = forwardRef(function Transition(
42
42
  interface DrawerButtonProps {
43
43
  anchor: (props: { open: () => void }) => ReactNode
44
44
  content: (props: { close: () => void }) => ReactNode
45
- title: string | ReactNode
45
+ title: string
46
46
  dialogProps?: Omit<DialogProps, 'open'>
47
47
  onDialogClose?: () => void
48
48
  }
@@ -83,10 +83,10 @@ export default function DialogButton({
83
83
 
84
84
  interface CustomDialogProps {
85
85
  content: (props: { close: () => void }) => ReactNode
86
- title: string | ReactNode
87
- dialogProps?: Omit<DialogProps, 'open'>
86
+ title: string
88
87
  onClose: () => void
89
88
  open: boolean
89
+ dialogProps?: Omit<DialogProps, 'open'>
90
90
  }
91
91
 
92
92
  export const CustomDialog = ({