generated from nim-od/softeer-mono-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from softeerbootcamp4th/TASK-42
[Feature][Task-42] 8.21일 QA 수정
- Loading branch information
Showing
11 changed files
with
112 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/admin/src/components/error/CommonErrorBoundary.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { ACCESS_TOKEN_KEY } from '@softeer/common/constants'; | ||
import { Cookie } from '@softeer/common/utils'; | ||
import { PropsWithChildren, useEffect } from 'react'; | ||
import { ErrorBoundary } from 'react-error-boundary'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { Button } from '../ui/button.tsx'; | ||
|
||
export function CommonErrorFallback({ | ||
error, | ||
resetErrorBoundary, | ||
}: { | ||
error: Error, | ||
resetErrorBoundary: () => void | ||
}) { | ||
const navigate = useNavigate(); | ||
useEffect(() => { | ||
switch (error.message) { | ||
case '관리자 로그인을 먼저 진행해주세요': | ||
case '로그인이 만료 되었습니다': | ||
Cookie.clearCookie(ACCESS_TOKEN_KEY); | ||
navigate('/'); | ||
break; | ||
default: | ||
} | ||
}, []); | ||
|
||
return ( | ||
<div className="min-w-screen min-h-screen flex justify-center items-center flex-col gap-4 bg-skyblue-500 "> | ||
<Button onClick={resetErrorBoundary}>다시 시도하기</Button>{error.message} | ||
</div> | ||
); | ||
} | ||
|
||
function CommonErrorBoundary({ children }: PropsWithChildren) { | ||
return ( | ||
<ErrorBoundary | ||
FallbackComponent={CommonErrorFallback} | ||
onReset={() => { window.location.reload(); }} | ||
> | ||
{children} | ||
</ErrorBoundary> | ||
); | ||
} | ||
export default CommonErrorBoundary; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters