diff --git a/frontend/sweet-red-beans/src/components/DMPage/DMDetail.js b/frontend/sweet-red-beans/src/components/DMPage/DMDetail.js index d0540fd..825e9a0 100644 --- a/frontend/sweet-red-beans/src/components/DMPage/DMDetail.js +++ b/frontend/sweet-red-beans/src/components/DMPage/DMDetail.js @@ -1,9 +1,9 @@ import React, { - useState, - useCallback, - useEffect, - useMemo, - useRef, + useState, + useCallback, + useEffect, + useMemo, + useRef, } from 'react'; import * as StompJs from '@stomp/stompjs'; import SockJS from 'sockjs-client'; @@ -24,414 +24,357 @@ let stompClient = null; //props를 selectedRoom으로 바꾸고 roomId는 selectedRoom.chat_room_id으로 바꾸기 //transaction_id 값 바꾸기 const DMDetail = ({ selectedRoom }) => { - const navigation = useNavigate(); - - const [modalOpen, setModalOpen] = useState(false); - - const [reportContent, setReportContent] = useState(''); - //거래완료되면 true - //초기값 selectedRoom.is_complete로 설정하기 - const [complete, setComplete] = useState(selectedRoom.is_complete); - - const [imgFile, setImgFile] = useState(null); - const [imgBase64, setImgBase64] = useState(null); - - const [myNickname, setMyNickname] = useState(''); - - const openModal = () => { - setModalOpen(true); - }; - const closeModal = () => { - setModalOpen(false); - }; - - //대화 내용, 상대방 것 포함 - const [contents, setContents] = useState([]); - const [username, setUsername] = useState(''); - //내가 보낸 메시지 내용 - const [message, setMessage] = useState(''); - - let socket = new SockJS('http://localhost:8080/ws-stomp'); - let stompClient = Stomp.over(socket); - - useEffect(() => { - axios - .get('http://localhost:8080/mypage', { - withCredentials: true, - }) - .then((response) => { - setMyNickname(response.data.user.nickname); - }) - .catch((e) => console.log(e)); - }, []); - - useEffect(() => { - console.log(myNickname); - }, [myNickname]); - - //전송 버튼 눌렀을 때 - const sendClick = () => { - // if(!cookies.get("login")) { - // alert("로그인을 먼저 해주세요"); - // navigation('/') - // } - sendMessage(message); - //서버에서 받아올 때처럼 비슷한 형식으로 넣어주기 위해 - setMessage(''); - }; - - const sendMessage = (message) => { - const fd = new FormData(); - - if (imgFile === null) { - if (message !== '') { - stompClient.send( - '/pub/chat/message', - {}, - JSON.stringify({ - content: message, - chat_room_id: selectedRoom.chat_room_id, - }) - ); - } - } else { - stompClient.send( - '/pub/chat/message', - {}, - JSON.stringify({ - content: message, - chat_room_id: selectedRoom.chat_room_id, - image_url: imgBase64, - }) - ); - setImgBase64(null); - setImgFile(null); + const navigation = useNavigate(); + + const [modalOpen, setModalOpen] = useState(false); + + const [reportContent, setReportContent] = useState(''); + //거래완료되면 true + //초기값 selectedRoom.is_complete로 설정하기 + // const [complete, setComplete] = useState(selectedRoom.is_complete); + const [complete, setComplete] = useState(false); + const [imgFile, setImgFile] = useState(null); + const [imgBase64, setImgBase64] = useState(null); + + const [myNickname, setMyNickname] = useState(''); + + const openModal = () => { + setModalOpen(true); + }; + const closeModal = () => { + setModalOpen(false); + }; + + //대화 내용, 상대방 것 포함 + const [contents, setContents] = useState([]); + const [username, setUsername] = useState(''); + //내가 보낸 메시지 내용 + const [message, setMessage] = useState(''); + + let socket = new SockJS('http://localhost:8080/ws-stomp'); + let stompClient = Stomp.over(socket); + + //이제까지 메시지 내역 조회 + useEffect(() => { + console.log(selectedRoom); + setContents([]); + setMessage(''); + if (selectedRoom !== undefined) { + axios + .get('http://localhost:8080/direct-message/detail', { + withCredentials: true, + params: { + room_id: selectedRoom.chat_room_id, + }, + }) + .then((response) => { + setContents(response.data.message); + }) + .catch((error) => console.log(error)); + } + + stompClient.connect({}, () => { + stompClient.subscribe( + '/sub/chat/room/' + selectedRoom.chat_room_id, + (data) => { + console.log(JSON.parse(data.body)); + const newMessage = JSON.parse(data.body); + addMessage(newMessage); } + ); + }); + setComplete(selectedRoom.is_complete); + + return () => { + if (stompClient != null) { + stompClient.disconnect(); + setContents(null); + } }; - - useEffect(() => { - console.log(imgBase64); - }, [imgBase64]); - - useEffect(() => { - console.log(contents); - }, [contents]); - - const addMessage = (message) => { - //상대에게 받아온 메시지를 추가함 - setContents((prev) => [...prev, message]); + }, [selectedRoom]); + + //전송 버튼 눌렀을 때 + const sendClick = () => { + sendMessage(message); + setMessage(''); + }; + + const sendMessage = (message) => { + const fd = new FormData(); + + if (imgFile === null) { + if (message !== '') { + stompClient.send( + '/pub/chat/message', + {}, + JSON.stringify({ + content: message, + chat_room_id: selectedRoom.chat_room_id, + }) + ); + } + } else { + stompClient.send( + '/pub/chat/message', + {}, + JSON.stringify({ + content: message, + chat_room_id: selectedRoom.chat_room_id, + image_url: imgBase64, + }) + ); + setImgBase64(null); + setImgFile(null); + } + }; + + const addMessage = (message) => { + //상대에게 받아온 메시지를 추가함 + setContents((prev) => [...prev, message]); + }; + + const onChange = useCallback((e) => { + setMessage(e.target.value); + }, []); + + //신뢰도 +1 주는 버튼 + const reliabilityPlusClick = () => { + //신뢰도 1 주기 + if (complete === false) { + alert('거래완료를 해야 신뢰도를 줄 수 있습니다'); + } else { + const body = { + user_id: selectedRoom.not_mine_id, + }; + axios + .post('http://localhost:8080/direct-message/reliability', body, { + withCredentials: true, + }) + .then((response) => { + if (response.data.result) { + alert('상대방의 신뢰도가 올랐습니다.'); + } else { + alert('신뢰도를 올리는 데 실패했습니다.'); + } + }) + .catch((error) => console.log(error)); + } + }; + + //신고 내용 + const reportContentChange = (e) => { + setReportContent(e.target.value); + }; + + //신고 확인 버튼 눌렀을 때 + const reportConfirm = () => { + const body = { + user_id: '1', + transaction_id: selectedRoom.transaction_id, + report_content: reportContent, }; - - const onChange = useCallback((e) => { - setMessage(e.target.value); - }, []); - - //이제까지 메시지 내역 조회 - useEffect(() => { - console.log(selectedRoom); - setContents([]); - setMessage(''); - if (selectedRoom !== undefined) { - axios - .get('http://localhost:8080/direct-message/detail', { - withCredentials: true, - params: { - room_id: selectedRoom.chat_room_id, - }, - }) - .then((response) => { - //setMList(response.data.message.map(item => item.message_content)); - setContents(response.data.message); - }) - .catch((error) => console.log(error)); - } - - stompClient.connect({}, () => { - stompClient.subscribe( - '/sub/chat/room/' + selectedRoom.chat_room_id, - (data) => { - console.log(JSON.parse(data.body)); - const newMessage = JSON.parse(data.body); - addMessage(newMessage); - } - ); - }); - setComplete(selectedRoom.is_complete); - - return () => { - if (stompClient != null) { - stompClient.disconnect(); - } - }; - }, [selectedRoom]); - - //신뢰도 +1 주는 버튼 - const reliabilityPlusClick = () => { - //신뢰도 1 주기 - if (complete === false) { - alert('거래완료를 해야 신뢰도를 줄 수 있습니다'); + axios + .post('http://localhost:8080/direct-message/report', body, { + withCredentials: true, + }) + .then((response) => { + if (response.data.result) { + alert('신고되었습니다.'); + setReportContent(''); + setModalOpen(false); } else { - const body = { - user_id: selectedRoom.not_mine_id, - }; - axios - .post( - 'http://localhost:8080/direct-message/reliability', - body, - { withCredentials: true } - ) - .then((response) => { - if (response.data.result) { - alert('상대방의 신뢰도가 올랐습니다.'); - } else { - alert('신뢰도를 올리는 데 실패했습니다.'); - } - }) - .catch((error) => console.log(error)); + alert('신고에 실패했습니다.'); } + }) + .catch((error) => console.log(error)); + }; + + //삭제 취소 버튼 눌렀을 때 + const cancelConfirm = (e) => { + console.log('신고 취소'); + }; + + //모달창에서 신고하기 버튼 눌렀을 때 + const reportClick = (e) => { + e.preventDefault(); + if (reportContent === '') { + alert('신고 내용을 입력해주세요'); + } else { + if (window.confirm('정말 신고하시겠습니까?')) { + reportConfirm(); + } else { + cancelConfirm(); + } + } + }; + + //거래완료 버튼 눌렀을 때 + const completeClick = () => { + const body = { + transaction_id: selectedRoom.transaction_id, }; - - //신고 내용 - const reportContentChange = (e) => { - setReportContent(e.target.value); - }; - - //신고 확인 버튼 눌렀을 때 - const reportConfirm = () => { - const body = { - user_id: '1', - transaction_id: selectedRoom.transaction_id, - report_content: reportContent, - }; - axios - .post('http://localhost:8080/direct-message/report', body, { - withCredentials: true, - }) - .then((response) => { - if (response.data.result) { - alert('신고되었습니다.'); - setReportContent(''); - setModalOpen(false); - } else { - alert('신고에 실패했습니다.'); - } - }) - .catch((error) => console.log(error)); - }; - - //삭제 취소 버튼 눌렀을 때 - const cancelConfirm = (e) => { - console.log('신고 취소'); - }; - - //모달창에서 신고하기 버튼 눌렀을 때 - const reportClick = (e) => { - e.preventDefault(); - if (reportContent === '') { - alert('신고 내용을 입력해주세요'); + axios + .post('http://localhost:8080/direct-message/transaction-complete', body, { + withCredentials: true, + }) + .then((response) => { + if (response.data.result) { + setComplete(true); } else { - if (window.confirm('정말 신고하시겠습니까?')) { - reportConfirm(); - } else { - cancelConfirm(); - } + alert('거래완료에 실패했습니다.'); } + }) + .catch((error) => console.log(error)); + }; + + useEffect(() => { + // 메시지가 오면 스크롤 맨 아래로 내려주기 + let messagebox = document.querySelector('#messagebox'); + messagebox.scrollTop = messagebox.scrollHeight; + }, [contents, imgBase64]); + + const fileChange = (e) => { + setImgFile(e.target.files); + }; + + const previewCancelClick = () => { + setImgFile(null); + setImgBase64(null); + }; + + useEffect(() => { + if (!imgFile) return false; + + const reader = new FileReader(); + reader.onloadend = () => { + setImgBase64(reader.result); }; - - //거래완료 버튼 눌렀을 때 - const completeClick = () => { - const body = { - transaction_id: selectedRoom.transaction_id, - }; - axios - .post( - 'http://localhost:8080/direct-message/transaction-complete', - body, - { withCredentials: true } - ) - .then((response) => { - if (response.data.result) { - setComplete(true); - } else { - alert('거래완료에 실패했습니다.'); - } - }) - .catch((error) => console.log(error)); - }; - - useEffect(() => { - let messagebox = document.querySelector('#messagebox'); - messagebox.scrollTop = messagebox.scrollHeight; - }, [contents, imgBase64]); - - const handleChangeFile = (e) => { - setImgFile(e.target.files); - }; - - const previewCancelClick = () => { - setImgFile(null); - setImgBase64(null); - }; - - useEffect(() => { - if (!imgFile) return false; - - const reader = new FileReader(); - reader.onloadend = () => { - setImgBase64(reader.result); - }; - reader.readAsDataURL(imgFile[0]); - }, [imgFile]); - - return ( - <> - -
-
신고사유를 적어주세요
-
- -
- -
-
- -
-
-
- -
- {selectedRoom.user_status === '정지' || - selectedRoom.user_status === '탈퇴' - ? '(알수없음)' - : selectedRoom.not_mine_nickname} -
-
{selectedRoom.not_mine_reliability}
-
- - - -
-
- {useMemo( - () => ( -
- {contents.map((message, index) => ( -
- {message.image_url === null || - message.image_url === '' ? ( - <> -
- {message.nickname === myNickname - ? parseDate( - message.written_date - ) - : null} -
-
{message.content}
-
- {!( - message.nickname === - myNickname - ) - ? parseDate( - message.written_date - ) - : null} -
- - ) : ( - <> -
- {message.nickname === myNickname - ? parseDate( - message.written_date - ) - : null} -
-
-
{message.content}
-
- -
-
-
- {!( - message.nickname === - myNickname - ) - ? parseDate( - message.written_date - ) - : null} -
- - )} -
- ))} -
- {imgBase64 !== null ? ( -
- - -
- ) : null} -
+ reader.readAsDataURL(imgFile[0]); + }, [imgFile]); + + return ( + <> + +
+
신고사유를 적어주세요
+
+ +
+ +
+
+ +
+
+
+ +
+ {selectedRoom.user_status === '정지' || + selectedRoom.user_status === '탈퇴' + ? '(알수없음)' + : selectedRoom.not_mine_nickname} +
+
{selectedRoom.not_mine_reliability}
+
+ + + +
+
+ {useMemo( + () => ( +
+ {contents.map((message, index) => ( +
+ {message.image_url === null || message.image_url === '' ? ( + <> +
+ {message.nickname === myNickname + ? parseDate(message.written_date) + : null} +
+
{message.content}
+
+ {!(message.nickname === myNickname) + ? parseDate(message.written_date) + : null} +
+ + ) : ( + <> +
+ {message.nickname === myNickname + ? parseDate(message.written_date) + : null} +
+
+
{message.content}
+
+
- ), - [contents, imgBase64, myNickname] - )} - - {complete ? ( -
거래가 완료되었습니다.
- ) : null} - -
- - - - +
+
+ {!(message.nickname === myNickname) + ? parseDate(message.written_date) + : null} +
+ + )}
+ ))} +
+ {imgBase64 !== null ? ( +
+ + +
+ ) : null} +
- - ); + ), + [contents, imgBase64, myNickname] + )} + + {complete ? ( +
거래가 완료되었습니다.
+ ) : null} + +
+ + + + +
+
+ + ); }; export default DMDetail; diff --git a/frontend/sweet-red-beans/src/components/DMPage/DMList.js b/frontend/sweet-red-beans/src/components/DMPage/DMList.js index ace2449..f716ec2 100644 --- a/frontend/sweet-red-beans/src/components/DMPage/DMList.js +++ b/frontend/sweet-red-beans/src/components/DMPage/DMList.js @@ -7,19 +7,43 @@ import { SELECTED_DM } from '../../actions/types'; import { useNavigate } from 'react-router'; import style from '../../css/DMPage/DMList.module.css'; -const DMList = ({ DMlist, DMListClick }) => { - console.log(DMlist); - return ( - <> -
- {DMlist.map((item, index) => ( -
DMListClick(item, e)}> - -
- ))} -
- - ); +const DMList = () => { + const dispatch = useDispatch(); + const [DMlist, setDMList] = useState([]); + useEffect(() => { + //DM 목록 조회 + axios + .get('http://localhost:8080/direct-message', { + withCredentials: true, + }) + .then((response) => { + setDMList(response.data.room_id); + }) + .catch((error) => {}); + + return () => { + setDMList(null); + }; + }, []); + + const DMListClick = (selectedRoom, e) => { + dispatch({ + type: SELECTED_DM, + payload: selectedRoom, + }); + }; + + return ( + <> +
+ {DMlist.map((item, index) => ( +
DMListClick(item, e)}> + +
+ ))} +
+ + ); }; export default DMList; diff --git a/frontend/sweet-red-beans/src/components/DMPage/DMListThumbnail.js b/frontend/sweet-red-beans/src/components/DMPage/DMListThumbnail.js index 0326a57..145f625 100644 --- a/frontend/sweet-red-beans/src/components/DMPage/DMListThumbnail.js +++ b/frontend/sweet-red-beans/src/components/DMPage/DMListThumbnail.js @@ -6,61 +6,55 @@ import { parseDate } from '../../parseDate/parseDate'; import user from '../../img/user.png'; const DMListThumbnail = ({ dm }) => { - //const cookies = Cookies(); - const dispatch = useDispatch(); - const navigation = useNavigate(); - const [currentRoom, setCurrentRoom] = useState(false); - const selectedRoomId = useSelector((s) => { - if (s === undefined) { - return null; - } else { - return s.selectedRoomId; - } - }); + //const cookies = Cookies(); + const dispatch = useDispatch(); + const navigation = useNavigate(); + const [currentRoom, setCurrentRoom] = useState(false); + const selectedRoomId = useSelector((s) => { + if (s === undefined) { + return null; + } else { + return s.selectedRoom; + } + }); - useEffect(() => { - console.log(dm); - if (selectedRoomId !== null) { - if (dm.chat_room_id === selectedRoomId) { - console.log('a의 번호: ', selectedRoomId); - console.log('같음 : ', dm.chat_room_id); - setCurrentRoom(true); - } else { - setCurrentRoom(false); - } - } - }, [selectedRoomId]); + useEffect(() => { + if (selectedRoomId !== null) { + if (dm.chat_room_id === selectedRoomId.chat_room_id) { + setCurrentRoom(true); + } else { + setCurrentRoom(false); + } + } + }, [selectedRoomId]); - return ( - <> -
- + return ( + <> +
+ -
-
- {dm.user_status === '정지' || dm.user_status === '탈퇴' - ? '(알수없음)' - : dm.not_mine_nickname} -
-
{dm.recent_message}
-
-
- {dm.recent_message_date === '2020-01-01T00:00:00' - ? '' - : parseDate(dm.recent_message_date)} -
-
- - ); +
+
+ {dm.user_status === '정지' || dm.user_status === '탈퇴' + ? '(알수없음)' + : dm.not_mine_nickname} +
+
{dm.recent_message}
+
+
+ {dm.recent_message_date === '2020-01-01T00:00:00' + ? '' + : parseDate(dm.recent_message_date)} +
+
+ + ); }; export default DMListThumbnail; diff --git a/frontend/sweet-red-beans/src/components/DMPage/DMPage.js b/frontend/sweet-red-beans/src/components/DMPage/DMPage.js index 3b6a322..b124ef6 100644 --- a/frontend/sweet-red-beans/src/components/DMPage/DMPage.js +++ b/frontend/sweet-red-beans/src/components/DMPage/DMPage.js @@ -8,61 +8,27 @@ import style from '../../css/DMPage/DMPage.module.css'; import { SELECTED_DM } from '../../actions/types'; const DMPage = () => { - const dispatch = useDispatch(); - const [DMlist, setDMList] = useState([]); - const [selectedRoomId, setSelectedRoomId] = useState(null); - - const navigation = useNavigate(); - const [renderError, setRenderError] = useState(true); - - useEffect(() => { - //DM 목록 조회 - axios - .get('http://localhost:8080/direct-message', { - withCredentials: true, - }) - .then((response) => { - setDMList(response.data.room_id); - setRenderError(false); - }) - .catch((error) => { - setRenderError(true); - alert('로그인을 먼저 해주세요'); - navigation('/'); - }); - - return () => { - dispatch({ - type: SELECTED_DM, - payload: null, - }); - }; - }, []); - - const DMListClick = (selectedRoom, e) => { - dispatch({ - type: SELECTED_DM, - payload: selectedRoom.chat_room_id, - }); - setSelectedRoomId(selectedRoom); - }; + const selectedRoomId = useSelector((s) => { + if (s === undefined) { + return null; + } else { + return s.selectedRoom; + } + }); return ( <> - {!renderError ? ( - <> -
-
- -
-
- {selectedRoomId !== null ? ( - - ) : null} -
-
- - ) : null} +
+
+ +
+ +
+ {selectedRoomId !== null ? ( + + ) : null} +
+
); }; diff --git a/frontend/sweet-red-beans/src/components/MainPage/MainMovieEvents.js b/frontend/sweet-red-beans/src/components/MainPage/MainMovieEvents.js index eb75b67..a47a732 100644 --- a/frontend/sweet-red-beans/src/components/MainPage/MainMovieEvents.js +++ b/frontend/sweet-red-beans/src/components/MainPage/MainMovieEvents.js @@ -11,71 +11,67 @@ import Test from './Test'; import EventMovieThumbnail from '../EventPage/EventMovieThumbnail'; const MainMovieEvents = ({ cinemaName }) => { - const dispatch = useDispatch(); - const [events, setEvents] = useState([]); - const [thisEvents, setThisEvents] = useState([]); - const filterMovieList = []; + const dispatch = useDispatch(); + const [events, setEvents] = useState([]); + const [thisEvents, setThisEvents] = useState([]); + const filterMovieList = []; - useEffect(() => { - axios - .get('http://localhost:8080/main/event-limit', { - withCredentials: true, - }) - .then((response) => { - setEvents(response.data); - }); - }, []); + useEffect(() => { + axios + .get('http://localhost:8080/main/event-limit', { + withCredentials: true, + }) + .then((response) => { + setEvents(response.data); + }); + }, []); - useEffect(() => { - console.log(events); - events.map((item, index) => { - if (item.cinema_name === cinemaName) { - filterMovieList.push(item); - } - }); - setThisEvents(filterMovieList); - dispatch({ - type: MAIN_CINEMA_EVENTS, - mainCinemaEvents: { - cinemaName: cinemaName, - mainCinemaEvents: filterMovieList, - }, - }); - }, [events]); + useEffect(() => { + console.log(events); + events.map((item, index) => { + if (item.cinema_name === cinemaName) { + filterMovieList.push(item); + } + }); + setThisEvents(filterMovieList); + dispatch({ + type: MAIN_CINEMA_EVENTS, + mainCinemaEvents: { + cinemaName: cinemaName, + mainCinemaEvents: filterMovieList, + }, + }); + }, [events]); - useEffect(() => {}, [thisEvents]); - - const settings = { - dots: false, - arrows: true, - infinite: true, - speed: 500, - slidesToShow: 3, - slidesToScroll: 3, - }; - return ( - <> -
- {cinemaName} -
-
-
- {thisEvents !== [] ? ( - - { - thisEvents.map((item, index) => ( -
- -
- )) - //thisEvents!==[] ? thisEvents.map((item, index) =>
) : null - //test.map((item, index) =>
{item}
) - } -
- ) : null} -
- - ); + const settings = { + dots: false, + arrows: true, + infinite: true, + speed: 500, + slidesToShow: 1, + slidesToScroll: 1, + }; + return ( + <> +
+ {cinemaName} +
+
+
+ {thisEvents.length !== 0 ? ( + + {thisEvents.map((item, index) => ( +
+ +
+ ))} +
+ ) : ( +
업데이트 된 이벤트가 없어요
+ )} +
+ + ); }; export default MainMovieEvents; diff --git a/frontend/sweet-red-beans/src/components/MainPage/MainPage.js b/frontend/sweet-red-beans/src/components/MainPage/MainPage.js index cc5c7c8..a7c444b 100644 --- a/frontend/sweet-red-beans/src/components/MainPage/MainPage.js +++ b/frontend/sweet-red-beans/src/components/MainPage/MainPage.js @@ -11,58 +11,53 @@ import { Link } from 'react-router-dom'; import { useNavigate } from 'react-router'; const MainPage = () => { - const [cinemaNames, setCinemaNames] = useState([ - 'CGV', - '롯데시네마', - '메가박스', - '씨네큐', - ]); - const dispatch = useDispatch(); - const [mainVideo, setMainVideo] = useState(''); - const navigation = useNavigate(); + const [cinemaNames, setCinemaNames] = useState([ + 'CGV', + '롯데시네마', + '메가박스', + '씨네큐', + ]); + const dispatch = useDispatch(); + const [mainVideo, setMainVideo] = useState(''); + const navigation = useNavigate(); - dispatch({ - type: CINEMA_NAMES, - cinemaNames: cinemaNames, - }); - - useEffect(() => { - axios - .get('http://localhost:8080/main/video', { - withCredentials: true, - }) - .then((response) => { - setMainVideo(response.data.src); - }) - .catch((error) => console.log(error)); - return () => { - setMainVideo(''); - }; - }, []); - - const arrowClick = () => { - navigation('/event'); + useEffect(() => { + axios + .get('http://localhost:8080/main/video', { + withCredentials: true, + }) + .then((response) => { + setMainVideo(response.data.src); + }) + .catch((error) => console.log(error)); + return () => { + setMainVideo(''); }; + }, []); + + const arrowClick = () => { + navigation('/event'); + }; - return ( - <> -
- -
-
- EVENTS -
-
- {cinemaNames.map((item, index) => ( -
- -
- ))} + return ( + <> +
+ +
+
+ EVENTS +
+
+ {cinemaNames.map((item, index) => ( +
+ +
+ ))} -
TODAY'S POSTS
- - - ); +
TODAY'S POSTS
+ + + ); }; export default MainPage; diff --git a/frontend/sweet-red-beans/src/components/MainPage/MainPosts.js b/frontend/sweet-red-beans/src/components/MainPage/MainPosts.js index 73e0fba..aacd29c 100644 --- a/frontend/sweet-red-beans/src/components/MainPage/MainPosts.js +++ b/frontend/sweet-red-beans/src/components/MainPage/MainPosts.js @@ -11,6 +11,7 @@ const MainPosts = () => { useEffect(() => { axios + .get('http://localhost:8080/main/daily-community', { withCredentials: true, params: { @@ -35,6 +36,11 @@ const MainPosts = () => { setDailyGeneralPosts(response.data); }) .catch((error) => console.log(error)); + + // return () => { + // setDailyInfoPosts(null); + // setDailyGeneralPosts(null); + // }; }, []); const writeClick = () => { @@ -56,6 +62,10 @@ const MainPosts = () => { key={index}>
  • {item.title}
    +
    +
    16
    +
    16
    +
  • ))} @@ -71,6 +81,10 @@ const MainPosts = () => { key={index}>
  • {item.title}
    +
    +
    16
    +
    16
    +
  • ))} @@ -83,27 +97,6 @@ const MainPosts = () => {
    내 통장처럼 비어버린 오늘의 글...
    )} - - {/* {dailyGeneralPosts.length !== 0 ? ( - - ) : ( -
    -
    지금 당장 글 쓰러 가기
    -
    -
    내 통장처럼 비어버린 오늘의 글...
    -
    - )} */}
    ); diff --git a/frontend/sweet-red-beans/src/components/TransactionPage/TransactionDetail.js b/frontend/sweet-red-beans/src/components/TransactionPage/TransactionDetail.js index 88447a1..2a723b0 100644 --- a/frontend/sweet-red-beans/src/components/TransactionPage/TransactionDetail.js +++ b/frontend/sweet-red-beans/src/components/TransactionPage/TransactionDetail.js @@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from 'react'; import axios from 'axios'; import { useNavigate } from 'react-router'; import { useDispatch } from 'react-redux'; -import { DM_CREATE } from '../../actions/types'; +import { DM_CREATE, SELECTED_DM } from '../../actions/types'; import style from '../../css/TransactionPage/TransactionDetail.module.css'; import Modal from '../Modals/TransactionModal'; import Switch from 'react-switch'; @@ -93,8 +93,14 @@ const TransactionDetail = ({ transaction }) => { ); const DMClick = () => { + if ( + transaction.user_status === '정지' || + transaction.user_status === '탈퇴' + ) { + alert('정지되거나 탈퇴한 사용자입니다.'); + return; + } const body = { - user_id: '1', transaction_id: transaction.transaction_id, }; axios @@ -103,7 +109,7 @@ const TransactionDetail = ({ transaction }) => { }) .then((response) => { dispatch({ - type: DM_CREATE, + type: SELECTED_DM, DMCreate: response.data, }); navigation('/DM'); diff --git a/frontend/sweet-red-beans/src/css/MainPage/MainMovieEvents.module.css b/frontend/sweet-red-beans/src/css/MainPage/MainMovieEvents.module.css index feaac14..a1279cf 100644 --- a/frontend/sweet-red-beans/src/css/MainPage/MainMovieEvents.module.css +++ b/frontend/sweet-red-beans/src/css/MainPage/MainMovieEvents.module.css @@ -1,29 +1,39 @@ .cinemaName { - cursor: default; - display: inline-block; - position: relative; - text-align: left; - margin-bottom: 50px; - margin-left: -870px; - font-size: 20px; - z-index: 5; - font-family: 'ROKAFSansBold'; + cursor: default; + display: inline-block; + position: relative; + text-align: left; + margin-bottom: 50px; + margin-left: -870px; + font-size: 20px; + z-index: 5; + font-family: 'ROKAFSansBold'; } .underline { - display: inline-block; - z-index: 0; - position: absolute; - content: ''; - bottom: -8px; - left: 50%; - transform: translate(-50%, 0%); - width: 120%; - height: 5px; - background-color: #f23333; - border-radius: 10px; + display: inline-block; + z-index: 0; + position: absolute; + content: ''; + bottom: -8px; + left: 50%; + transform: translate(-50%, 0%); + width: 120%; + height: 5px; + background-color: #f23333; + border-radius: 10px; } .movieThumbnails { - margin-bottom: 50px; + margin-bottom: 50px; +} + +.nullEvents { + height: 280px; + display: flex; + justify-content: center; + align-items: center; + font-size: 20px; + color: #5a5a5a; + font-family: 'ROKAFSansBold'; } diff --git a/frontend/sweet-red-beans/src/css/MainPage/MainPosts.module.css b/frontend/sweet-red-beans/src/css/MainPage/MainPosts.module.css index de0dc94..b2198c9 100644 --- a/frontend/sweet-red-beans/src/css/MainPage/MainPosts.module.css +++ b/frontend/sweet-red-beans/src/css/MainPage/MainPosts.module.css @@ -10,9 +10,10 @@ .dailyInfoPosts, .dailyGeneralPosts { - border: #5a5a5a 1px solid; + border: #c4c4c4 1px solid; border-radius: 20px; width: 480px; + min-height: 480px; padding: 40px; box-sizing: border-box; } @@ -25,26 +26,65 @@ .posts li { padding: 30px 15px 0px 15px; box-sizing: border-box; + display: flex; + justify-content: space-between; } .posts li div { font-size: 16px; } -.posts li div:hover { +.title { + cursor: pointer; + display: inline-block; + font-size: 18px; + color: #5a5a5a; +} + +.title:hover { + color: #f23333; text-decoration: underline; } -.posts li:hover::after { - transform: translate(-50%, 0) scaleX(1); +.countArea { + font-size: 14px; + color: #5a5a5a; + font-family: 'Pretendard-Regular'; } -.title { - cursor: pointer; +.commentCount { display: inline-block; + margin-right: 5px; +} + +.commentCount::before { + display: inline-block; + content: ''; + width: 18px; + height: 18px; + background: url('../../img/main-comment.png'); + background-repeat: no-repeat; + background-size: 90%; + background-position: 50% 20%; vertical-align: middle; - font-size: 18px; - color: black; + margin-right: 5px; +} + +.views { + display: inline-block; +} + +.views::before { + display: inline-block; + content: ''; + width: 18px; + height: 18px; + background: url('../../img/view.png'); + background-repeat: no-repeat; + background-size: 100%; + background-position: 50% 20%; + vertical-align: top; + margin-right: 4px; } .nullMessage { diff --git a/frontend/sweet-red-beans/src/img/main-comment.png b/frontend/sweet-red-beans/src/img/main-comment.png new file mode 100644 index 0000000..9854a3e Binary files /dev/null and b/frontend/sweet-red-beans/src/img/main-comment.png differ diff --git a/frontend/sweet-red-beans/src/store.js b/frontend/sweet-red-beans/src/store.js index 9111c37..709635a 100644 --- a/frontend/sweet-red-beans/src/store.js +++ b/frontend/sweet-red-beans/src/store.js @@ -1,84 +1,82 @@ -import { createStore } from "redux"; -import { LOGIN_USER, MAIN_EVENTS, CINEMA_NAMES, MAIN_CINEMA_EVENTS, EVENTS, EVENT_ISEND, EVENT_SORT, INFO, -DM_CREATE, MYPAGE_USER, MYPAGE_TRANSACTIONS, MYPAGE_COMMENTS, MYPAGE_EVENTS, MYPAGE_POSTS, MYPAGE_LIKE_TRANSACTIONS, SELECTED_DM } from "./actions/types"; +import { createStore } from 'redux'; +import { + LOGIN_USER, + MAIN_EVENTS, + CINEMA_NAMES, + MAIN_CINEMA_EVENTS, + EVENTS, + EVENT_ISEND, + EVENT_SORT, + INFO, + DM_CREATE, + MYPAGE_USER, + MYPAGE_TRANSACTIONS, + MYPAGE_COMMENTS, + MYPAGE_EVENTS, + MYPAGE_POSTS, + MYPAGE_LIKE_TRANSACTIONS, + SELECTED_DM, +} from './actions/types'; - -const reducer = (state={}, action) => { - - if(action.type === LOGIN_USER){ - //user : nickname, profileURL이 있음 - return{...state, user: action.user} - } - else if(action.type === MAIN_EVENTS){ - //전체 이벤트(배열) - return {...state, mainEvents: action.events} - } - else if(action.type === CINEMA_NAMES){ - // - return {...state, cinemaNames: action.cinemaNames} - } - else if(action.type === MAIN_CINEMA_EVENTS){ - //각 영화사 별 이벤트(배열) - // if (action.mainCinemaEvents.cinemaName === "CGV") { - // return {...state, mainCGVEvents: action.mainCinemaEvents.mainCinemaEvents} - // } - // else if(action.mainCinemaEvents.cinemaName === "롯데시네마"){ - // return {...state, mainLCEvents: action.mainCinemaEvents.mainCinemaEvents} - // } - // else if(action.mainCinemaEvents.cinemaName === "메가박스"){ - // return {...state, mainLMBvents: action.mainCinemaEvents.mainCinemaEvents} - // } - // else if(action.mainCinemaEvents.cinemaName === "씨네큐"){ - // return {...state, mainLCQvents: action.mainCinemaEvents.mainCinemaEvents} - // } - } - else if (action.type === EVENTS){ - //이벤트 페이지에서 전체 이벤트 조회 - // cinema_name : string - // event_id : long - // thumbnail_url : string - // title : string - // start_date : date - // end_date : date - // is_like : boolean - return {...state, events: action.events} - } - else if (action.type === EVENT_ISEND){ - return {...state, eventIsEnd: action.payload} - } - else if (action.type === EVENT_SORT){ - return {...state, eventSort: action.payload} - } - else if (action.type === INFO){ - return {...state, info: action.info} - } - else if (action.type === DM_CREATE){ - return {...state, DMCreate: action.DMCreate} - } - else if (action.type === MYPAGE_USER){ - return {...state, mypageUser: action.payload} - } - else if (action.type === MYPAGE_TRANSACTIONS){ - return {...state, mypageTransactions: action.payload} - } - else if (action.type === MYPAGE_COMMENTS){ - return {...state, mypageComments: action.payload} - } - else if (action.type === MYPAGE_EVENTS){ - return {...state, mypageEvents: action.payload} - } - else if (action.type === MYPAGE_POSTS){ - return {...state, mypagePosts: action.payload} - } - else if (action.type === MYPAGE_LIKE_TRANSACTIONS){ - return {...state, mypageLikeTransactions: action.payload} - } - else if (action.type === SELECTED_DM){ - return {...state, selectedRoomId: action.payload} - } - -} +const reducer = (state = {}, action) => { + if (action.type === LOGIN_USER) { + //user : nickname, profileURL이 있음 + return { ...state, user: action.user }; + } else if (action.type === MAIN_EVENTS) { + //전체 이벤트(배열) + return { ...state, mainEvents: action.events }; + } else if (action.type === CINEMA_NAMES) { + // + return { ...state, cinemaNames: action.cinemaNames }; + } else if (action.type === MAIN_CINEMA_EVENTS) { + //각 영화사 별 이벤트(배열) + // if (action.mainCinemaEvents.cinemaName === "CGV") { + // return {...state, mainCGVEvents: action.mainCinemaEvents.mainCinemaEvents} + // } + // else if(action.mainCinemaEvents.cinemaName === "롯데시네마"){ + // return {...state, mainLCEvents: action.mainCinemaEvents.mainCinemaEvents} + // } + // else if(action.mainCinemaEvents.cinemaName === "메가박스"){ + // return {...state, mainLMBvents: action.mainCinemaEvents.mainCinemaEvents} + // } + // else if(action.mainCinemaEvents.cinemaName === "씨네큐"){ + // return {...state, mainLCQvents: action.mainCinemaEvents.mainCinemaEvents} + // } + } else if (action.type === EVENTS) { + //이벤트 페이지에서 전체 이벤트 조회 + // cinema_name : string + // event_id : long + // thumbnail_url : string + // title : string + // start_date : date + // end_date : date + // is_like : boolean + return { ...state, events: action.events }; + } else if (action.type === EVENT_ISEND) { + return { ...state, eventIsEnd: action.payload }; + } else if (action.type === EVENT_SORT) { + return { ...state, eventSort: action.payload }; + } else if (action.type === INFO) { + return { ...state, info: action.info }; + } else if (action.type === DM_CREATE) { + return { ...state, DMCreate: action.DMCreate }; + } else if (action.type === MYPAGE_USER) { + return { ...state, mypageUser: action.payload }; + } else if (action.type === MYPAGE_TRANSACTIONS) { + return { ...state, mypageTransactions: action.payload }; + } else if (action.type === MYPAGE_COMMENTS) { + return { ...state, mypageComments: action.payload }; + } else if (action.type === MYPAGE_EVENTS) { + return { ...state, mypageEvents: action.payload }; + } else if (action.type === MYPAGE_POSTS) { + return { ...state, mypagePosts: action.payload }; + } else if (action.type === MYPAGE_LIKE_TRANSACTIONS) { + return { ...state, mypageLikeTransactions: action.payload }; + } else if (action.type === SELECTED_DM) { + return { ...state, selectedRoom: action.payload }; + } +}; const store = createStore(reducer); -export default store; \ No newline at end of file +export default store;