Skip to content

Commit

Permalink
Fix: Chat-320-root-url-라우팅-login으로-조정-취소 (#91)
Browse files Browse the repository at this point in the history
* Feat: 로그인 전에 페이지 경로로 접근 못하게 막음

* Fix: bottomNav 홈화면 경로 수정

* Fix: 홈, 로그인 경로 변경
  • Loading branch information
somin-jeong authored Feb 20, 2024
1 parent eb774cc commit c1cd796
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/common/BottomNav/BottomNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const BottomNav = ({ page, isBtn = true }: IProps) => {
''
)}
<nav className={styles.bottomNav}>
<Link to="/home" className={styles.navLink}>
<Link to="/" className={styles.navLink}>
{page === 0 ? (
<>
<NavHomeActive />
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Header/ChatHeader/ChatHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const ChatHeader = ({ onClick }: IProps) => {
const character = getAi();
return (
<div className={styles.container}>
<Link className={styles.link} to="/home">
<Link className={styles.link} to="/">
<LeftChevron />
</Link>
<Link className={styles.link} to="/chat/profile">
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Login/Kakao/KakaoLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ const KakaoLogin = () => {
setUserInfo(data);
}, [data]);
} else {
navigate('/');
navigate('/login');
throw new Error('code is invalid');
}

useEffect(() => {
if (userInfo) {
localStorage.setItem('userId', userInfo.userId?.toString());
localStorage.setItem('nickname', userInfo.nickname);
navigate('/home');
navigate('/');
}
}, [userInfo]);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/MyPage/Account/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Account = () => {
onClickCancel={onClickClose}
onClickConfirm={() => {
onClickClose;
navigate('/');
navigate('/login');
}}
isOpen={isModalOpen}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/MyPage/Account/AccountQuitFinish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const AccountQuitFinish = () => {
<div className={styles.header}>챗다이어리 탈퇴 완료</div>
<div className={styles.sub}>다음에 다시 만나요!</div>
<div className={styles.img}>{aiImgs[ai!.id]}</div>
<ConfirmButton isAble={true} id={0} onClick={() => navigate('/')}>
<ConfirmButton isAble={true} id={0} onClick={() => navigate('/login')}>
홈으로 가기
</ConfirmButton>
</>
Expand Down
6 changes: 3 additions & 3 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Router = () => {
children: [
{
index: true,
element: <Login />,
element: <Home />,
},
{
path: 'login',
Expand All @@ -46,11 +46,11 @@ const Router = () => {
],
},
{
path: 'home',
path: 'login',
children: [
{
index: true,
element: <Home />,
element: <Login />,
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion src/stores/pageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface IPath {
}

const initialPath = {
prevPath: '/home',
prevPath: '/',
isHomeTypeList: false,
isTagTypeList: true,
};
Expand Down
2 changes: 1 addition & 1 deletion src/utils/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export const getUserId = () => {
export const isLogin = () => {
const navigate = useNavigate();
if (!localStorage.getItem('userId')) {
navigate('/');
navigate('/login');
}
};

0 comments on commit c1cd796

Please sign in to comment.