@campxdev/shared 1.8.48 → 1.8.49

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.8.48",
3
+ "version": "1.8.49",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -7,7 +7,7 @@ import {
7
7
  Typography,
8
8
  styled,
9
9
  } from '@mui/material'
10
- import { useState } from 'react'
10
+ import { useEffect, useState } from 'react'
11
11
  import { useMutation, useQuery } from 'react-query'
12
12
  import { toast } from 'react-toastify'
13
13
  import { useImmer } from 'use-immer'
@@ -218,6 +218,12 @@ export const RenderProfileDropDown = ({
218
218
  profileId: data.profiles[0].id,
219
219
  })
220
220
 
221
+ useEffect(() => {
222
+ setState((pre) => ({
223
+ userId: data.id,
224
+ profileId: data.profiles[0].id,
225
+ }))
226
+ }, [data])
221
227
  const { mutate, isLoading } = useMutation(updateUserApplicationProfile, {
222
228
  onSuccess: (res) => {
223
229
  refetchFn()
@@ -2,6 +2,7 @@ import { Box } from '@mui/material'
2
2
  import UserBox from './UserBox'
3
3
  import CogWheelMenu from './CogWheelMenu'
4
4
  import FreshDeskHelpButton from './FreshDeskHelpButton'
5
+ import SchoolSwitch from '../SchoolSwitch/SchoolSwitch'
5
6
 
6
7
  export default function HeaderActions({
7
8
  cogWheelMenu,
@@ -10,6 +11,7 @@ export default function HeaderActions({
10
11
  }) {
11
12
  return (
12
13
  <>
14
+ {/* <SchoolSwitch /> */}
13
15
  <FreshDeskHelpButton />
14
16
  {cogWheelMenu?.length ? <CogWheelMenu menu={cogWheelMenu} /> : null}
15
17
  <UserBox fullName={fullName} actions={userBoxActions} />
@@ -0,0 +1,33 @@
1
+ import { useState } from 'react'
2
+ import { FormSingleSelect } from '../../../HookForm'
3
+ import { SingleSelect } from '../../../Input'
4
+
5
+ export default function SchoolSwitch() {
6
+ const [state, setStatr] = useState()
7
+
8
+ return (
9
+ <SingleSelect
10
+ containerProps={{
11
+ sx: {
12
+ width: '200px',
13
+ },
14
+ }}
15
+ options={[
16
+ {
17
+ label: 'School 1',
18
+ value: 'school1',
19
+ },
20
+ {
21
+ label: 'School 2',
22
+ value: 'school2',
23
+ },
24
+ {
25
+ label: 'School 3',
26
+ value: 'school3',
27
+ },
28
+ ]}
29
+ value={state}
30
+ onChange={(e) => setStatr(e.target.value)}
31
+ />
32
+ )
33
+ }
@@ -1,9 +1,10 @@
1
- import Axios from 'axios'
1
+ import Axios, { AxiosRequestConfig } from 'axios'
2
2
  import _ from 'lodash'
3
3
  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 { UserStore } from '../shared-state'
7
8
 
8
9
  const sessionKey = Cookies.get('campx_session_key')
9
10
  const clientId = window.location.pathname.split('/')[1] ?? 'campx_dev'
@@ -30,7 +31,12 @@ let axios = Axios.create({
30
31
  })
31
32
 
32
33
  axios.interceptors.request.use(
33
- function (config) {
34
+ function (config: AxiosRequestConfig) {
35
+ const userState = UserStore.getRawState()
36
+ if (userState?.username) {
37
+ config.headers.test = userState.username
38
+ }
39
+
34
40
  const params = formatParams(config?.params)
35
41
  NetworkStore.update((s) => {
36
42
  s.loading = true
@@ -593,7 +593,7 @@ export enum Permission {
593
593
  //Hostels
594
594
 
595
595
  // manage hostels profile_permissions
596
- CAN_MANAGE_HOSTELS_PROFILE_PERMISSIONS_VIEW = 'manage_hostels_profile_permissions_view',
596
+ CAN_MANAGE_HOSTELS_PROFILE_PERMISSIONS_VIEW = 'can_manage_hostels_profile_permissions_view',
597
597
  CAN_MANAGE_HOSTELS_PROFILE_PERMISSIONS_ADD = 'can_manage_hostels_profile_permissions_add',
598
598
  CAN_MANAGE_HOSTELS_PROFILE_PERMISSIONS_EDIT = 'can_manage_hostels_profile_permissions_edit',
599
599
  CAN_MANAGE_HOSTELS_PROFILE_PERMISSIONS_DELETE = 'can_manage_hostels_profile_permissions_delete',