@campxdev/shared 1.2.9 → 1.3.0

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.
@@ -7,7 +7,9 @@ import {
7
7
  styled,
8
8
  Typography,
9
9
  Link,
10
+ Avatar,
10
11
  } from '@mui/material'
12
+ import { Link as RouterLink } from 'react-router-dom'
11
13
 
12
14
  export const StyledImageWrapper = styled('div')`
13
15
  width: auto;
@@ -36,7 +38,7 @@ export const StyledHeader = styled(Box)(({ theme }) => ({
36
38
  alignItems: 'center',
37
39
  justifyContent: 'space-between',
38
40
  '& .actions': {
39
- marginRight: '10px',
41
+ marginRight: '20px',
40
42
  display: 'flex',
41
43
  alignItems: 'center',
42
44
  gap: '14px',
@@ -63,6 +65,7 @@ export const StyledIconButton = styled(IconButton)({
63
65
  alignItems: 'center',
64
66
  justifyContent: 'center',
65
67
  borderRadius: '0px',
68
+ border: '1px solid white',
66
69
  })
67
70
 
68
71
  export const StyledLink = styled(Link)({
@@ -96,3 +99,26 @@ export const StyledMenuItemContainer = styled(Box)(({ theme }) => ({
96
99
  },
97
100
  padding: '8px 0px',
98
101
  }))
102
+
103
+ export const StyledAvatar = styled(Avatar)(({ theme }) => ({
104
+ background: theme.palette.secondary.main,
105
+ cursor: 'pointer',
106
+ height: '45px',
107
+ width: '45px',
108
+ }))
109
+
110
+ export const StyledLogosWrapper = styled(Box)(() => ({
111
+ display: 'flex',
112
+ alignItems: 'center',
113
+ gap: '10px',
114
+ padding: '10px',
115
+ transition: 'background ease 0.3s',
116
+ borderRadius: '5px',
117
+ '&:hover': {
118
+ background: 'rgba(0, 0, 0, 0.05)',
119
+ },
120
+ }))
121
+
122
+ export const StyledRouterLink = styled(RouterLink)(() => ({
123
+ textDecoration: 'none',
124
+ }))
@@ -2,41 +2,38 @@ import { Box, Typography } from '@mui/material'
2
2
  import moment from 'moment'
3
3
  import { useState } from 'react'
4
4
  import { useQuery } from 'react-query'
5
- import axios from '../../../config/axios'
5
+ import ErrorBoundary from '../../ErrorBoundary'
6
6
  import Spinner from '../../Spinner'
7
- // import { getImage } from './Services'
7
+ import { fetchTickets } from './services'
8
8
  import { StyledCardData, StyledLeftContainer, StyledListItem } from './styles'
9
9
  import TicketDetails from './TicketDetails'
10
10
 
11
- function MyTickets() {
11
+ function MyTickets({ close }) {
12
12
  const [currentTicket, setCurrentTicket] = useState(null)
13
- const { data, isLoading } = useQuery<any>('tickets', () =>
14
- axios
15
- .get('/square/service-tickets/my-tickets')
16
- .then((res) => res.data.result),
17
- )
18
- // const { data: imageData } = useQuery('imageData', () => getImage(data))
13
+
14
+ const { data, isLoading } = useQuery<any>('tickets', fetchTickets)
15
+
19
16
  if (isLoading) return <Spinner />
20
17
  return (
21
- <Box sx={{ display: 'flex', gap: '20px' }}>
22
- <Box sx={{ margin: '10px', borderRadius: '10px' }}>
23
- <StyledLeftContainer>
24
- {data?.map((item) => (
25
- <TicketListItem
26
- key={item}
27
- data={item}
28
- setCurrentTicket={setCurrentTicket}
29
- currentTicket={currentTicket}
30
- />
31
- ))}
32
- </StyledLeftContainer>
18
+ <ErrorBoundary>
19
+ <Box sx={{ display: 'flex', gap: '20px' }}>
20
+ <Box sx={{ margin: '10px', borderRadius: '10px' }}>
21
+ <StyledLeftContainer>
22
+ {data?.result?.map((item) => (
23
+ <TicketListItem
24
+ key={item}
25
+ data={item}
26
+ setCurrentTicket={setCurrentTicket}
27
+ currentTicket={currentTicket}
28
+ />
29
+ ))}
30
+ </StyledLeftContainer>
31
+ </Box>
32
+ {currentTicket?._id && (
33
+ <TicketDetails data={currentTicket} id={currentTicket._id} />
34
+ )}
33
35
  </Box>
34
- {currentTicket?._id ? (
35
- <TicketDetails data={currentTicket} id={currentTicket._id} />
36
- ) : (
37
- ''
38
- )}
39
- </Box>
36
+ </ErrorBoundary>
40
37
  )
41
38
  }
42
39
 
@@ -47,7 +44,6 @@ const TicketListItem = ({ data, setCurrentTicket, currentTicket }) => {
47
44
  <StyledListItem
48
45
  isActive={currentTicket?._id === data?._id ? true : false}
49
46
  onClick={() => {
50
- // set selected ticket data
51
47
  setCurrentTicket(data)
52
48
  }}
53
49
  >
@@ -1,18 +1,12 @@
1
- /* eslint-disable react/jsx-key */
2
1
  import { Box, Card, Stack, Typography } from '@mui/material'
3
- import axios from 'axios'
4
2
  import moment from 'moment'
5
3
  import { useQuery } from 'react-query'
6
- import { getImage } from './Services'
4
+ import { getImage } from './services'
7
5
  import { StyledBoxDetails, StyledCardData } from './styles'
8
6
  import StyledTimeLine from './TimeLine'
9
- // export const getImage = async (id: string) => {
10
- // let imgData = await axios.get(`/service-tickets/${id}`)
11
- // return imgData?.data
12
- // }
7
+
13
8
  function TicketDetails({ data, id }) {
14
9
  const { data: imageData } = useQuery(['imageData', id], () => getImage(id))
15
- console.log(imageData, 'imagedata')
16
10
  return (
17
11
  <Box>
18
12
  {data ? (
@@ -34,8 +28,13 @@ function TicketDetails({ data, id }) {
34
28
  {data?.description}
35
29
  </Typography>
36
30
  <Stack direction={'column'} gap="20px" sx={{ marginTop: '10px' }}>
37
- {imageData?.issueFiles?.map((item) => (
38
- <img src={item?.url} height={'100px'} width={'200px'} />
31
+ {imageData?.issueFiles?.map((item, index) => (
32
+ <img
33
+ src={item?.url}
34
+ height={'100px'}
35
+ width={'200px'}
36
+ key={index}
37
+ />
39
38
  ))}
40
39
  </Stack>
41
40
  </Box>
@@ -4,3 +4,8 @@ export const getImage = async (id: string) => {
4
4
  let imageData = await axios.get(`/square/service-tickets/${id}`)
5
5
  return imageData?.data
6
6
  }
7
+
8
+ export const fetchTickets = async () => {
9
+ let imageData = await axios.get(`/square/service-tickets/my-tickets`)
10
+ return imageData?.data
11
+ }
@@ -1,83 +1,88 @@
1
1
  import { Close } from '@mui/icons-material'
2
2
  import {
3
- alpha,
4
3
  Box,
5
- ButtonProps,
6
4
  Dialog,
7
5
  DialogProps,
6
+ DialogTitle,
7
+ Grow,
8
8
  IconButton,
9
9
  styled,
10
- Typography,
11
10
  } from '@mui/material'
12
- import { createElement, ReactNode, useState } from 'react'
11
+ import { TransitionProps } from '@mui/material/transitions'
12
+ import { forwardRef, ReactNode, useState } from 'react'
13
13
 
14
- const StyledDialogHeader = styled(Box)(({ theme }) => ({
14
+ const StyledDialogHeader = styled(Box)(() => ({
15
15
  height: '64px',
16
- backgroundColor: alpha(theme.palette.text.secondary, 0.1),
16
+ backgroundColor: '#f7f7f7',
17
17
  display: 'flex',
18
18
  justifyContent: 'space-between',
19
- alignItems: 'center',
19
+ alignItems: 'end',
20
20
  padding: '0.6rem 1rem',
21
+ paddingBottom: '10px',
21
22
  }))
22
23
 
23
- const StyledDialogContent = styled(Box)(({ theme }) => ({
24
+ const StyledDialogContent = styled(Box)(() => ({
24
25
  width: '100%',
25
26
  padding: '1rem',
26
27
  }))
27
28
 
28
- type ContentProps = {
29
- close: () => void
30
- }
29
+ export const Transition = forwardRef(function Transition(
30
+ props: TransitionProps & {
31
+ children: React.ReactElement
32
+ },
33
+ ref: React.Ref<unknown>,
34
+ ) {
35
+ return <Grow timeout={1000} ref={ref} {...props} />
36
+ })
31
37
 
32
38
  interface DrawerButtonProps {
33
- button: any
34
- content: (props: ContentProps) => ReactNode
39
+ anchor: (props: { open: () => void }) => ReactNode
40
+ content: (props: { close: () => void }) => ReactNode
35
41
  title: string | ReactNode
36
- btnTxt?: string | ReactNode
37
- btnProps?: ButtonProps
38
42
  dialogProps?: Omit<DialogProps, 'open'>
39
43
  onDialogClose?: () => void
40
44
  }
41
45
 
42
46
  export default function DialogButton({
43
- button: Button,
44
47
  content,
45
48
  title,
46
- btnTxt,
47
- btnProps,
48
49
  dialogProps,
49
50
  onDialogClose,
51
+ anchor,
50
52
  }: DrawerButtonProps) {
51
53
  const [open, setOpen] = useState(false)
52
54
 
53
- const ButtonEl = (props) => (
54
- <Button {...props} {...btnProps} sx={{ fontSize: '14px', fontWeight: 600 }}>
55
- {btnTxt}
56
- </Button>
57
- )
58
-
59
- const MyButton = createElement(ButtonEl, {
60
- onClick: () => setOpen(true),
61
- })
62
-
63
55
  const onClose = () => {
64
56
  onDialogClose && onDialogClose()
65
57
  setOpen(false)
66
58
  }
59
+
60
+ const onOpen = () => {
61
+ setOpen(true)
62
+ }
63
+
67
64
  return (
68
65
  <>
69
- {MyButton}
66
+ {anchor({
67
+ open: onOpen,
68
+ })}
70
69
  <Dialog
71
- PaperProps={{ sx: { borderRadius: '10px' } }}
70
+ PaperProps={{ elevation: 2, sx: { borderRadius: '10px' } }}
72
71
  fullWidth
73
72
  onClose={onClose}
74
73
  open={open}
75
- transitionDuration={200}
74
+ transitionDuration={100}
75
+ TransitionComponent={Transition}
76
+ sx={{
77
+ '& .MuiBackdrop-root': {
78
+ backgroundColor: 'rgba(0, 0, 0, 0.4)',
79
+ },
80
+ }}
76
81
  {...dialogProps}
77
82
  >
78
83
  <StyledDialogHeader>
79
- <Typography fontWeight={600}>{title}</Typography>
80
- <IconButton onClick={onClose}>
84
+ <DialogTitle>{title}</DialogTitle>
85
+ <IconButton onClick={onClose} sx={{ color: 'black' }}>
81
86
  <Close />
82
87
  </IconButton>
83
88
  </StyledDialogHeader>
@@ -3,20 +3,21 @@ import {
3
3
  alpha,
4
4
  Box,
5
5
  ButtonProps,
6
+ DialogTitle,
6
7
  Drawer,
7
8
  IconButton,
8
9
  styled,
9
- Typography,
10
10
  } from '@mui/material'
11
- import { createElement, ReactNode, useState } from 'react'
11
+ import { ReactNode, useState } from 'react'
12
12
 
13
13
  const StyledDrawerHeader = styled(Box)(({ theme }) => ({
14
14
  height: '64px',
15
- backgroundColor: alpha(theme.palette.text.secondary, 0.1),
15
+ backgroundColor: '#f7f7f7',
16
16
  display: 'flex',
17
17
  justifyContent: 'space-between',
18
- alignItems: 'center',
18
+ alignItems: 'end',
19
19
  padding: '0.6rem 1rem',
20
+ paddingBottom: '10px',
20
21
  }))
21
22
 
22
23
  const StyledDrawerContent = styled(Box)(({ theme }) => ({
@@ -26,59 +27,54 @@ const StyledDrawerContent = styled(Box)(({ theme }) => ({
26
27
  paddingBottom: '4rem',
27
28
  }))
28
29
 
29
- type ContentProps = {
30
- close: () => void
31
- }
32
-
33
30
  interface DrawerButtonProps {
34
- button: any
35
- content: (props: ContentProps) => ReactNode
31
+ anchor: (props: { open: () => void }) => ReactNode
32
+ content: (props: { close: () => void }) => ReactNode
36
33
  title: string | ReactNode
37
34
  btnTxt?: string | ReactNode
38
35
  btnProps?: ButtonProps
39
36
  }
40
37
 
41
38
  export default function DrawerButton({
42
- button: Button,
43
39
  content,
44
40
  title,
45
- btnTxt,
46
- btnProps,
41
+ anchor,
47
42
  }: DrawerButtonProps) {
48
43
  const [open, setOpen] = useState(false)
49
44
 
50
- const ButtonEl = (props) => (
51
- <Button {...props} {...btnProps} sx={{ fontSize: '14px', fontWeight: 600 }}>
52
- {btnTxt}
53
- </Button>
54
- )
55
-
56
- const MyButton = createElement(ButtonEl, {
57
- onClick: () => setOpen(true),
58
- })
45
+ const onOpen = () => {
46
+ setOpen(true)
47
+ }
59
48
 
60
49
  const onClose = () => {
61
50
  setOpen(false)
62
51
  }
63
52
  return (
64
53
  <>
65
- {MyButton}
54
+ {anchor({ open: onOpen })}
66
55
  <Drawer
67
56
  anchor="right"
68
57
  elevation={10}
69
58
  onClose={onClose}
70
59
  open={open}
60
+ PaperProps={{
61
+ elevation: 2,
62
+ }}
71
63
  sx={{
72
64
  zIndex: 500,
73
65
  '& .MuiDrawer-paper': {
74
66
  boxSizing: 'border-box',
75
67
  width: 600,
76
68
  },
69
+ '& .MuiBackdrop-root': {
70
+ backgroundColor: 'rgba(0, 0, 0, 0.4)',
71
+ },
77
72
  }}
73
+ transitionDuration={200}
78
74
  >
79
75
  <StyledDrawerHeader>
80
- <Typography fontWeight={600}>{title}</Typography>
81
- <IconButton onClick={onClose}>
76
+ <DialogTitle>{title}</DialogTitle>
77
+ <IconButton onClick={onClose} sx={{ color: 'black' }}>
82
78
  <Close />
83
79
  </IconButton>
84
80
  </StyledDrawerHeader>
@@ -1,5 +1,5 @@
1
1
  import { Box, Typography } from '@mui/material'
2
- import DropDownButton from '../DropDownButton'
2
+ import DropDownButton from '../DropDownButton/DropDownButton'
3
3
  import {
4
4
  StyledActionIconButton,
5
5
  StyledActionsRow,
@@ -1,5 +1,5 @@
1
1
  import { Box, Typography } from '@mui/material'
2
- import DropDownButton from '../../DropDownButton'
2
+ import DropDownButton from '../../DropDownButton/DropDownButton'
3
3
  import { StyledPagination, StyledTableFooter } from '../styles'
4
4
 
5
5
  interface TableFooterProps {
@@ -62,17 +62,19 @@ const LimitField = ({ handlePageLimit, limit }) => {
62
62
  return (
63
63
  <Box>
64
64
  <DropDownButton
65
- buttonProps={{
66
- variant: 'outlined',
67
- color: 'secondary',
68
- sx: {
69
- padding: '0px 10px',
70
- color: '#121212',
71
- fontSize: '13px',
72
- border: '1px solid #1212121A',
65
+ button={{
66
+ buttonProps: {
67
+ variant: 'outlined',
68
+ color: 'secondary',
69
+ sx: {
70
+ padding: '0px 10px',
71
+ color: '#121212',
72
+ fontSize: '13px',
73
+ border: '1px solid #1212121A',
74
+ },
73
75
  },
76
+ label: `${limit} / page`,
74
77
  }}
75
- label={`${limit} / page`}
76
78
  menu={[
77
79
  {
78
80
  label: 10,
@@ -8,7 +8,6 @@ import SearchBar from './SearchBar'
8
8
  import { DrawerButton, DialogButton } from './ModalButtons'
9
9
  import DetailsGrid from './DetailsGrid'
10
10
  import AppHeader from './Layout/Header'
11
- import MenuButton from './MenuButton'
12
11
  import StepsHeader from './StepsHeader'
13
12
  import UploadDocument from './UploadDocument'
14
13
  import { Table as StyledTable } from './Table'
@@ -61,7 +60,6 @@ export {
61
60
  DialogButton,
62
61
  DetailsGrid,
63
62
  AppHeader,
64
- MenuButton,
65
63
  StepsHeader,
66
64
  UploadDocument,
67
65
  StyledTable,
@@ -104,7 +104,7 @@ const muiTheme = createTheme({
104
104
  root: {
105
105
  color: '#121212',
106
106
  fontSize: '14px',
107
- fontWeight: 500,
107
+ fontWeight: 600,
108
108
  fontFamily: PRIMARY_FONT,
109
109
  },
110
110
  h1: {
@@ -157,30 +157,26 @@ const muiTheme = createTheme({
157
157
  styleOverrides: {
158
158
  root: {
159
159
  fontFamily: SECONDARY_FONT,
160
- height: '40px',
161
- padding: '10px 36px',
160
+ height: '50px',
161
+ fontSize: '14px',
162
+ padding: '10px 40px',
162
163
  textTransform: 'capitalize',
163
164
  fontWeight: 600,
164
165
  borderRadius: borderRadius.small,
165
166
  '&.MuiButton-sizeSmall': {
166
167
  padding: '6px 8px',
167
- height: '32px',
168
- fontSize: '13px',
168
+ height: '40px',
169
+ fontSize: '14px',
169
170
  },
170
171
  },
171
172
  },
172
173
  },
173
174
  MuiButtonBase: {
174
- defaultProps: {
175
- disableRipple: true,
176
- },
177
175
  styleOverrides: {
178
176
  root: {
179
177
  fontFamily: SECONDARY_FONT,
180
- '&.MuiButton-textSizeSmall': {
181
- padding: '6px 8px',
182
- height: '32px',
183
- },
178
+ fontSize: '14px',
179
+ fontWeight: 600,
184
180
  },
185
181
  },
186
182
  },
@@ -225,9 +221,7 @@ const muiTheme = createTheme({
225
221
  },
226
222
  root: {
227
223
  '.MuiAutocomplete-inputRoot.MuiOutlinedInput-root .MuiAutocomplete-endAdornment':
228
- {
229
- right: 14,
230
- },
224
+ { right: 14 },
231
225
  '& .MuiAutocomplete-tag': {
232
226
  border: '1px solid #D1D1D1',
233
227
  background: '#F8F8F8',
@@ -454,6 +448,16 @@ const muiTheme = createTheme({
454
448
  },
455
449
  },
456
450
  },
451
+ MuiDialogTitle: {
452
+ styleOverrides: {
453
+ root: {
454
+ fontFamily: SECONDARY_FONT,
455
+ fontWeight: 500,
456
+ fontSize: '16px',
457
+ padding: 0,
458
+ },
459
+ },
460
+ },
457
461
  MuiChip: {
458
462
  styleOverrides: {
459
463
  root: {