@campxdev/shared 1.5.4 → 1.5.7

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.5.4",
3
+ "version": "1.5.7",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -1,2 +1,13 @@
1
- const avenirFont = require('./Avenir.ttc')
2
- export { avenirFont }
1
+ const avenirRegular = require('./Avenir-Book.ttf')
2
+ const avenirMedium = require('./Avenir-Medium.ttf')
3
+ const avenirMediumObliquue = require('./Avenir-MediumOblique.ttf')
4
+ const avenirHeavy = require('./Avenir-Heavy.ttf')
5
+ const avenirHeavyObliquue = require('./Avenir-HeavyOblique.ttf')
6
+
7
+ export {
8
+ avenirRegular,
9
+ avenirHeavy,
10
+ avenirHeavyObliquue,
11
+ avenirMedium,
12
+ avenirMediumObliquue,
13
+ }
@@ -3,5 +3,16 @@ const semiboldPoppins = require('./Poppins-SemiBold.ttf')
3
3
  const mediumPoppins = require('./Poppins-Medium.ttf')
4
4
  const lightPoppins = require('./Poppins-Light.ttf')
5
5
  const regularPoppins = require('./Poppins-Regular.ttf')
6
+ const regularPoppinsItalic = require('./Poppins-Italic.ttf')
7
+ const mediumPoppinsItalic = require('./Poppins-MediumItalic.ttf')
8
+ const lightPoppinsItalic = require('./Poppins-LightItalic.ttf')
6
9
 
7
- export { semiboldPoppins, mediumPoppins, lightPoppins, regularPoppins }
10
+ export {
11
+ semiboldPoppins,
12
+ mediumPoppins,
13
+ lightPoppins,
14
+ regularPoppins,
15
+ regularPoppinsItalic,
16
+ mediumPoppinsItalic,
17
+ lightPoppinsItalic,
18
+ }
@@ -16,6 +16,7 @@ export interface IDatePicker {
16
16
  onChange: (value: Date) => void
17
17
  placeholder?: string
18
18
  inputProps?: TextFieldProps
19
+ size?: 'medium' | 'small'
19
20
  }
20
21
 
21
22
  export default function FormDatePicker({
@@ -26,6 +27,7 @@ export default function FormDatePicker({
26
27
  value,
27
28
  onChange,
28
29
  placeholder,
30
+ size = 'medium',
29
31
  required = false,
30
32
  ...rest
31
33
  }: IDatePicker) {
@@ -38,6 +40,7 @@ export default function FormDatePicker({
38
40
  dateFormat: 'd-m-Y',
39
41
  minDate,
40
42
  maxDate,
43
+ allowInput: true,
41
44
  }}
42
45
  value={value || null}
43
46
  render={(
@@ -46,6 +49,7 @@ export default function FormDatePicker({
46
49
  ) => {
47
50
  return (
48
51
  <TextField
52
+ size={size}
49
53
  placeholder={placeholder}
50
54
  label={label}
51
55
  name={name}
@@ -18,6 +18,7 @@ export interface IDateTimePicker {
18
18
  placeholder?: string
19
19
  inputProps?: TextFieldProps
20
20
  enableTime?: boolean
21
+ size?: 'medium' | 'small'
21
22
  }
22
23
 
23
24
  export default function DateTimePicker({
@@ -32,6 +33,7 @@ export default function DateTimePicker({
32
33
  value,
33
34
  placeholder,
34
35
  enableTime = true,
36
+ size = 'medium',
35
37
  ...rest
36
38
  }: IDateTimePicker) {
37
39
  return (
@@ -43,6 +45,7 @@ export default function DateTimePicker({
43
45
  maxDate,
44
46
  minTime,
45
47
  maxTime,
48
+ allowInput: true,
46
49
  }}
47
50
  onChange={(dates: Date[]) => {
48
51
  if (onChange) onChange(dates[0])
@@ -54,6 +57,7 @@ export default function DateTimePicker({
54
57
  ) => {
55
58
  return (
56
59
  <TextField
60
+ size={size}
57
61
  placeholder={placeholder}
58
62
  label={label}
59
63
  name={name}
@@ -15,6 +15,7 @@ export interface ITimePicker {
15
15
  onChange: (value: Date) => void
16
16
  placeholder?: string
17
17
  inputProps?: TextFieldProps
18
+ size?: 'medium' | 'small'
18
19
  }
19
20
 
20
21
  export default function TimePicker({
@@ -26,6 +27,7 @@ export default function TimePicker({
26
27
  onChange,
27
28
  value,
28
29
  placeholder,
30
+ size = 'medium',
29
31
  ...rest
30
32
  }: ITimePicker) {
31
33
  return (
@@ -36,6 +38,7 @@ export default function TimePicker({
36
38
  dateFormat: 'h:i K',
37
39
  minTime,
38
40
  maxTime,
41
+ allowInput: true,
39
42
  }}
40
43
  onChange={(dates: Date[]) => {
41
44
  if (onChange) onChange(dates[0])
@@ -47,6 +50,7 @@ export default function TimePicker({
47
50
  ) => {
48
51
  return (
49
52
  <TextField
53
+ size={size}
50
54
  placeholder={placeholder}
51
55
  label={label}
52
56
  name={name}
@@ -1,33 +1,66 @@
1
- import {
2
- Button,
3
- Dialog,
4
- DialogActions,
5
- DialogContent,
6
- DialogTitle,
7
- } from '@mui/material'
1
+ import { Box, Button, Dialog, styled, Typography } from '@mui/material'
8
2
  import useConfirm from './useConfirm'
3
+ const animatedImage = require('./animation.gif')
4
+
5
+ const StyledImage = styled((props: any) => (
6
+ <Box>
7
+ <img {...props} />
8
+ </Box>
9
+ ))(({ theme }) => ({
10
+ width: '154px',
11
+ '> img': {
12
+ width: '100%',
13
+ height: '100%',
14
+ objectFit: 'contain',
15
+ },
16
+ }))
17
+
18
+ const StyledDialogContent = styled(Box)(({ theme }) => ({
19
+ height: '360px',
20
+ width: '570px',
21
+ display: 'flex',
22
+ alignItems: 'center',
23
+ justifyContent: 'center',
24
+ flexDirection: 'column',
25
+ }))
9
26
 
10
27
  const PopupConfirm = () => {
11
28
  const { prompt = '', isOpen = false, proceed, cancel } = useConfirm()
12
29
  return (
13
30
  <Dialog
14
- sx={{ zIndex: 1600 }}
31
+ PaperProps={{
32
+ elevation: 2,
33
+ sx: {
34
+ borderRadius: '10px',
35
+ },
36
+ }}
37
+ sx={{
38
+ '& .MuiBackdrop-root': { backgroundColor: 'rgba(0, 0, 0, 0.4)' },
39
+ zIndex: 1600,
40
+ }}
15
41
  keepMounted
16
42
  maxWidth="sm"
17
43
  fullWidth
18
44
  open={isOpen}
19
45
  transitionDuration={150}
20
46
  >
21
- <DialogTitle>Confirm</DialogTitle>
22
- <DialogContent sx={{ minHeight: '40px' }}>{prompt}</DialogContent>
23
- <DialogActions>
24
- <Button variant="contained" color="primary" onClick={proceed}>
25
- Ok
26
- </Button>
27
- <Button color="secondary" variant="outlined" onClick={cancel}>
28
- Cancel
29
- </Button>
30
- </DialogActions>
47
+ <StyledDialogContent>
48
+ <Box sx={{ marginBottom: '20px' }}>
49
+ <StyledImage src={animatedImage} alt="Upload Image" />
50
+ </Box>
51
+
52
+ <Typography variant="h6" sx={{ minHeight: '30px' }}>
53
+ {prompt}
54
+ </Typography>
55
+ <Box sx={{ display: 'flex', gap: '20px', marginTop: '30px' }}>
56
+ <Button color="secondary" variant="outlined" onClick={cancel}>
57
+ No, Cancel
58
+ </Button>
59
+ <Button variant="outlined" onClick={proceed} sx={{ height: '40px' }}>
60
+ Yes, I'm. Sure
61
+ </Button>
62
+ </Box>
63
+ </StyledDialogContent>
31
64
  </Dialog>
32
65
  )
33
66
  }
@@ -1,7 +1,8 @@
1
- import { Done } from '@mui/icons-material'
1
+ import { Done, Close, WarningAmberRounded } from '@mui/icons-material'
2
2
  import { Box } from '@mui/material'
3
3
  import { Slide, ToastContainer as ReactToastContainer } from 'react-toastify'
4
4
  import 'react-toastify/dist/ReactToastify.css'
5
+ import WarningAmberRoundedIcon from '@mui/icons-material/WarningAmberRounded'
5
6
 
6
7
  export default function ToastContainer() {
7
8
  return (
@@ -18,12 +19,26 @@ export default function ToastContainer() {
18
19
  draggable
19
20
  pauseOnHover
20
21
  theme="colored"
21
- icon={<Icon />}
22
+ icon={({ type }) => <Icon type={type} />}
22
23
  />
23
24
  )
24
25
  }
25
26
 
26
- const Icon = () => {
27
+ const Icon = ({ type }) => {
28
+ const renderIcon = () => {
29
+ switch (type) {
30
+ case 'error':
31
+ return <Close />
32
+ case 'success':
33
+ return <Done />
34
+ case 'warning':
35
+ return <WarningAmberRounded />
36
+
37
+ default:
38
+ return <Done />
39
+ }
40
+ }
41
+
27
42
  return (
28
43
  <Box
29
44
  sx={{
@@ -36,7 +51,7 @@ const Icon = () => {
36
51
  justifyContent: 'center',
37
52
  }}
38
53
  >
39
- <Done />
54
+ {renderIcon()}
40
55
  </Box>
41
56
  )
42
57
  }
@@ -1,28 +1,53 @@
1
1
  import React, { useEffect, useState } from 'react'
2
2
 
3
- export default function useFilters(initialState, key) {
3
+ export default function useFilters(initialState, key?: any) {
4
4
  const [filters, setFilters] = useState(initialState)
5
5
  const [filtersApplied, setFiltersApplied] = useState(false)
6
6
 
7
+ useEffect(() => {
8
+ const prevFilters = getSessionFilters()
9
+ setFilters({
10
+ ...filters,
11
+ ...prevFilters,
12
+ })
13
+ }, [])
14
+
7
15
  function onFilterChange(modified) {
8
16
  setFilters({
9
17
  ...filters,
10
18
  ...modified,
11
19
  })
12
20
 
13
- const sessionData = Object.keys(modified).reduce((acc, curr) => {
14
- if (!!modified[curr]) {
15
- acc.push({ key: curr, value: modified[curr] })
21
+ const filterData = {
22
+ ...filters,
23
+ ...modified,
24
+ }
25
+
26
+ const sessionData = Object.keys(filterData).map((item, key) => {
27
+ if (filtersCheck(item, filterData)) {
28
+ return { key: item, value: filterData[item] }
16
29
  }
17
- return acc
18
- }, [])
30
+ })
19
31
 
20
- if (sessionData?.length > 0) {
21
- sessionStorage.setItem(key, JSON.stringify(sessionData))
32
+ const filteredSessionArray = sessionData.filter(
33
+ (value) => value !== undefined,
34
+ )
35
+
36
+ if (filteredSessionArray?.length > 0) {
37
+ sessionStorage.setItem(key, JSON.stringify(filteredSessionArray))
22
38
  setFiltersApplied(true)
23
- } else {
24
- sessionStorage.removeItem(key)
25
- setFiltersApplied(false)
39
+ }
40
+ }
41
+
42
+ function filtersCheck(item: any, filterData: any) {
43
+ switch (true) {
44
+ case !!filterData[item] &&
45
+ item !== 'limit' &&
46
+ item !== 'offset' &&
47
+ item !== 'page':
48
+ return true
49
+ default:
50
+ return false
26
51
  }
27
52
  }
28
53
 
@@ -32,14 +57,6 @@ export default function useFilters(initialState, key) {
32
57
  sessionStorage.removeItem(key)
33
58
  }
34
59
 
35
- useEffect(() => {
36
- const prevFilters = getSessionFilters()
37
- setFilters({
38
- ...filters,
39
- ...prevFilters,
40
- })
41
- }, [])
42
-
43
60
  const getSessionFilters = () => {
44
61
  try {
45
62
  if (sessionStorage.getItem(key)) {
@@ -1,50 +1,109 @@
1
- import { avenirFont } from '../assets/fonts/avenir'
1
+ import {
2
+ avenirHeavy,
3
+ avenirHeavyObliquue,
4
+ avenirMedium,
5
+ avenirMediumObliquue,
6
+ avenirRegular,
7
+ } from '../assets/fonts/avenir'
2
8
  import {
3
9
  lightPoppins,
4
10
  mediumPoppins,
5
11
  regularPoppins,
6
12
  semiboldPoppins,
13
+ lightPoppinsItalic,
14
+ mediumPoppinsItalic,
15
+ regularPoppinsItalic,
7
16
  } from '../assets/fonts/poppins'
8
17
 
9
- const uniCode =
10
- 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF'
11
-
12
18
  export const customCssBaseline = `
19
+ :root{
20
+ --toastify-color-info: #3498db;
21
+ --toastify-color-success: #7EB872;
22
+ --toastify-color-warning: #f1c40f;
23
+ --toastify-color-error: #BC2C3D;
24
+ }
25
+
13
26
  html, body {
14
27
  font-size: 14px;
15
28
  font-family: Avenir, sans-serif;
16
29
  font-weight: 400;
17
30
  }
31
+
32
+ @font-face {
33
+ font-family: Avenir;
34
+ src: url(${avenirRegular}) format('truetype');
35
+ font-display: swap;
36
+ font-weight: 400;
37
+ }
18
38
  @font-face {
19
39
  font-family: Avenir;
20
- src: url(${avenirFont});
40
+ src: url(${avenirMedium}) format('truetype');
21
41
  font-display: swap;
42
+ font-weight: 500;
22
43
  }
44
+ @font-face {
45
+ font-family: Avenir;
46
+ src: url(${avenirMediumObliquue}) format('truetype');
47
+ font-display: swap;
48
+ font-weight: 500;
49
+ font-style: oblique;
50
+ }
51
+ @font-face {
52
+ font-family: Avenir;
53
+ src: url(${avenirHeavy}) format('truetype');
54
+ font-display: swap;
55
+ font-weight: 600;
56
+ }
57
+ @font-face {
58
+ font-family: Avenir;
59
+ src: url(${avenirHeavyObliquue}) format('truetype');
60
+ font-display: swap;
61
+ font-weight: 600;
62
+ font-style: oblique;
63
+ }
64
+
23
65
  @font-face {
24
66
  font-family: Poppins;
25
67
  src: url(${lightPoppins}) format('truetype');
26
- unicodeRange: ${uniCode};
27
68
  font-display: swap;
28
69
  font-weight: 300;
29
70
  }
30
71
  @font-face {
31
72
  font-family: Poppins;
32
- src: url(${mediumPoppins}) format('truetype');
33
- unicodeRange: ${uniCode};
73
+ src: url(${lightPoppinsItalic}) format('truetype');
34
74
  font-display: swap;
35
- font-weight: 500;
75
+ font-weight: 300;
76
+ font-style: italic;
36
77
  }
37
78
  @font-face {
38
79
  font-family: Poppins;
39
80
  src: url(${regularPoppins}) format('truetype');
40
- unicodeRange: ${uniCode};
41
81
  font-display: swap;
42
82
  font-weight: 400;
43
83
  }
84
+ @font-face {
85
+ font-family: Poppins;
86
+ src: url(${regularPoppinsItalic}) format('truetype');
87
+ font-display: swap;
88
+ font-weight: 400;
89
+ font-style: italic;
90
+ }
91
+ @font-face {
92
+ font-family: Poppins;
93
+ src: url(${mediumPoppins}) format('truetype');
94
+ font-display: swap;
95
+ font-weight: 500;
96
+ }
97
+ @font-face {
98
+ font-family: Poppins;
99
+ src: url(${mediumPoppinsItalic}) format('truetype');
100
+ font-display: swap;
101
+ font-weight: 500;
102
+ font-style: italic;
103
+ }
44
104
  @font-face {
45
105
  font-family: Poppins;
46
106
  src: url(${semiboldPoppins}) format('truetype');
47
- unicodeRange: ${uniCode};
48
107
  font-display: swap;
49
108
  font-weight: 600;
50
109
  }
@@ -26,50 +26,3 @@
26
26
  --toastify-color-success: #7eb872;
27
27
  --toastify-color-warning: #f1c40f;
28
28
  }
29
-
30
- @font-face {
31
- font-family: Avenir;
32
- src: url('../assets/fonts/avenir/Avenir.ttc');
33
- }
34
-
35
- @font-face {
36
- font-family: Poppins;
37
- src: url('../assets/fonts/poppins/Poppins-SemiBold.otf');
38
- }
39
- @font-face {
40
- font-family: Poppins;
41
- src: url('../assets/fonts/poppins/Poppins-Medium.otf');
42
- }
43
- @font-face {
44
- font-family: Poppins;
45
- src: url('../assets/fonts/poppins/Poppins-Light.otf');
46
- }
47
- @font-face {
48
- font-family: Poppins;
49
- src: url('../assets/fonts/poppins/Poppins-Regular.otf');
50
- }
51
-
52
- .Toastify__toast {
53
- border-radius: 10px;
54
- padding: 0;
55
- }
56
-
57
- .Toastify__toast-body {
58
- font-family: Poppins;
59
- font-size: 16px;
60
- line-height: 1.5;
61
- color: #fff;
62
- font-weight: 600;
63
- padding: 0;
64
- margin: 0;
65
- height: 64px;
66
- align-items: stretch;
67
- }
68
- .Toastify__toast-body > div:last-child {
69
- align-self: center;
70
- margin-left: 30px;
71
- }
72
-
73
- .Toastify__toast > button > svg {
74
- display: none;
75
- }
@@ -135,7 +135,7 @@ const muiTheme = createTheme({
135
135
  root: {
136
136
  color: '#121212',
137
137
  fontSize: '14px',
138
- fontWeight: 600,
138
+ fontWeight: 500,
139
139
  fontFamily: PRIMARY_FONT,
140
140
  },
141
141
  h1: {
@@ -167,12 +167,12 @@ const muiTheme = createTheme({
167
167
  },
168
168
  subtitle1: {
169
169
  fontSize: '14px',
170
- fontWeight: 600,
170
+ fontWeight: 500,
171
171
  color: '#121212b3',
172
172
  },
173
173
  subtitle2: {
174
174
  fontSize: '13px',
175
- fontWeight: 600,
175
+ fontWeight: 500,
176
176
  color: '#959595',
177
177
  },
178
178
  },
@@ -1,4 +1,5 @@
1
1
  import Cookies from 'js-cookie'
2
+ import { useConfirm } from '../components'
2
3
  import axios, { axiosErrorToast } from '../config/axios'
3
4
  import { isDevelopment } from '../constants'
4
5
 
Binary file