Skip to content

Commit

Permalink
Merge pull request #161 from codestates-seb/dev-client#123/refactor2
Browse files Browse the repository at this point in the history
[FE] 김병현 코드 리팩토링Dev client#123/refactor2
  • Loading branch information
novice1993 authored Sep 28, 2023
2 parents 33bc58b + 420023f commit 8ecb1f2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
17 changes: 17 additions & 0 deletions client/src/components/Headers/Index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { RootState } from '../../store/config';
import LoginHeader from './LoginHeader';
import LogoutHeader from './LogoutHeader';

const Header: React.FC = () => {
const isLogin = useSelector((state: RootState) => state.login);

if (isLogin === 1) {
return <LoginHeader onProfileClick={() => { /* Handle profile click logic here */ }} />;
}

return <LogoutHeader onLoginClick={() => { /* Handle login click logic here */ }} />;
}

export default Header;
7 changes: 2 additions & 5 deletions client/src/page/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { useState, useEffect, useCallback } from "react";
import { useSelector, useDispatch } from "react-redux";
import styled from "styled-components";

import LogoutHeader from "../components/Headers/LogoutHeader";
import LoginHeader from "../components/Headers/LoginHeader";
import Header from "../components/Headers/Index";

import OAuthLoginModal from "../components/Logins/OAuthLogin";
import EmailLoginModal from "../components/Logins/EmailLogin";
Expand All @@ -25,7 +24,6 @@ import StockOrderSection from "../components/StockOrderSection/Index";
import ProfileModal from "../components/Profile/ProfileModal";
import { StateProps } from "../models/stateProps";
import { TabContainerPage } from "./TabPages/TabContainerPage";
import { RootState } from "../store/config";

import { setLoginState } from "../reducer/member/loginSlice";
import setAutoLogoutAlarm from "../utils/setAutoLogoutAlarm";
Expand All @@ -42,7 +40,6 @@ const MainPage = () => {
const [isProfileModalOpen, setProfileModalOpen] = useState(false); //프로필 모달 보이기/숨기기

const dispatch = useDispatch();
const isLogin = useSelector((state: RootState) => state.login);

const openOAuthModal = useCallback(() => {
setOAuthModalOpen(true);
Expand Down Expand Up @@ -202,7 +199,7 @@ const MainPage = () => {

return (
<Container>
{isLogin == 1 ? <LoginHeader onProfileClick={openProfileModal} /> : <LogoutHeader onLoginClick={openOAuthModal} />}
<Header/>
<Main>
<LeftSection leftExpand={expandScreen.left}>
{selectedMenu === "전체종목" ? (
Expand Down

0 comments on commit 8ecb1f2

Please sign in to comment.