Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/bsideproject/14_3_FE
Browse files Browse the repository at this point in the history
  • Loading branch information
wpdbsx committed Sep 22, 2023
2 parents 5e4163b + 71bd540 commit 0d72ade
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 54 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ zustand
* @TODO backend-connection
*/
```
TODO: 제외 가능
34 changes: 5 additions & 29 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Intro />
// <div className="App">
// <h1>Links</h1>
// <Link to="/login">Login</Link>
// <br />
// <Link to="/register">Register</Link>
// <br />
// <Link to="/mypage">mypage</Link>
// <br />
// <Link to="/mypage-category">mypage-category</Link>
// <br />
// <Link to="/password-check">password-check</Link>
// <br />
// <Link to="/lost-info">lostinfo</Link>
// <br />
// <Link to="/withdrawal">회원탈퇴</Link>
// <br />
// <Link to="/main">메인화면(UI완료)</Link>
// <br />
// <Link to="/onepager">원페이저(미완료)</Link>
// <br />
// <Link to="/answered-list">메인화면-답변한목록</Link>
// <br />
// <Link to="/intro">인트로</Link>
// <br />
// <Link to="/loading">로딩</Link>
// <br />
// </div>
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ root.render(
<Route path="/intro" element={<Intro />} />
<Route path="/loading" element={<Loading />} />
<Route path="/new-question" element={<AddNewQuiestion />} />
<Route path="/*" element={<NotFound />} />
<Route path="*" element={<NotFound />} />
<Route path="/new-question-list" element={<ShowNewQuestions />}></Route>
</Routes>
</BrowserRouter>
Expand Down
25 changes: 8 additions & 17 deletions src/pages/auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 으로 이동
}
Expand Down Expand Up @@ -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 (
<>
<div>
Expand Down
6 changes: 3 additions & 3 deletions src/pages/etc/Intro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},[])

Expand Down
3 changes: 3 additions & 0 deletions src/pages/main/MainContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const MainContent = () => {

useEffect(() => {
console.log(fourCards, oneCard)
console.log(todayCardSelectStep);
updateTodayCardSelectStatus(true)

setHeaderText('')
setIsNavigation(true)

Expand Down
23 changes: 20 additions & 3 deletions src/pages/mypage/MyPageCategoryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>(false)

const SESSION_LOGIN = sessionStorage.getItem('GomingIsLoginS')

useEffect(()=> {
setHeaderText()
setHeaderBgColor(true)
setIsNavigation(true)

return (()=> setHeaderBgColor(false))
},[])

Expand All @@ -41,6 +45,7 @@ const MyPageCategoryList = () => {

//로그아웃 프로세스
const handleLogout = () => {
sessionStorage.removeItem("GomingIsLoginS") //세션스토리지 삭제
logout() //로그아웃
navigate('/login', {replace: true}) //로그인으로 이동
}
Expand All @@ -54,12 +59,24 @@ const MyPageCategoryList = () => {
{/* welcome */}
<div>
<h3 className="headline3">반가워요!</h3>
<h3 className="headline3" style={{color: '#6E8DBA'}}>카페인중독자님</h3>
<h3 className="headline3">
<span style={{color: '#6E8DBA'}}>
{userInfo.usrNm ? userInfo.usrNm : '커피중독자'}
</span>
<span>
</span>
</h3>
</div>

{/* logout btn */}
<div className="logout-area">
<button className="caption1-bold btn-p-xs logout-btn" type="button" onClick={()=> setLogoutCheck(true)}>로그아웃</button>
{
SESSION_LOGIN
? (<button className="caption1-bold btn-p-xs logout-btn" type="button" onClick={()=> setLogoutCheck(true)}>로그아웃</button>)
: (<button className="caption1-bold btn-p-xs logout-btn" type="button" onClick={()=> navigate('/login')}>로그인</button>)
}

</div>
</div>
</div>
Expand Down

0 comments on commit 0d72ade

Please sign in to comment.