diff --git a/src/App.tsx b/src/App.tsx index ca7ae41..ecafa29 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,46 +6,22 @@ import useAuthStore from "store/modules/Auth"; function App() { - const { isLogin } = useAuthStore((state) => state); const navigate = useNavigate(); + + //로그인 정보를 세션에서 값을 가져와 판단 + // const { isLogin } = useAuthStore((state) => state); + const isLogin = sessionStorage.getItem('GomingIsLoginS') === 'true' ? true : false; useEffect(() => { //islogin을 확인한다. //로그인이 되어있으면 메인화면으로 이동 //로그인이 안되어있으면 로그인화면으로 이동 if (isLogin) { - navigate('/main') //임시주석 + navigate('/main') } }, []); return ( - //
- //

Links

- // Login - //
- // Register - //
- // mypage - //
- // mypage-category - //
- // password-check - //
- // lostinfo - //
- // 회원탈퇴 - //
- // 메인화면(UI완료) - //
- // 원페이저(미완료) - //
- // 메인화면-답변한목록 - //
- // 인트로 - //
- // 로딩 - //
- //
) } diff --git a/src/index.tsx b/src/index.tsx index 5114a98..18f6286 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -46,7 +46,7 @@ root.render( } /> } /> } /> - } /> + } /> }> diff --git a/src/pages/auth/Login.tsx b/src/pages/auth/Login.tsx index b6b0cac..63cd4b1 100644 --- a/src/pages/auth/Login.tsx +++ b/src/pages/auth/Login.tsx @@ -91,8 +91,14 @@ const Login: React.FC = () => { alert(result.data); // 알림컴포넌트창 출력 return; } else { - console.log(result); - const userInfoData: TYPE_USER_INFO = result?.data && result?.data; + console.log('로그인완료'); + + // const userInfoData: TYPE_USER_INFO = result?.data && result?.data; + const userInfoData: any = result?.data && result?.data; + if (userInfoData) { + sessionStorage.setItem('GomingIsLoginS', 'true') //GomingIsLoginS 라는 key 로 세션에 저장 + } + updateLoginStatus(true, userInfoData); // 1.auth store 에 저장 navigate("/main"); // 2. main 으로 이동 } @@ -129,21 +135,6 @@ const Login: React.FC = () => { const handleRememberEmail = ({ target }: any) => { setRememberEmail(!rememberEmail); }; - const industries = { - industry: { - 카페: 1, - 음식점: 2, - 학원: 10, - 미용실: 12, - 학교: 5, - 병원: 22, - 약국: 17, - 편의점: 1, - 안경점: 2, - }, - total: 77, - }; - console.log(industries); return ( <>
diff --git a/src/pages/etc/Intro.tsx b/src/pages/etc/Intro.tsx index f7d90d1..fa3f464 100644 --- a/src/pages/etc/Intro.tsx +++ b/src/pages/etc/Intro.tsx @@ -17,10 +17,10 @@ const Intro = () => { const {setIsNavigation} = useDefaultSets((state)=>state) const {isLogin} = useAuthStore() const navigate = useNavigate() - - useEffect(()=>{ + const SESSION_LOGIN = sessionStorage.getItem('GomingIsLoginS') + useEffect(()=>{ setIsNavigation(false) - isLogin && navigate('/main') + SESSION_LOGIN && navigate('/main') return () => setIsNavigation(true) },[]) diff --git a/src/pages/main/MainContent.tsx b/src/pages/main/MainContent.tsx index 8be4424..3eca9c2 100644 --- a/src/pages/main/MainContent.tsx +++ b/src/pages/main/MainContent.tsx @@ -32,6 +32,9 @@ const MainContent = () => { useEffect(() => { console.log(fourCards, oneCard) + console.log(todayCardSelectStep); + updateTodayCardSelectStatus(true) + setHeaderText('') setIsNavigation(true) diff --git a/src/pages/mypage/MyPageCategoryList.tsx b/src/pages/mypage/MyPageCategoryList.tsx index 4b696b6..2a0f5f7 100644 --- a/src/pages/mypage/MyPageCategoryList.tsx +++ b/src/pages/mypage/MyPageCategoryList.tsx @@ -23,12 +23,16 @@ const categoryList = [ //카테고리목록 const MyPageCategoryList = () => { //헤더설정 const {setHeaderText, setHeaderBgColor,setIsNavigation} = useDefaultSets() - const {updateLoginStatus, logout} = useAuthStore((state)=>state) + const {userInfo, updateLoginStatus, logout} = useAuthStore((state)=>state) const [logoutCheck, setLogoutCheck] = useState(false) + + const SESSION_LOGIN = sessionStorage.getItem('GomingIsLoginS') + useEffect(()=> { setHeaderText() setHeaderBgColor(true) setIsNavigation(true) + return (()=> setHeaderBgColor(false)) },[]) @@ -41,6 +45,7 @@ const MyPageCategoryList = () => { //로그아웃 프로세스 const handleLogout = () => { + sessionStorage.removeItem("GomingIsLoginS") //세션스토리지 삭제 logout() //로그아웃 navigate('/login', {replace: true}) //로그인으로 이동 } @@ -54,12 +59,24 @@ const MyPageCategoryList = () => { {/* welcome */}

반가워요!

-

카페인중독자님

+

+ + {userInfo.usrNm ? userInfo.usrNm : '커피중독자'} + + + 님 + +

{/* logout btn */}
- + { + SESSION_LOGIN + ? () + : () + } +