From 35e1564dbc9660f1cf60a2851242875977d1b3cc Mon Sep 17 00:00:00 2001 From: HyunJungJo98 Date: Thu, 24 Mar 2022 23:27:22 +0900 Subject: [PATCH] =?UTF-8?q?[#57]Refactor:=EC=B5=9C=EC=A0=81=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EventPage/EventMovieThumbnail.js | 9 +- .../src/components/EventPage/EventPage.js | 97 +++++-------------- .../src/components/EventPage/Events.js | 16 --- .../InformationShares/InformationSharePage.js | 12 +-- .../InformationShares/InformationShares.js | 7 +- .../src/components/MainContent/MainContent.js | 5 +- .../src/components/TopBar/LogIn.js | 5 - .../TransactionPage/TransactionDetail.js | 3 - .../TransactionPage/TransactionPage.js | 68 ++++--------- 9 files changed, 58 insertions(+), 164 deletions(-) diff --git a/frontend/sweet-red-beans/src/components/EventPage/EventMovieThumbnail.js b/frontend/sweet-red-beans/src/components/EventPage/EventMovieThumbnail.js index b2c8e1c..450897f 100644 --- a/frontend/sweet-red-beans/src/components/EventPage/EventMovieThumbnail.js +++ b/frontend/sweet-red-beans/src/components/EventPage/EventMovieThumbnail.js @@ -46,8 +46,7 @@ const EventMovieThumbnail = ({ event }) => { + className={style.thumbnailArea}>
{event.title}
@@ -58,13 +57,11 @@ const EventMovieThumbnail = ({ event }) => { {status ? ( + className={style.likeOnButton}> ) : ( + className={style.likeOffButton}> )}
diff --git a/frontend/sweet-red-beans/src/components/EventPage/EventPage.js b/frontend/sweet-red-beans/src/components/EventPage/EventPage.js index 28a0595..7d4f259 100644 --- a/frontend/sweet-red-beans/src/components/EventPage/EventPage.js +++ b/frontend/sweet-red-beans/src/components/EventPage/EventPage.js @@ -1,21 +1,9 @@ import React, { useCallback, useEffect, useState, useMemo } from 'react'; -import { Routes, Route } from 'react-router'; -import { Link } from 'react-router-dom'; -import EventDetailPage from './EventDetailPage'; -import { useNavigate } from 'react-router'; import Events from './Events'; -import { useDispatch, useSelector, shallowEqual } from 'react-redux'; -import events from '../../actions/event_action'; -import { EVENT_ISEND, EVENT_SORT, EVENTS } from '../../actions/types'; -import axios from 'axios'; import style from '../../css/EventPage/EventPage.module.css'; const EventPage = () => { - let navigation = useNavigate(); - const dispatch = useDispatch(); - const [events, setEvents] = useState([]); - const [eventIsHere, setEventIsHere] = useState(false); //검색 단어, 처음에 없음 const [search, setSearch] = useState(''); //검색했던 단어들 저장 @@ -35,46 +23,31 @@ const EventPage = () => { setSearch(e.target.value); }; - //검색 버튼 눌렀을 때 다시 서버 요청 + //검색 버튼 눌렀을 때 const searchClick = () => { setSearchWords([...searchWords, search]); setSelecteds([...selecteds, selected]); }; - //진행 중 클릭했을 때 다시 서버 요청 + //진행 중 클릭했을 때 const ongoingClick = () => { + console.log('진행중'); setIsEnd(false); - dispatch({ - type: EVENT_ISEND, - payload: false, - }); }; - //진행 완료 클릭했을 때 다시 서버 요청 + //진행 완료 클릭했을 때 const doneClick = () => { setIsEnd(true); - dispatch({ - type: EVENT_ISEND, - payload: true, - }); }; - //최신순 클릭했을 때 다시 서버 요청 + //최신순 클릭했을 때 const recentClick = () => { setSort('최신순'); - dispatch({ - type: EVENT_SORT, - payload: '최신순', - }); }; - //관심도순 클릭했을 때 다시 서버 요청 + //관심도순 클릭했을 때 const interestClick = () => { setSort('관심도순'); - dispatch({ - type: EVENT_SORT, - payload: '관심도순', - }); }; //영화관 필터 바뀌었을 때 @@ -82,27 +55,6 @@ const EventPage = () => { setSelected(e.target.value); }; - useEffect(() => { - // //처음에 기본으로 진행 중인 이벤트로 보여줌 - // dispatch({ - // type:EVENT_ISEND, - // payload:false, - // }) - // //처음에 기본으로 최신순으로 보여줌 - // dispatch({ - // type:EVENT_SORT, - // payload:sort, - // }) - }, []); - - useEffect(() => { - // dispatch({ - // type:EVENTS, - // events:events, - // }); - setEventIsHere(true); - }, [events]); - return ( <>
@@ -112,16 +64,14 @@ const EventPage = () => { onClick={ongoingClick} className={ isEnd ? style.notSelected : style.selected - } - > + }> 진행 중
@@ -132,8 +82,7 @@ const EventPage = () => { sort === '최신순' ? style.selected : style.notSelected - } - > + }> 최신순 @@ -163,24 +111,25 @@ const EventPage = () => { type="text" placeholder="검색" onChange={searchChange} - value={search} - > + value={search}>
+ onClick={searchClick}> - { - - } + {useMemo( + () => ( + + ), + [sort, isEnd, searchWords, selecteds] + )} ); diff --git a/frontend/sweet-red-beans/src/components/EventPage/Events.js b/frontend/sweet-red-beans/src/components/EventPage/Events.js index de735b6..ae9fa73 100644 --- a/frontend/sweet-red-beans/src/components/EventPage/Events.js +++ b/frontend/sweet-red-beans/src/components/EventPage/Events.js @@ -16,24 +16,8 @@ const Events = ({ sort, isEnd, search_word, cinema_name }) => { const offset = (page - 1) * limit; const [events, setEvents] = useState([]); - useEffect(() => { - const body = { - withCredentials: true, - params: { - sort_criteria: sort, - is_end: isEnd, - }, - }; - - //처음에 진행 중, 최신순으로 요청 - axios - .get('http://localhost:8080/events/search', body) - .then((response) => setEvents(response.data)) - .catch((error) => console.log(error)); - }, []); useEffect(() => { - console.log('!!!!!!!!!!!!!!!!!!'); let body = {}; if (cinema_name[cinema_name.length - 1] === '전체') { body = { diff --git a/frontend/sweet-red-beans/src/components/InformationShares/InformationSharePage.js b/frontend/sweet-red-beans/src/components/InformationShares/InformationSharePage.js index 341e1d5..80b12f6 100644 --- a/frontend/sweet-red-beans/src/components/InformationShares/InformationSharePage.js +++ b/frontend/sweet-red-beans/src/components/InformationShares/InformationSharePage.js @@ -176,8 +176,7 @@ const InformationSharePage = () => {
+ value={cinemaBranch}> {cinemaBranches.map((item) => (
{ //처음에 최신순으로 요청 console.log(searchWords, sort, cinemaName, cinemaArea, cinemaBranch); @@ -35,6 +38,7 @@ const InformationShares = ({ return () => { setInfos([]); }; + console.log(pageNumber); }, []); useEffect(() => { @@ -126,8 +130,7 @@ const InformationShares = ({
+ style={{ textDecoration: 'none' }}>
{item.title}
diff --git a/frontend/sweet-red-beans/src/components/MainContent/MainContent.js b/frontend/sweet-red-beans/src/components/MainContent/MainContent.js index 1ad3285..631b9d6 100644 --- a/frontend/sweet-red-beans/src/components/MainContent/MainContent.js +++ b/frontend/sweet-red-beans/src/components/MainContent/MainContent.js @@ -8,6 +8,7 @@ import TopBar from '../TopBar/TopBar'; import InformationSharePage from '../InformationShares/InformationSharePage'; import InformationShareWritePage from '../InformationShares/InformationShareWritePage'; import InformationShareDetailPage from '../InformationShares/InformationShareDetailPage'; +import InformationShares from '../InformationShares/InformationShares'; import TransactionPage from '../TransactionPage/TransactionPage'; import DMPage from '../DMPage/DMPage'; import MyPageAdmin from '../MyPage/MyPageAdmin'; @@ -38,8 +39,8 @@ const MainContent = () => { element={} /> } + path="/informationShare/:pageNumber" + element={} /> } /> } /> diff --git a/frontend/sweet-red-beans/src/components/TopBar/LogIn.js b/frontend/sweet-red-beans/src/components/TopBar/LogIn.js index 371afac..954da80 100644 --- a/frontend/sweet-red-beans/src/components/TopBar/LogIn.js +++ b/frontend/sweet-red-beans/src/components/TopBar/LogIn.js @@ -65,11 +65,6 @@ const LogIn = () => { alert('정지된 상태입니다. 관리자에게 문의해주세요.'); setModalOpen(false); } else if (response.data.result) { - // dispatch({ - // type: LOGIN_USER, - // user: response.data, - // }) - const date = new Date(); date.setMinutes(date.getMinutes() + 30); cookies.set('login', true, { expires: date }); diff --git a/frontend/sweet-red-beans/src/components/TransactionPage/TransactionDetail.js b/frontend/sweet-red-beans/src/components/TransactionPage/TransactionDetail.js index b6597f9..b4359e9 100644 --- a/frontend/sweet-red-beans/src/components/TransactionPage/TransactionDetail.js +++ b/frontend/sweet-red-beans/src/components/TransactionPage/TransactionDetail.js @@ -245,9 +245,6 @@ const TransactionDetail = ({ transaction }) => {
{transaction.is_mine ? ( - //
- //
{status==='진행중'? "진행중" : "마감"}
- //
- + {useMemo( + () => ( + + ), + [transactions] + )}