@campxdev/shared 1.11.30 → 1.11.31

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.30",
3
+ "version": "1.11.31",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -14,10 +14,10 @@ import {
14
14
  } from '@mui/material'
15
15
  import { ReactNode, useEffect, useRef, useState } from 'react'
16
16
  import { toast } from 'react-toastify'
17
- import axios, { axiosErrorToast } from '../../config/axios'
17
+ import axios from '../../config/axios'
18
18
  import { buffertoCSV } from '../../utils'
19
- import { DeleteButton, EditButton } from '../IconButtons'
20
19
  import { useErrorModal } from '../ErrorModalWrapper/ErrorModalWrapper'
20
+ import { DeleteButton, EditButton } from '../IconButtons'
21
21
  const animatedImage = require('./AnimatedUploadFile.gif')
22
22
 
23
23
  const StyledDialogHeader = styled(Box)(({ theme }) => ({
@@ -80,7 +80,8 @@ interface UploadFileDialogProps {
80
80
  sampleFileDownloadUrl?: string
81
81
  uploadUrl: string
82
82
  successMessage?: string
83
- refetchFn: (res: any) => void
83
+ refetchFn?: (res: any) => void
84
+ onUpload?: () => void
84
85
  postBody?: { [key: string]: string }
85
86
  }
86
87
 
@@ -95,6 +96,7 @@ export default function UploadFileDialog({
95
96
  refetchFn,
96
97
  sampleFileDownloadUrl,
97
98
  postBody = {},
99
+ onUpload,
98
100
  }: UploadFileDialogProps) {
99
101
  const inputRef: any = useRef(null)
100
102
  const [loading, setLoading] = useState(false)
@@ -115,6 +117,7 @@ export default function UploadFileDialog({
115
117
  }
116
118
 
117
119
  const handleOnUpload = () => {
120
+ onUpload && onUpload()
118
121
  if (!file) return ``
119
122
  const formData = new FormData()
120
123
  formData.append('file', file)
@@ -129,7 +132,7 @@ export default function UploadFileDialog({
129
132
  .post(uploadUrl, formData)
130
133
  .then((res) => {
131
134
  setLoading(false)
132
- refetchFn(res)
135
+ refetchFn && refetchFn(res)
133
136
  setOpen(false)
134
137
  toast.success(successMessage ?? 'Successful')
135
138
  setFile(null)
@@ -6,3 +6,14 @@ export default function getUrlParams() {
6
6
  }
7
7
  return params
8
8
  }
9
+
10
+ export const createSearchParams = (query: { [key: string]: string }) => {
11
+ const searchParams = new URLSearchParams()
12
+
13
+ for (const key in query) {
14
+ if (query[key] !== null && query[key] !== 'all') {
15
+ searchParams.append(key, encodeURIComponent(query[key]))
16
+ }
17
+ }
18
+ return query
19
+ }
@@ -1,8 +1,11 @@
1
- export { default as getUrlParams } from './getUrlParams'
1
+ import { createSearchParams } from './getUrlParams'
2
2
  export { default as arrayPadEnd } from './arrayPadEnd'
3
- export { default as romanize } from './romanize'
4
3
  export { default as buffertoCSV } from './buffertoCSV'
4
+ export { default as getUrlParams } from './getUrlParams'
5
+ export { default as romanize } from './romanize'
5
6
 
7
+ export { default as onLogout } from './logout'
6
8
  export { default as withRouteWrapper } from './withRouteWrapper'
7
9
  export { default as withSuspense } from './withSuspense'
8
- export { default as onLogout } from './logout'
10
+
11
+ export { createSearchParams }