-
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: 노드 환경에서 실행되지 않도록 코드 추가 * feat: 타입가드 추가 * feat: 권한별 페이지 접근 처리 * feat: test 계정의 토큰을 받는 api 추가 * feat: 테스트 계정의 토큰을 받은 후 회원가입 페이지로 리다이렉트 처리 * feat: 회원가입 유무를 판단하여 리다이렉트 시키는 코드 추가
- Loading branch information
Showing
8 changed files
with
151 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"use client"; | ||
|
||
import { getTestUserAPI, getUserInfoAPI } from "lib/apis/user"; | ||
import Path from "lib/Path"; | ||
import { queryKeys } from "lib/queryKeys"; | ||
import userStorage from "lib/utils/userStorage"; | ||
import { useRouter } from "next/navigation"; | ||
import { useEffect } from "react"; | ||
|
||
// const getQuery = [queryKeys.LOGIN_INFO]; | ||
|
||
function TestPage() { | ||
const router = useRouter(); | ||
|
||
// const { userInfo } = useGetUserInfo(); | ||
// if (!userInfo) return null; | ||
// const { gender, yearOfBirth, mbti } = userInfo!; | ||
// const isRegister = gender && yearOfBirth && mbti; | ||
|
||
// const { data: loginInfo } = useQuery(getQuery, getTestUserAPI); | ||
|
||
useEffect(() => { | ||
const testUserLogin = async () => { | ||
try { | ||
const { accessToken } = await getTestUserAPI(); | ||
userStorage.set({ accessToken }); | ||
const userInfo = await getUserInfoAPI(); | ||
if (userInfo.gender && userInfo.yearOfBirth && userInfo.mbti) { | ||
router.push(Path.MAIN_PAGE); | ||
} else router.push(Path.REGISTER_PAGE); | ||
} catch (error) { | ||
alert("에러가 발생하였습니다."); | ||
} | ||
}; | ||
testUserLogin(); | ||
// if (loginInfo?.accessToken) { | ||
// userStorage.set({ accessToken: loginInfo.accessToken }); | ||
// if (isRegister) router.push(Path.MAIN_PAGE); | ||
// else { | ||
// router.replace(Path.REGISTER_PAGE); | ||
// } | ||
// } | ||
}, []); | ||
|
||
return <>잠시만 기다려주십시오.</>; | ||
} | ||
|
||
export default TestPage; |
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