@campxdev/shared 0.3.3 → 0.3.4

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": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -1,12 +1,25 @@
1
+ import {ReactNode} from 'react'
1
2
  import {ErrorBoundary as ReactErrorBoundary} from 'react-error-boundary'
2
3
  import {QueryErrorResetBoundary} from 'react-query'
4
+ import {useLocation} from 'react-router-dom'
3
5
  import ErrorFallback from './ErrorFallback'
4
6
 
5
- export default function ErrorBoundary({children}) {
7
+ export default function ErrorBoundary({
8
+ children,
9
+ resetKey,
10
+ }: {
11
+ children: ReactNode
12
+ resetKey?: string
13
+ }) {
14
+ const location = useLocation()
6
15
  return (
7
16
  <QueryErrorResetBoundary>
8
17
  {({reset}) => (
9
- <ReactErrorBoundary fallbackRender={ErrorFallback} onReset={reset}>
18
+ <ReactErrorBoundary
19
+ key={resetKey ?? location?.pathname}
20
+ fallbackRender={ErrorFallback}
21
+ onReset={reset}
22
+ >
10
23
  {children}
11
24
  </ReactErrorBoundary>
12
25
  )}
@@ -23,7 +23,7 @@ export default function ErrorFallback({error, resetErrorBoundary}) {
23
23
  return (
24
24
  <Box sx={{marginTop: '16px', padding: '16px'}}>
25
25
  <StyledAlert severity='error'>
26
- {error?.message}
26
+ {error?.response?.data?.message ?? error?.message}
27
27
  <Button
28
28
  className='retryBtn'
29
29
  onClick={() => resetErrorBoundary()}
@@ -1,14 +1,17 @@
1
- import styled from 'styled-components'
1
+ import {Box, styled} from '@mui/material'
2
+ import ErrorBoundary from './ErrorBoundary'
2
3
 
3
- const StyledPageContent = styled.div`
4
- padding-left: 25px;
5
- padding-right: 25px;
6
- margin-top: 16px;
7
- padding-bottom: 3rem;
8
- `
4
+ const StyledPageContent = styled(Box)(() => ({
5
+ paddingLeft: '25px',
6
+ paddingRight: '25px',
7
+ marginTop: '16px',
8
+ paddingBottom: '3rem',
9
+ }))
9
10
 
10
11
  export function PageContent(props) {
11
- return (
12
- <StyledPageContent style={props.style}>{props.children}</StyledPageContent>
13
- )
12
+ return (
13
+ <StyledPageContent style={props.style}>
14
+ <ErrorBoundary>{props.children}</ErrorBoundary>
15
+ </StyledPageContent>
16
+ )
14
17
  }