Skip to content

Commit

Permalink
Merge branch 'develop' into FEAT-#111]-Feign통신
Browse files Browse the repository at this point in the history
  • Loading branch information
Hwater00 authored Dec 28, 2023
2 parents 4fbed9e + f2cd2d5 commit 1e8545b
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 75 deletions.
10 changes: 7 additions & 3 deletions front-service/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ import styled, { createGlobalStyle } from "styled-components"
import {BrowserRouter as Router} from 'react-router-dom';
import Main from "./components/Main";
import UserRouteController from "./components/user/userRoute/UserRouteController";
import Sidebar from "./components/sidebar/sidebar";
import BiddingList from "./components/bidding/biddingList/BiddingList";

const GlobalStyle = createGlobalStyle`
body{
background: #e9ecef;
display: flex;
justify-content: flex-end;
all: unset;
display: flex;
width: 100vw;
justify-content: center;
flex-direction: column;
}
`
const App = () => (
<Router>
<Sidebar />
<GlobalStyle/>
<Main/>
</Router>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import CreateBoard from "../createBoard/CreateBoard"
import BoardDetail from "../boardDetail/BoardDetail"
import Authentication from "../../user/authentication";
import BiddingList from "../../bidding/biddingList/BiddingList"
import Sidebar from "../../sidebar/sidebar";

const BoardRouteController = () => {
return(

<>
{/*<Routes>*/}
{/* <Route path="/" element={<Sidebar path={"/"} menuName={"Main"}/>}/>*/}
{/*</Routes>*/}
<Routes>
<Route path="/" element={<BoardBody/>}>
<Route path='/boards' element={<BoardMain />} />
Expand Down
106 changes: 42 additions & 64 deletions front-service/src/components/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,75 +1,53 @@
import { Link, useLocation } from "react-router-dom";
import styled from "styled-components";
import Accordion from 'react-bootstrap/Accordion';
import React from "react";
import {useNavigate} from "react-router-dom";
import {Button, ButtonGroup} from "react-bootstrap";
import './sidebarStyle.css';

interface Props {
// children: JSX.Element;
menuName: string;
path: string;
}
interface ContainerProps {
focus: boolean;
}
const Sidebar = () => {

// const ContentContainer = styled.div`
// width: 100%;
// height: 100%;
// `;
const navigator = useNavigate();

const Container = styled.div<ContainerProps>`
width: 100%;
height: 100vh;
display: flex;
font-size: 1.5rem;
&:hover {
cursor: pointer;
}
const handleHomeClick = () => {
navigator('/');
};

const handleAuthenticationClick = () => {
navigator('/auth');
};

a {
text-decoration: none;
color: ${({ theme }) => theme.textColor};
}
`;
const handleCreateBoardClick = () => {
navigator('/boards/write');
};

const NavBar = styled.div`
width: 300px;
height: 100%;
background-color: #d9d9d9;
`;
const handleBoardDetailClick = () => {
navigator(`/boards/firstBoardUUID`);
};

const Menu = styled.div`
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
li {
width: 100%;
height: 50px;
}
`;

const menuList = [
{ menuName: "Main", path: "/" },
{ menuName: "로그인", path: "/auth" },
{ menuName: "게시물", path: "/boards" },
];

const Sidebar = ({ path }: Props) => {
const { pathname } = useLocation();
const focus = pathname === path ? true : false;
return (
<Container focus={focus}>
<NavBar>
<Menu>
{menuList.map((menu) => (
<li key={menu.menuName}>
<Link to={menu.path}>{menu.menuName}</Link>
</li>
))}
</Menu>
</NavBar>
{/*<ContentContainer>{children}</ContentContainer>*/}
</Container>
<Accordion className='flex-accordion'>
<Accordion.Item eventKey="0">
<Accordion.Header>메뉴 바</Accordion.Header>

<Accordion.Body>
<ButtonGroup vertical>
<Button variant="primary" size="sm" onClick={handleHomeClick} className="mb-2">
홈으로 이동
</Button>
<Button variant="primary" size="sm" onClick={handleCreateBoardClick} className="mb-2">
게시판 작성 페이지로 이동
</Button>
<Button variant="primary" size="sm" onClick={handleBoardDetailClick} className="mb-2">
게시판 상세 페이지로 이동
</Button>
<Button variant="primary" size="sm" onClick={handleAuthenticationClick} className="mb-2">
인증 페이지로 이동
</Button>
</ButtonGroup>
</Accordion.Body>
</Accordion.Item>

</Accordion>
);
};

Expand Down
12 changes: 12 additions & 0 deletions front-service/src/components/sidebar/sidebarStyle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.flex-accordion {
display: flex;
flex-direction: column;
}

.flex-accordion .accordion-item {
flex: 1;
}

.flex-accordion .accordion-body {
flex: 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default interface MembernameRequestDto {
memberName: string;
}
138 changes: 138 additions & 0 deletions front-service/src/components/user/loginedUser/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import './style.css'
import {useNavigate, useParams} from "react-router-dom";
import React, {ChangeEvent, useEffect, useRef, useState} from "react";
import {useCookies} from "react-cookie";
import useUserStore from "../store/user.store";
import MembernameRequestDto from "../dto/request/memberNameRequestDto";



// component: 유저 페이지 //
export default function User() {

// state: 조회하는 유저 이메일 path variable 상태 //
const { searchEmail } = useParams();
// state: 로그인 유저 정보 상태 //
const { user, setUser } = useUserStore();
// state: 본인 여부 상태 //
const [isMyPage, setMyPage] = useState<boolean>(false);

// function: 네비게이트 함수 //
const navigator = useNavigate();

// component: 유저 정보 컴포넌트 //
const UserInfo = () => {

// state: 프로필 이미지 input ref 상태 //
const fileInputRef = useRef<HTMLInputElement | null>(null);
// state: cookie 상태 //
const [cookies, setCookie] = useCookies();
// state: 이메일 상태 //
const [email, setEmail] = useState<string>('');
// state: 프로필 이미지 상태 //
const [profileImage, setProfileImage] = useState<string | null>('');
// state: 기존 닉네임 상태 //
const [existingmemberName, setExistingmemberName] = useState<string>('');
// state: 닉네임 상태 //
const [memberName, setMemberName] = useState<string>('');
// state: 닉네임 변경 상태 //
const [showChangememberName, setShowChangememberName] = useState<boolean>(false);


// event handler: 프로필 이미지 클릭 이벤트 처리 //
const onProfileImageClickHandler = () => {
if (!isMyPage) return;
if (!fileInputRef.current) return;
fileInputRef.current.click();
};
// event handler: 닉네임 변경 버튼 클릭 이벤트 처리 //
const onChangememberNameButtonClickHandler = () => {
if (!showChangememberName) {
setShowChangememberName(true);
return;
}

const isEqual = memberName === existingmemberName;
if (isEqual) {
setShowChangememberName(false);
return;
}

const accessToken = cookies.accessToken;
if (!accessToken) return;

const requestBody: MembernameRequestDto = { memberName };

//// fetch
}

// event handler: 프로필 이미지 변경 이벤트 처리 //
const onProfileImageChangeHandler = (event: ChangeEvent<HTMLInputElement>) => {
if (!event.target.files || !event.target.files.length) return;

const file = event.target.files[0];
const data = new FormData();
data.append('file', file);

/// fetch
};

// event handler: 닉네임 변경 이벤트 처리 //
const onmemberNameChangeHandler = (event: ChangeEvent<HTMLInputElement>) => {
const memberName = event.target.value;
setMemberName(memberName);
};

// effect: 조회하는 유저의 이메일이 변경될 때 마다 실행할 함수 //
useEffect(() => {
if (!searchEmail) {
navigator('/');
return;
}
/// fetch
}, [searchEmail]);

// render: 유저 정보 컴포넌트 렌더링 //
return (
<div id='user-info-wrapper'>
<div className='user-info-container'>
<div className={isMyPage ? 'user-info-profile-image-box-mypage' : 'user-info-profile-image-box'} onClick={onProfileImageClickHandler}>
<input ref={fileInputRef} type='file' accept='image/*' style={{ display: 'none' }} onChange={onProfileImageChangeHandler} />
{profileImage === null ? (
<div className='user-info-profile-default-image'>
<div className='user-info-profile-icon-box'>
<div className='image-box-white-icon'></div>
</div>
</div>
) : (
<div className='user-info-profile-image' style={{ backgroundImage: `url(${profileImage})` }}></div>
)}
</div>
<div className='user-info-meta-box'>
<div className='user-info-memberName-box'>
{showChangememberName ? (
<input className='user-info-memberName-input' type='text' size={memberName.length + 1} value={memberName} onChange={onmemberNameChangeHandler} />
) : (
<div className='user-info-memberName'>{memberName}</div>
)}
{isMyPage && (
<div className='icon-button' onClick={onChangememberNameButtonClickHandler}>
<div className='edit-light-icon'></div>
</div>
)}
</div>
<div className='user-info-email'>{email}</div>
</div>
</div>
</div>
);

};

// render: 유저 페이지 렌더링 //
return (
<>
<UserInfo />
</>
)
}
1 change: 1 addition & 0 deletions front-service/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import App from "./App";
import 'bootstrap/dist/css/bootstrap.min.css';



const rootElement = document.getElementById('root');
if (!rootElement) throw new Error('Failed to find the root element');
const root = ReactDOM.createRoot(rootElement);
Expand Down
8 changes: 3 additions & 5 deletions gateway-service/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1e8545b

Please sign in to comment.