@campxdev/shared 0.5.15 → 0.5.17

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": "0.5.15",
3
+ "version": "0.5.17",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -13,6 +13,7 @@ import useAppInit from '../hooks/useAppInit'
13
13
  import Cookies from 'js-cookie'
14
14
 
15
15
  export const campxTenantKey = Cookies.get('campx_tenant')
16
+ export const urlTenantKey = window.location.pathname.split('/')[1]
16
17
 
17
18
  export default function Providers({children}: {children: ReactNode}) {
18
19
  const {isInvalid} = useAppInit()
@@ -47,6 +48,11 @@ const InvalidClientKey = () => {
47
48
  }}
48
49
  >
49
50
  <h1>Invalid Tenant Key</h1>
51
+ {!isDevelopment && (
52
+ <a href='https://id.campx.in'>
53
+ <p>Login to continue</p>
54
+ </a>
55
+ )}
50
56
  </div>
51
57
  )
52
58
  }
@@ -1,12 +1,14 @@
1
1
  import Cookies from 'js-cookie'
2
2
  import {useEffect, useState} from 'react'
3
3
  import {isDevelopment} from '../constants'
4
- import {campxTenantKey} from '../contexts/Providers'
4
+ import {campxTenantKey, urlTenantKey} from '../contexts/Providers'
5
+
6
+ const validTenant = campxTenantKey && urlTenantKey
5
7
 
6
8
  export default function useAppInit() {
7
9
  const [isInvalid, setIsInvalid] = useState(false)
8
10
  useEffect(() => {
9
- if (!isDevelopment && !campxTenantKey) {
11
+ if (!isDevelopment && !validTenant) {
10
12
  setIsInvalid(true)
11
13
  }
12
14
 
@@ -15,7 +15,8 @@ export default function logout() {
15
15
  url: '/auth/logout',
16
16
  })
17
17
  .then((res) => {
18
- window.location.href = '/'
18
+ Cookies.remove('campx_tenant')
19
+ window.location.href = 'https://id.campx.in'
19
20
  })
20
21
  .catch((err) => {
21
22
  axiosErrorToast('Unable To Logout.')