@campxdev/shared 1.5.3 → 1.5.5

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.3",
3
+ "version": "1.5.5",
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
+ }
@@ -1,5 +1,6 @@
1
1
  import { Tune } from '@mui/icons-material'
2
2
  import { Box, styled } from '@mui/material'
3
+ import { useEffect, useState } from 'react'
3
4
 
4
5
  const StyledButtonWrapper = styled(Box)<{ size: 'regular' | 'large' }>(
5
6
  ({ theme, size }) => ({
@@ -37,14 +38,15 @@ export default function FilterButton({
37
38
  ...props
38
39
  }: {
39
40
  onClick: (e: any) => void
40
- filtersApplied?: boolean
41
41
  size?: 'regular' | 'large'
42
+ filtersApplied?: any
42
43
  }) {
43
44
  const handleClick = (e) => {
44
45
  e.stopPropagation()
45
46
  if (!onClick) return
46
47
  onClick(e)
47
48
  }
49
+
48
50
  return (
49
51
  <StyledButtonWrapper size={size} {...props} onClick={handleClick}>
50
52
  {filtersApplied && <StyledNotify />}
@@ -1,11 +1,47 @@
1
1
  import {
2
+ Box,
2
3
  Button,
3
4
  Dialog,
4
5
  DialogActions,
5
6
  DialogContent,
6
7
  DialogTitle,
8
+ styled,
9
+ Typography,
7
10
  } from '@mui/material'
8
11
  import useConfirm from './useConfirm'
12
+ const animatedImage = require('./animation.gif')
13
+ const StyledImage = styled((props: any) => (
14
+ <Box>
15
+ <img {...props} />
16
+ </Box>
17
+ ))(({ theme }) => ({
18
+ width: '154px',
19
+ height: '172px',
20
+ display: 'flex',
21
+ alignItems: 'center',
22
+ justifyContent: 'center',
23
+
24
+ '> img': {
25
+ width: '100%',
26
+ height: '100%',
27
+ objectFit: 'contain',
28
+ },
29
+ }))
30
+
31
+ const StyledDialogContent = styled(Box)(({ theme }) => ({
32
+ height: '360px',
33
+ width: '570px',
34
+ display: 'flex',
35
+ alignItems: 'center',
36
+ justifyContent: 'center',
37
+ flexDirection: 'column',
38
+ }))
39
+
40
+ const StyledCancel = styled(Button)(() => ({
41
+ color: 'rgba(18, 18, 18, 0.5)',
42
+ border: '0.5px solid #12121280',
43
+ height: '40px',
44
+ }))
9
45
 
10
46
  const PopupConfirm = () => {
11
47
  const { prompt = '', isOpen = false, proceed, cancel } = useConfirm()
@@ -18,16 +54,26 @@ const PopupConfirm = () => {
18
54
  open={isOpen}
19
55
  transitionDuration={150}
20
56
  >
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>
57
+ <StyledDialogContent>
58
+ <Box sx={{ marginBottom: '20px' }}>
59
+ {' '}
60
+ <StyledImage src={animatedImage} alt="Upload Image" />
61
+ </Box>
62
+
63
+ <Typography
64
+ sx={{ fontSize: '16px', fontFamily: 'Poppins', fontWeight: '500' }}
65
+ >
66
+ {prompt}
67
+ </Typography>
68
+ <Box sx={{ display: 'flex', gap: '20px', marginTop: '30px' }}>
69
+ <StyledCancel variant="text" onClick={cancel}>
70
+ No, Cancel
71
+ </StyledCancel>
72
+ <Button variant="outlined" onClick={proceed} sx={{ height: '40px' }}>
73
+ Yes, I’m. Sure
74
+ </Button>
75
+ </Box>
76
+ </StyledDialogContent>
31
77
  </Dialog>
32
78
  )
33
79
  }
@@ -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,3 +1,4 @@
1
1
  export { default as useFetch } from './useFetch'
2
2
  export * from './useRouter'
3
3
  export { default as useAuth } from './useAuth'
4
+ export { default as useFilter } from './useFilters'
@@ -0,0 +1,80 @@
1
+ import React, { useEffect, useState } from 'react'
2
+
3
+ export default function useFilters(initialState, key?: any) {
4
+ const [filters, setFilters] = useState(initialState)
5
+ const [filtersApplied, setFiltersApplied] = useState(false)
6
+
7
+ useEffect(() => {
8
+ const prevFilters = getSessionFilters()
9
+ setFilters({
10
+ ...filters,
11
+ ...prevFilters,
12
+ })
13
+ }, [])
14
+
15
+ function onFilterChange(modified) {
16
+ setFilters({
17
+ ...filters,
18
+ ...modified,
19
+ })
20
+
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] }
29
+ }
30
+ })
31
+
32
+ const filteredSessionArray = sessionData.filter(
33
+ (value) => value !== undefined,
34
+ )
35
+
36
+ if (filteredSessionArray?.length > 0) {
37
+ sessionStorage.setItem(key, JSON.stringify(filteredSessionArray))
38
+ setFiltersApplied(true)
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
51
+ }
52
+ }
53
+
54
+ function clearFilters() {
55
+ setFilters(initialState)
56
+ setFiltersApplied(false)
57
+ sessionStorage.removeItem(key)
58
+ }
59
+
60
+ const getSessionFilters = () => {
61
+ try {
62
+ if (sessionStorage.getItem(key)) {
63
+ setFiltersApplied(true)
64
+ const parsed = JSON.parse(sessionStorage.getItem(key))
65
+ const filters = parsed?.reduce(
66
+ (acc, curr) => ({ ...acc, [curr.key]: curr.value }),
67
+ {},
68
+ )
69
+ return filters
70
+ }
71
+ } catch (error) {}
72
+ }
73
+
74
+ return {
75
+ filters,
76
+ onFilterChange,
77
+ clearFilters,
78
+ filtersApplied,
79
+ }
80
+ }
@@ -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