@campxdev/shared 0.5.14 → 0.5.16

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.14",
3
+ "version": "0.5.16",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -6,7 +6,7 @@ import {NetworkStore} from '../components/ErrorBoundary/GlobalNetworkLoadingIndi
6
6
  import {isDevelopment} from '../constants'
7
7
 
8
8
  const sessionKey = Cookies.get('campx_session_key')
9
- const clientId = window.location.pathname.split('/')[0] ?? 'campx_dev'
9
+ const clientId = window.location.pathname.split('/')[1] ?? 'campx_dev'
10
10
 
11
11
  const formatParams = (params) => {
12
12
  return Object.fromEntries(
@@ -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