@campxdev/shared 1.8.12 → 1.8.13

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.12",
3
+ "version": "1.8.13",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -1,5 +1,8 @@
1
- import { ReactNode } from 'react'
2
- import { ErrorBoundary as ReactErrorBoundary } from 'react-error-boundary'
1
+ import { ReactElement, ReactNode } from 'react'
2
+ import {
3
+ ErrorBoundary as ReactErrorBoundary,
4
+ FallbackProps,
5
+ } from 'react-error-boundary'
3
6
  import { QueryErrorResetBoundary } from 'react-query'
4
7
  import { useLocation } from 'react-router-dom'
5
8
  import ErrorFallback from './ErrorFallback'
@@ -7,9 +10,11 @@ import ErrorFallback from './ErrorFallback'
7
10
  export default function ErrorBoundary({
8
11
  children,
9
12
  resetKey,
13
+ customFallback,
10
14
  }: {
11
15
  children: ReactNode
12
16
  resetKey?: string
17
+ customFallback?: (props: FallbackProps) => JSX.Element
13
18
  }) {
14
19
  const location = useLocation()
15
20
  return (
@@ -17,7 +22,7 @@ export default function ErrorBoundary({
17
22
  {({ reset }) => (
18
23
  <ReactErrorBoundary
19
24
  key={resetKey ?? location?.pathname}
20
- fallbackRender={ErrorFallback}
25
+ fallbackRender={customFallback ?? ErrorFallback}
21
26
  onReset={reset}
22
27
  >
23
28
  {children}
@@ -14,6 +14,7 @@ import { PermissionsStore } from '../../shared-state'
14
14
  import axios from '../../config/axios'
15
15
 
16
16
  const StyledAlert = styled(Alert)(({ theme }) => ({
17
+ height: '60px',
17
18
  border: `1px solid ${theme.palette.error.main}`,
18
19
  display: 'flex',
19
20
  alignItems: 'center',
@@ -66,7 +67,7 @@ export default function ErrorFallback({ error, resetErrorBoundary }) {
66
67
  }
67
68
 
68
69
  return (
69
- <Box sx={{ marginTop: '16px', padding: '16px' }}>
70
+ <Box sx={{ marginTop: '16px', padding: '20px' }}>
70
71
  <StyledAlert severity="error">
71
72
  {error?.response?.data?.message ?? error?.message}
72
73
  <Button
@@ -139,7 +140,11 @@ export function InternalServer({ resetBoundary, error }) {
139
140
  Internal Server Error.
140
141
  </Typography>
141
142
  <Typography variant="body1">
142
- {error?.response?.data?.message}
143
+ {error?.response?.data?.message
144
+ ? typeof error?.response?.data?.message === 'string'
145
+ ? error?.response?.data?.message
146
+ : JSON.stringify(error?.response?.data?.message)
147
+ : 'Internal Server Error'}
143
148
  </Typography>
144
149
  <Button
145
150
  size="small"