-
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 branch 'main' of https://github.com/prgrms-web-devcourse/Team-G…
…aerval-Dadok-FE into refactor/#603
- Loading branch information
Showing
10 changed files
with
127 additions
and
65 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
This file was deleted.
Oops, something went wrong.
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,38 @@ | ||
'use client'; | ||
|
||
import Button from '@/v1/base/Button'; | ||
import Image from 'next/image'; | ||
import { useRouter } from 'next/navigation'; | ||
|
||
export const ErrorPage = () => { | ||
const router = useRouter(); | ||
|
||
return ( | ||
<html> | ||
<body> | ||
<div className="absolute left-0 top-0 flex h-full w-full flex-col items-center justify-center gap-[2rem]"> | ||
<Image | ||
src="/images/loading.gif" | ||
width={230} | ||
height={160} | ||
alt="loading" | ||
/> | ||
<div className="font-heading"> | ||
<span className="font-bold text-main-900">다독이</span>도 몰라요~ 왜 | ||
이래요~ | ||
</div> | ||
<Button | ||
size="large" | ||
colorScheme="main" | ||
fill={false} | ||
onClick={() => router.replace('/')} | ||
> | ||
처음으로 돌아가기 | ||
</Button> | ||
</div> | ||
</body> | ||
</html> | ||
); | ||
}; | ||
|
||
export default ErrorPage; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use client'; | ||
|
||
import { useEffect } from 'react'; | ||
import { QueryErrorResetBoundary } from '@tanstack/react-query'; | ||
import { ErrorBoundary, FallbackProps } from 'react-error-boundary'; | ||
|
||
import useToast from '@/v1/base/Toast/useToast'; | ||
import { isAuthFailedError, isAxiosErrorWithCustomCode } from '@/utils/helpers'; | ||
import Loading from '@/v1/base/Loading'; | ||
|
||
const AuthFailedErrorBoundary = ({ | ||
children, | ||
}: { | ||
children?: React.ReactNode; | ||
}) => { | ||
return ( | ||
<QueryErrorResetBoundary> | ||
{({ reset }) => ( | ||
<ErrorBoundary onReset={reset} FallbackComponent={AuthFailedFallback}> | ||
{children} | ||
</ErrorBoundary> | ||
)} | ||
</QueryErrorResetBoundary> | ||
); | ||
}; | ||
|
||
export default AuthFailedErrorBoundary; | ||
|
||
const AuthFailedFallback = ({ error, resetErrorBoundary }: FallbackProps) => { | ||
const { show: showToast } = useToast(); | ||
|
||
useEffect(() => { | ||
if ( | ||
isAxiosErrorWithCustomCode(error) && | ||
isAuthFailedError(error.response.data.code) | ||
) { | ||
showToast({ message: '다시 로그인 해주세요' }); | ||
resetErrorBoundary(); | ||
} | ||
}, [error, resetErrorBoundary, showToast]); | ||
|
||
return <Loading fullpage />; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* accessToken을 갱신하는 요청이 진행 중인 경우, 갱신 요청은 무시되고 해당 에러가 발생합니다. | ||
*/ | ||
class AuthRefreshIgnoredError extends Error { | ||
constructor(message: string) { | ||
super(message); | ||
this.name = this.constructor.name; | ||
} | ||
} | ||
|
||
export default AuthRefreshIgnoredError; |
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 @@ | ||
export { default as AuthRefreshIgnoredError } from './AuthRefreshIgnoredError'; |