@campxdev/shared 1.11.7-0.alpha.33 → 1.11.7-0.alpha.36

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.11.7-0.alpha.33",
3
+ "version": "1.11.7-0.alpha.36",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -1,4 +1,5 @@
1
1
  import { AxiosError } from 'axios'
2
+ import Cookies from 'js-cookie'
2
3
  import { useEffect, useState } from 'react'
3
4
  import { toast } from 'react-toastify'
4
5
  import axios from '../config/axios'
@@ -40,7 +41,7 @@ const ApplicationObj = {
40
41
  people: 'hrms',
41
42
  commute: 'commute_x',
42
43
  }
43
- const checkIsAdmin = (user) => {
44
+ export const checkIsAdmin = (user) => {
44
45
  let subDomain = window.location.host.split('.')?.slice(-3)[0]
45
46
  const localSubDomain = process.env.REACT_APP_SUBDOMAIN
46
47
 
@@ -192,23 +193,14 @@ function useAuth({ permissionsEndpoint, loginUrl }: AuthParams): AuthResponse {
192
193
  window.location.hostname.split('.').includes('setup') && isAdmin
193
194
  const isMasterSlave = res.data?.institutionType === 'MASTER_CHILD'
194
195
 
195
- // eslint-disable-next-line no-console
196
-
197
- if (isDevelopment == false && isStaging == false && !isSetup) {
198
- if (
199
- !res.data.applications.includes(ApplicationObj[originSubdomain])
200
- ) {
201
- window.location.replace(
202
- `https://www.id.campx.in/apps?redirect_to=${url}`,
203
- )
204
- }
205
- }
206
-
207
- if (res.data?.institutions) {
208
- handleInstitutions(res.data?.institutions)
209
- }
210
-
211
196
  setData(res.data)
197
+
198
+ InstitutionsStore.update((s) => {
199
+ s.institutions = res.data?.institutions
200
+ s.current = res.data?.institutions.find(
201
+ (item) => item.code === Cookies.get('campx_institution'),
202
+ )
203
+ })
212
204
  UserStore.update((s) => {
213
205
  s.username = res.data?.user?.username
214
206
  s.user = res.data?.user
@@ -1,4 +1,11 @@
1
1
  import { AssetsStore } from './AssetsStore'
2
+ import { InstitutionsStore } from './InstitutionsStore'
3
+ import { Permission, PermissionsStore } from './PermissionsStore'
2
4
  import { UserStore } from './UserStore'
3
- import { PermissionsStore, Permission } from './PermissionsStore'
4
- export { AssetsStore, UserStore, Permission, PermissionsStore }
5
+ export {
6
+ AssetsStore,
7
+ InstitutionsStore,
8
+ Permission,
9
+ PermissionsStore,
10
+ UserStore,
11
+ }