@campxdev/shared 1.10.93 → 1.10.95

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.10.93",
3
+ "version": "1.10.95",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
File without changes
@@ -1,11 +1,11 @@
1
1
  import { Box, TextField, Typography, styled } from '@mui/material'
2
2
  import { useState } from 'react'
3
- import { InsititutionsStore } from '../../shared-state/InstitutionsStore'
3
+ import { InstitutionsStore } from '../../shared-state/InstitutionsStore'
4
4
  import Image from '../Image/Image'
5
5
 
6
- export default function InsititutionsDialog({ close }) {
6
+ export default function InstitutionsDialog({ close }) {
7
7
  const [searchText, setSearchText] = useState('')
8
- const { institutions } = InsititutionsStore.useState((s) => s)
8
+ const { institutions } = InstitutionsStore.useState((s) => s)
9
9
  const filteredInstitutions = institutions.filter((item) =>
10
10
  item.name.toLowerCase().includes(searchText.toLowerCase()),
11
11
  )
@@ -1,9 +1,9 @@
1
1
  import { urlTenantKey } from '../../contexts/Providers'
2
- import { InsititutionsStore } from '../../shared-state/InstitutionsStore'
2
+ import { InstitutionsStore } from '../../shared-state/InstitutionsStore'
3
3
  import { SearchSingleSelect } from '../Input/SearchSingleSelect'
4
4
 
5
5
  export default function SchoolSwitch() {
6
- const { current, institutions } = InsititutionsStore.useState((s) => s)
6
+ const { current, institutions } = InstitutionsStore.useState((s) => s)
7
7
 
8
8
  const handleChange = (value) => {
9
9
  if (value) {
@@ -1,7 +1,7 @@
1
1
  import { Box, Chip, Container, Typography } from '@mui/material'
2
2
  import { useQuery } from 'react-query'
3
3
  import axios from '../../config/axios'
4
- import { InsititutionsStore } from '../../shared-state/InstitutionsStore'
4
+ import { InstitutionsStore } from '../../shared-state/InstitutionsStore'
5
5
  import PageHeader from '../PageHeader'
6
6
  import Spinner from '../Spinner'
7
7
  import Education from './Education/Education'
@@ -19,7 +19,7 @@ import {
19
19
  import Workshop from './Workshop/Workshop'
20
20
 
21
21
  const MyProfile = ({ close }) => {
22
- const { institutions, current } = InsititutionsStore.useState((s) => s)
22
+ const { institutions, current } = InstitutionsStore.useState((s) => s)
23
23
 
24
24
  const { data, isLoading } = useQuery('dashboard', () =>
25
25
  axios.get('/square/users/dashboard').then((res) => res?.data),
@@ -1,6 +1,6 @@
1
- import { Box, CircularProgress, Stack, styled, Typography } from '@mui/material'
2
- import { ReactNode, useRef, useState } from 'react'
3
1
  import AttachFileIcon from '@mui/icons-material/AttachFile'
2
+ import { CircularProgress, styled, Typography } from '@mui/material'
3
+ import { ReactNode, useRef, useState } from 'react'
4
4
  import { toast } from 'react-toastify'
5
5
  import axios from '../config/axios'
6
6
 
@@ -10,7 +10,7 @@ export default function UploadDocument({
10
10
  postUrl,
11
11
  postBody,
12
12
  styleProps,
13
- refetchFn,
13
+ onSuccess,
14
14
  width,
15
15
  height,
16
16
  }: {
@@ -18,7 +18,7 @@ export default function UploadDocument({
18
18
  styledUpload?: ReactNode
19
19
  postUrl: string
20
20
  postBody?: object
21
- refetchFn?: () => void
21
+ onSuccess?: (res: any) => void
22
22
  styleProps?: any
23
23
  width?: string
24
24
  height?: string
@@ -41,7 +41,7 @@ export default function UploadDocument({
41
41
  .post(postUrl, formData)
42
42
  .then((res) => {
43
43
  setLoading(false)
44
- refetchFn()
44
+ onSuccess(res?.data)
45
45
  })
46
46
  .catch((err) => {
47
47
  setLoading(false)
@@ -3,7 +3,7 @@ import Cookies from 'js-cookie'
3
3
  import { toast } from 'react-toastify'
4
4
  import { NetworkStore } from '../components/ErrorBoundary/GlobalNetworkLoadingIndicator'
5
5
  import { isDevelopment, isSetup } from '../constants'
6
- import { InsititutionsStore } from '../shared-state/InstitutionsStore'
6
+ import { InstitutionsStore } from '../shared-state/InstitutionsStore'
7
7
 
8
8
  const sessionKey = Cookies.get('campx_session_key')
9
9
  const clientId = window.location.pathname.split('/')[1] ?? 'campx_dev'
@@ -31,7 +31,7 @@ let axios = Axios.create({
31
31
 
32
32
  axios.interceptors.request.use(
33
33
  function (config: AxiosRequestConfig) {
34
- const { current } = InsititutionsStore.getRawState()
34
+ const { current } = InstitutionsStore.getRawState()
35
35
  if (current) {
36
36
  config.headers['x-institution-code'] = current.code
37
37
  } else {
@@ -6,7 +6,7 @@ import { isDevelopment } from '../constants'
6
6
  import { urlTenantKey } from '../contexts/Providers'
7
7
  import { openRootModal } from '../contexts/RootModal'
8
8
  import { AssetsStore, PermissionsStore, UserStore } from '../shared-state'
9
- import { InsititutionsStore } from '../shared-state/InstitutionsStore'
9
+ import { InstitutionsStore } from '../shared-state/InstitutionsStore'
10
10
 
11
11
  const url = window.location.origin
12
12
 
@@ -97,7 +97,7 @@ function handleInstitutions(institutions) {
97
97
  `${window.location.origin}/${urlTenantKey}/${institutions[0]?.code}`,
98
98
  )
99
99
  }
100
- InsititutionsStore.update((s) => {
100
+ InstitutionsStore.update((s) => {
101
101
  s.current = institutions[0]
102
102
  s.institutions = institutions
103
103
  })
@@ -125,7 +125,7 @@ function handleInstitutions(institutions) {
125
125
  },
126
126
  })
127
127
  }
128
- InsititutionsStore.update((s) => {
128
+ InstitutionsStore.update((s) => {
129
129
  s.institutions = institutions
130
130
  s.current = institutions.find((item) => item.code === insititutionKey)
131
131
  })
@@ -174,7 +174,7 @@ const loginErrorHandler = ({
174
174
  function useAuth({ permissionsEndpoint, loginUrl }: AuthParams): AuthResponse {
175
175
  const [loading, setLoading] = useState<boolean>(false)
176
176
  const [data, setData] = useState(null)
177
- const { current } = InsititutionsStore.useState()
177
+ const { current } = InstitutionsStore.useState()
178
178
 
179
179
  const appInit = async () => {
180
180
  setLoading(true)
@@ -1,6 +1,6 @@
1
1
  import { Store } from 'pullstate'
2
2
 
3
- export const InsititutionsStore = new Store({
3
+ export const InstitutionsStore = new Store({
4
4
  institutions: [],
5
5
  loading: false,
6
6
  error: null,
@@ -1,5 +1,8 @@
1
1
  export default function getUrlParams() {
2
2
  const urlSearchParams = new URLSearchParams(window.location.search)
3
3
  const params = Object.fromEntries(urlSearchParams.entries())
4
+ for (const i in params) {
5
+ params[i] = decodeURIComponent(params[i])
6
+ }
4
7
  return params
5
8
  }