-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: localStroage에 있는 auth가 유효하면 재접속할 수 있도록 comfirm 띄우기 (#121)
* feat: localStroage에 있는 auth가 유효하면 재접속할 수 있도록 comfirm 띄우기 * refactor: auth유효검증을 valid로 변경
- Loading branch information
1 parent
0a37e5a
commit 7acf26f
Showing
6 changed files
with
56 additions
and
9 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
Empty file.
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,24 @@ | ||
import { useEffect } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { existGame } from '../axios/http'; | ||
|
||
interface propsType { | ||
children: React.ReactNode; | ||
} | ||
|
||
export default function CheckAuth({ children }: propsType) { | ||
const navigate = useNavigate(); | ||
useEffect(() => { | ||
(async () => { | ||
const isExist = await existGame(); | ||
if (isExist) { | ||
if (confirm('이미 참가중인 방이 있습니다. 재접속 하시겠습니까?')) { | ||
navigate('/game'); | ||
} | ||
} | ||
})(); | ||
}, []); | ||
|
||
return <>{children}</>; | ||
} |
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