@campxdev/shared 2.0.1 → 2.0.3

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": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -1,6 +1,4 @@
1
1
  import { Alert, Box, Button, styled, Typography } from '@mui/material'
2
- import Cookies from 'js-cookie'
3
- import { useState } from 'react'
4
2
  import { useNavigate } from 'react-router-dom'
5
3
  import {
6
4
  internalserver,
@@ -9,9 +7,7 @@ import {
9
7
  permissiondenied,
10
8
  unauth,
11
9
  } from '../../assets/images'
12
- import axios from '../../config/axios'
13
10
  import { openRootModal } from '../../contexts/RootModal'
14
- import { PermissionsStore } from '../../shared-state'
15
11
 
16
12
  const StyledAlert = styled(Alert)(({ theme }) => ({
17
13
  height: '60px',
@@ -149,47 +145,14 @@ export function InternalServer({ resetBoundary, error }) {
149
145
  }
150
146
  export function UnAuth({ resetBoundary }) {
151
147
  const navigate = useNavigate()
152
- const [username, setUsername] = useState('')
153
- const [loading, setLoading] = useState(false)
154
- const url = window.location.origin
155
- const origin = window?.location?.origin?.split('.')
156
- const isDevelopment =
157
- process.env.NODE_ENV === 'development' ||
158
- origin?.slice(-2).join('.') === 'campx.dev'
159
- console.log(isDevelopment, 'hii')
160
- const isSetup = window.location.hostname.split('.').includes('setup')
161
- const sessionCookie = Cookies.get('campx_session_key')
162
- const appinit = async () => {
163
- setLoading(true)
164
- await axios
165
- .get('/auth/my-permissions')
166
- .then((res) => {
167
- setUsername(res.data.user.fullName)
168
- PermissionsStore.update((s) => {
169
- s.permissions = {
170
- ...res.data?.permissions,
171
- can_settings_view: 1,
172
- can_dashboard_view: 1,
173
- can_individual_pages_view: 1,
174
- } as any
175
- })
176
- setLoading(false)
177
- })
178
- .catch((e) => {
179
- openRootModal({
180
- key: 'login',
181
- })
182
- })
183
- }
148
+
149
+ const isDevelopment = process.env.NODE_ENV === 'development'
150
+
184
151
  function handleLoginClick() {
185
152
  if (isDevelopment) {
186
- if (!sessionCookie) {
187
- openRootModal({
188
- key: 'login',
189
- })
190
- } else {
191
- appinit()
192
- }
153
+ openRootModal({
154
+ key: 'login',
155
+ })
193
156
  } else {
194
157
  navigate('/auth/login')
195
158
  }
@@ -5,9 +5,10 @@ import { NetworkStore } from '../components/ErrorBoundary/GlobalNetworkLoadingIn
5
5
 
6
6
  const isDevelopment = process.env.NODE_ENV == 'development'
7
7
 
8
- const tenantCode = isDevelopment
9
- ? Cookies.get('campx_tenant')
10
- : window.location.hostname.split('.')[0]
8
+ const tenantCode =
9
+ isDevelopment || window.location.hostname === 'localhost'
10
+ ? Cookies.get('campx_tenant')
11
+ : window.location.hostname.split('.')[0]
11
12
  const institutionCode = window.location.pathname.split('/')[1]
12
13
 
13
14
  export const formatParams = (params) => {