@campxdev/shared 1.1.6 → 1.2.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.
- package/package.json +1 -1
- package/src/components/ImageUpload.tsx +2 -2
- package/src/components/{JsonPreview/JsonPreview.tsx → JsonPreview.tsx} +0 -0
- package/src/components/{LabelValue/LabelValue.tsx → LabelValue.tsx} +0 -0
- package/src/components/Layout/Header/AppHeader.tsx +0 -1
- package/src/components/Layout/Header/UserBox.tsx +5 -5
- package/src/components/Layout/Header/applications.ts +1 -0
- package/src/components/LoginForm.tsx +2 -3
- package/src/components/{NoDataIllustration/NoDataIllustration.tsx → NoDataIllustration.tsx} +1 -1
- package/src/components/{Row/Row.tsx → Row.tsx} +0 -0
- package/src/components/{SearchBar/SearchBar.tsx → SearchBar.tsx} +28 -21
- package/src/components/{SwitchButton/SwitchButton.tsx → SwitchButton.tsx} +0 -0
- package/src/components/{UploadDocument/UploadDocument.tsx → UploadDocument.tsx} +1 -1
- package/src/config/axios.ts +1 -2
- package/src/config/axiosXTenant.ts +1 -1
- package/src/constants/isDevelopment.ts +2 -2
- package/src/contexts/Providers.tsx +25 -8
- package/src/utils/logout.ts +2 -2
- package/src/components/JsonPreview/index.tsx +0 -1
- package/src/components/LabelValue/index.tsx +0 -1
- package/src/components/NoDataIllustration/index.tsx +0 -1
- package/src/components/Router.tsx +0 -7
- package/src/components/Row/index.tsx +0 -1
- package/src/components/SearchBar/index.tsx +0 -1
- package/src/components/SwitchButton/index.tsx +0 -1
- package/src/components/UploadDocument/index.tsx +0 -1
- package/src/hooks/useAppInit.ts +0 -33
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { InsertPhotoOutlined } from '@mui/icons-material'
|
|
|
2
2
|
import { Box, CircularProgress, styled, Typography } from '@mui/material'
|
|
3
3
|
import { ReactNode, useRef, useState } from 'react'
|
|
4
4
|
import { toast } from 'react-toastify'
|
|
5
|
-
import axios from '../config/axios'
|
|
5
|
+
import axios, { axiosErrorToast } from '../config/axios'
|
|
6
6
|
|
|
7
7
|
interface ImageUploadProps {
|
|
8
8
|
onFileUploaded: (v) => void
|
|
@@ -40,7 +40,7 @@ export default function ImageUpload({
|
|
|
40
40
|
.catch((err) => {
|
|
41
41
|
setLoading(false)
|
|
42
42
|
loadingState && setLoading(false)
|
|
43
|
-
|
|
43
|
+
axiosErrorToast(err)
|
|
44
44
|
})
|
|
45
45
|
}
|
|
46
46
|
}
|
|
File without changes
|
|
File without changes
|
|
@@ -56,11 +56,11 @@ export default function UserBox({
|
|
|
56
56
|
}
|
|
57
57
|
menu={[
|
|
58
58
|
...actions,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
{
|
|
60
|
+
label: 'My Tickets',
|
|
61
|
+
icon: <ConfirmationNumberOutlinedIcon />,
|
|
62
|
+
onClick: handleTicketOpen,
|
|
63
|
+
},
|
|
64
64
|
|
|
65
65
|
{
|
|
66
66
|
label: 'Change Password',
|
|
@@ -14,8 +14,6 @@ import { useState } from 'react'
|
|
|
14
14
|
import { useForm } from 'react-hook-form'
|
|
15
15
|
import { FormTextField } from './HookForm'
|
|
16
16
|
|
|
17
|
-
const developmentOrigin = window.location.origin + '/campx_dev'
|
|
18
|
-
|
|
19
17
|
export const StyledTextField = styled(FormTextField)(({ theme }) => ({
|
|
20
18
|
'& .MuiInputBase-root': {
|
|
21
19
|
minHeight: '60px',
|
|
@@ -45,8 +43,9 @@ export function LoginForm({ loginUrl }: { loginUrl?: string }) {
|
|
|
45
43
|
: 'https://api.campx.dev/auth-server/auth/login',
|
|
46
44
|
data: values,
|
|
47
45
|
})
|
|
46
|
+
Cookies.set('campx_tenant', res?.data?.subDomain)
|
|
48
47
|
Cookies.set('campx_session_key', res.data?.token)
|
|
49
|
-
window.location.
|
|
48
|
+
window.location.reload()
|
|
50
49
|
} catch (err) {
|
|
51
50
|
// eslint-disable-next-line no-console
|
|
52
51
|
console.log(err)
|
|
File without changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Search, Tune } from '@mui/icons-material'
|
|
2
2
|
import { Box, InputAdornment, styled, TextField } from '@mui/material'
|
|
3
|
-
import { useState } from 'react'
|
|
3
|
+
import { useMemo, useState } from 'react'
|
|
4
|
+
import _ from 'lodash'
|
|
4
5
|
|
|
5
6
|
interface SearchBarProps {
|
|
6
7
|
onSearch: (v: string) => void
|
|
@@ -9,18 +10,38 @@ interface SearchBarProps {
|
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
|
|
13
|
+
const StyledButtonWrapper = styled(Box)(({ theme }) => ({
|
|
14
|
+
width: '52px',
|
|
15
|
+
border: theme.borders.grayLight,
|
|
16
|
+
display: 'flex',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
borderRadius: '10px',
|
|
20
|
+
cursor: 'pointer',
|
|
21
|
+
'&:active': {
|
|
22
|
+
border: `1px solid ${theme.palette.primary.main}`,
|
|
23
|
+
},
|
|
24
|
+
transition: 'border 0.1s ease-in-out',
|
|
25
|
+
}))
|
|
26
|
+
|
|
12
27
|
export default function SearchBar({ onSearch, filters }: SearchBarProps) {
|
|
13
|
-
const [
|
|
28
|
+
const [, setSearch] = useState('')
|
|
29
|
+
|
|
30
|
+
const debouncedChangeHandler = useMemo(
|
|
31
|
+
() =>
|
|
32
|
+
_.debounce((e) => {
|
|
33
|
+
setSearch(e.target.value)
|
|
34
|
+
setSearch(e.target.value)
|
|
35
|
+
}, 300),
|
|
36
|
+
[],
|
|
37
|
+
)
|
|
38
|
+
|
|
14
39
|
return (
|
|
15
40
|
<Box sx={{ display: 'flex', gap: '20px' }}>
|
|
16
41
|
<TextField
|
|
17
42
|
sx={{ maxWidth: '600px' }}
|
|
18
43
|
label="Search"
|
|
19
|
-
|
|
20
|
-
onChange={(e) => {
|
|
21
|
-
setSearch(e.target.value)
|
|
22
|
-
onSearch(e.target.value)
|
|
23
|
-
}}
|
|
44
|
+
onChange={debouncedChangeHandler}
|
|
24
45
|
InputProps={{
|
|
25
46
|
endAdornment: (
|
|
26
47
|
<InputAdornment position="end">
|
|
@@ -37,17 +58,3 @@ export default function SearchBar({ onSearch, filters }: SearchBarProps) {
|
|
|
37
58
|
</Box>
|
|
38
59
|
)
|
|
39
60
|
}
|
|
40
|
-
|
|
41
|
-
const StyledButtonWrapper = styled(Box)(({ theme }) => ({
|
|
42
|
-
width: '52px',
|
|
43
|
-
border: theme.borders.grayLight,
|
|
44
|
-
display: 'flex',
|
|
45
|
-
alignItems: 'center',
|
|
46
|
-
justifyContent: 'center',
|
|
47
|
-
borderRadius: '10px',
|
|
48
|
-
cursor: 'pointer',
|
|
49
|
-
'&:active': {
|
|
50
|
-
border: `1px solid ${theme.palette.primary.main}`,
|
|
51
|
-
},
|
|
52
|
-
transition: 'border 0.1s ease-in-out',
|
|
53
|
-
}))
|
|
File without changes
|
|
@@ -2,7 +2,7 @@ import { Box, CircularProgress, Stack, styled, Typography } from '@mui/material'
|
|
|
2
2
|
import { ReactNode, useRef, useState } from 'react'
|
|
3
3
|
import AttachFileIcon from '@mui/icons-material/AttachFile'
|
|
4
4
|
import { toast } from 'react-toastify'
|
|
5
|
-
import axios from '
|
|
5
|
+
import axios from '../config/axios'
|
|
6
6
|
|
|
7
7
|
export default function UploadDocument({
|
|
8
8
|
accept = '.doc,.docx,.pdf',
|
package/src/config/axios.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { toast } from 'react-toastify'
|
|
|
4
4
|
import Cookies from 'js-cookie'
|
|
5
5
|
import { NetworkStore } from '../components/ErrorBoundary/GlobalNetworkLoadingIndicator'
|
|
6
6
|
import { isDevelopment } from '../constants'
|
|
7
|
-
import { campxTenantKey } from '../contexts/Providers'
|
|
8
7
|
|
|
9
8
|
const sessionKey = Cookies.get('campx_session_key')
|
|
10
9
|
const clientId = window.location.pathname.split('/')[1] ?? 'campx_dev'
|
|
@@ -22,7 +21,7 @@ let axios = Axios.create({
|
|
|
22
21
|
baseURL: process.env.REACT_APP_API_HOST,
|
|
23
22
|
withCredentials: true,
|
|
24
23
|
headers: {
|
|
25
|
-
'x-tenant-id':
|
|
24
|
+
'x-tenant-id': clientId,
|
|
26
25
|
...(isDevelopment &&
|
|
27
26
|
sessionKey && {
|
|
28
27
|
campx_session_key: sessionKey,
|
|
@@ -12,7 +12,7 @@ const axiosTenant = Axios.create({
|
|
|
12
12
|
baseURL: process.env.REACT_APP_API_HOST,
|
|
13
13
|
withCredentials: true,
|
|
14
14
|
headers: {
|
|
15
|
-
'x-tenant-id':
|
|
15
|
+
'x-tenant-id': clientId,
|
|
16
16
|
...(isDevelopment &&
|
|
17
17
|
sessionKey && {
|
|
18
18
|
campx_session_key: sessionKey,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
const urlTenantKey = window.location.pathname.split('/')[1]
|
|
1
2
|
export const isDevelopment =
|
|
2
|
-
process.env.NODE_ENV === 'development' ||
|
|
3
|
-
window.location.origin.split('.').slice(-2).join('.') === 'campx.dev'
|
|
3
|
+
process.env.NODE_ENV === 'development' || urlTenantKey === 'campx_dev'
|
|
@@ -1,22 +1,39 @@
|
|
|
1
|
-
import MuiThemeProvider from '../theme/MuiThemeProvider'
|
|
2
|
-
import ConfirmContextProvider from '../components/PopupConfirm/ConfirmContextProvider'
|
|
3
1
|
import { CssBaseline } from '@mui/material'
|
|
4
2
|
import { BrowserRouter } from 'react-router-dom'
|
|
3
|
+
import ConfirmContextProvider from '../components/PopupConfirm/ConfirmContextProvider'
|
|
4
|
+
import MuiThemeProvider from '../theme/MuiThemeProvider'
|
|
5
5
|
import QueryClientProvider from './QueryClientProvider'
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import Cookies from 'js-cookie'
|
|
8
|
+
import { ReactNode, useEffect, useState } from 'react'
|
|
8
9
|
import { ToastContainer } from '../components'
|
|
9
|
-
import
|
|
10
|
-
import { ReactNode } from 'react'
|
|
10
|
+
import DialogProvider from '../components/DrawerWrapper/DrawerWrapper'
|
|
11
11
|
import { isDevelopment } from '../constants'
|
|
12
|
-
import
|
|
13
|
-
import Cookies from 'js-cookie'
|
|
12
|
+
import LoginFormProvider from './LoginFormProvider'
|
|
14
13
|
|
|
15
14
|
export const campxTenantKey = Cookies.get('campx_tenant')
|
|
16
15
|
export const urlTenantKey = window.location.pathname.split('/')[1]
|
|
17
16
|
|
|
18
17
|
export default function Providers({ children }: { children: ReactNode }) {
|
|
19
|
-
const
|
|
18
|
+
const [isInvalid, setIsInvalid] = useState(false)
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (campxTenantKey === 'campx_dev') {
|
|
22
|
+
window.location.href = window.location.origin + '/campx_dev'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!isDevelopment) {
|
|
26
|
+
if (!urlTenantKey && campxTenantKey) {
|
|
27
|
+
return window.location.replace(
|
|
28
|
+
window.location.origin + `/${campxTenantKey}`,
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!urlTenantKey) {
|
|
33
|
+
setIsInvalid(true)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}, [])
|
|
20
37
|
|
|
21
38
|
return (
|
|
22
39
|
<BrowserRouter basename={isDevelopment ? 'campx_dev' : urlTenantKey}>
|
package/src/utils/logout.ts
CHANGED
|
@@ -11,8 +11,8 @@ export default function logout() {
|
|
|
11
11
|
|
|
12
12
|
axios({
|
|
13
13
|
method: 'POST',
|
|
14
|
-
baseURL: 'https://
|
|
15
|
-
url: '/auth/logout',
|
|
14
|
+
baseURL: 'https://api.campx.in',
|
|
15
|
+
url: '/auth-server/auth/logout',
|
|
16
16
|
})
|
|
17
17
|
.then((res) => {
|
|
18
18
|
Cookies.remove('campx_tenant')
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './JsonPreview'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './LabelValue'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './NoDataIllustration'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Row'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as SearchBar } from './SearchBar'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './SwitchButton'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './UploadDocument'
|
package/src/hooks/useAppInit.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import Cookies from 'js-cookie'
|
|
2
|
-
import { useEffect, useRef, useState } from 'react'
|
|
3
|
-
import { isDevelopment } from '../constants'
|
|
4
|
-
import { campxTenantKey } from '../contexts/Providers'
|
|
5
|
-
|
|
6
|
-
const urlTenantKey = window.location.pathname.split('/')[1]
|
|
7
|
-
|
|
8
|
-
export default function useAppInit() {
|
|
9
|
-
const [isInvalid, setIsInvalid] = useState(false)
|
|
10
|
-
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
if (!isDevelopment) {
|
|
13
|
-
if (!urlTenantKey && campxTenantKey) {
|
|
14
|
-
return window.location.replace(
|
|
15
|
-
window.location.origin + `/${campxTenantKey}`,
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (!urlTenantKey) {
|
|
20
|
-
setIsInvalid(true)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (window.location.pathname === '/' && isDevelopment) {
|
|
25
|
-
Cookies.set('campx_tenant', 'campx_dev')
|
|
26
|
-
window.location.href = window.location.origin + '/campx_dev'
|
|
27
|
-
}
|
|
28
|
-
}, [])
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
isInvalid,
|
|
32
|
-
}
|
|
33
|
-
}
|