Skip to content

Commit

Permalink
[#56]Feat: 자유게시판 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
redhi committed Mar 24, 2022
1 parent f43ced7 commit 6c52ef3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ import React, {useEffect, useState} from "react";
import { Link } from "react-router-dom";
import Pagination from "../Pagination/Pagination";
import style from "../../css/GeneralBoardPage/GeneralBoard.module.css"
import { useSelector } from "react-redux";
import axios from "axios";
import { parseDate } from "../../parseDate/parseDate";

const GeneralBoard = ({searchWords, sort, cinemaName, cinemaArea, cinemaBranch}) => {
const GeneralBoard = ({searchWords, sort}) => {
const [infos, setInfos] = useState([]);
const [limit, setLimit] = useState(15);
const [page, setPage] = useState(1);
const offset = (page - 1) * limit;

useEffect(()=>{
//처음에 최신순으로 요청
console.log(searchWords, sort, cinemaName, cinemaArea, cinemaBranch);
axios.get('http://localhost:8080/general-board/search',{
withCredentials: true,
params: {
Expand All @@ -31,7 +29,6 @@ const GeneralBoard = ({searchWords, sort, cinemaName, cinemaArea, cinemaBranch})
}, [])

useEffect(()=>{
console.log(searchWords, sort, cinemaName, cinemaArea, cinemaBranch);
let searchWord = ""
if(searchWords.length!==0) {
searchWord = searchWords[searchWords.length-1]
Expand All @@ -52,21 +49,7 @@ const GeneralBoard = ({searchWords, sort, cinemaName, cinemaArea, cinemaBranch})

return (
<div className={style.layout}>
{/* <label>
페이지 당 표시할 게시물 수:&nbsp;
<select
type="number"
value={limit}
onChange={({ target: { value } }) => setLimit(Number(value))}
>
<option value="10">10</option>
<option value="12">12</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</label> */}

{}
<div className={style.infoBox}>
<div className={style.topBar}>
<div>제목</div>
Expand All @@ -77,7 +60,7 @@ const GeneralBoard = ({searchWords, sort, cinemaName, cinemaArea, cinemaBranch})
<main>
{infos.slice(offset, offset + limit).map((item, index) => (
<article key={index}>
<Link to={`/GeneralBoard/${item.post_id}`} style={{textDecoration:"none"}}>
<Link to={`/generalBoard/${item.post_id}`} style={{textDecoration:"none"}}>
<div>{item.title}</div>
</Link>
<div>{item.user_status === "정지" || item.user_status === "탈퇴" ? "(알수없음)" : item.nickname}</div>
Expand All @@ -90,7 +73,7 @@ const GeneralBoard = ({searchWords, sort, cinemaName, cinemaArea, cinemaBranch})
</div>

<div className={style.writeButtonArea}>
<Link to={`/GeneralBoardWrite`}>
<Link to={`/generalBoardWrite`}>
<button>글쓰기</button>
</Link>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, {useEffect, useMemo, useState}from "react";
import { Link, unstable_HistoryRouter } from "react-router-dom";
import Comment from "../Comment/Comment";
import { useParams } from "react-router";
import { useSelector } from "react-redux";
import axios from "axios";
import { useNavigate } from "react-router";
import style from "../../css/GeneralBoardPage/GeneralBoardDetailPage.module.css";
Expand All @@ -11,12 +10,11 @@ import { parseDate } from "../../parseDate/parseDate";
const GeneralBoardDetailPage = () => {

let navigation = useNavigate();

const {postid} = useParams();
//const userid = useSelector(state => state.user.user_id);
const [detailInfo, setDetailInfo] = useState({});
const [comments, setComments] = useState([]);
const [commentsIsHere, setCommentsIsHere] = useState(false);

const[commentContent, setCommentContent] = useState("");

//처음 조회
Expand Down Expand Up @@ -158,7 +156,7 @@ const GeneralBoardDetailPage = () => {
</div>

<div className={style.preButton}>
<Link to={`/GeneralBoard`}>
<Link to={`/generalBoard`}>
<button>목록으로 돌아가기</button>
</Link>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
import React, { useEffect, useState, useMemo, useCallback } from "react";
import { useSelector, useDispatch } from "react-redux";
import { CGVarea, CGV0, CGV1, CGV2, CGV3, CGV4, CGV5, CGV6, CGV7, CGV8 } from "../../cinemas/CGVcinemas";
import { LCarea, LC0, LC1, LC2, LC3, LC4, LC5, LC6, LC7 } from "../../cinemas/LCcinemas";
import { MBarea, MB0, MB1, MB2, MB3, MB4, MB5, MB6 } from "../../cinemas/MBcinemas";
import { CQarea, CQ0, CQ1, CQ2, CQ3, CQ4 } from "../../cinemas/CQcinemas";
import GeneralBoard from "./GeneralBoard";
import { Link } from "react-router-dom";
import { INFO } from "../../actions/types";
import axios from "axios";
import style from "../../css/GeneralBoardPage/GeneralBoardPage.module.css";

const GeneralBoardPage = () => {
const dispatch = useDispatch();

const [array, setArray] = useState([]);

//이제까지 검색한 것
const [searchWords, setSearchWords] = useState([]);

//search
const [search, setSearch] = useState("");

const sorts = ["제목+내용", "제목", "내용", "작성자"];
const [sort, setSort] = useState("제목+내용");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import React, { useEffect, useState } from "react";
import { CGVarea, CGV0, CGV1, CGV2, CGV3, CGV4, CGV5, CGV6, CGV7, CGV8 } from "../../cinemas/CGVcinemas";
import { LCarea, LC0, LC1, LC2, LC3, LC4, LC5, LC6, LC7 } from "../../cinemas/LCcinemas";
import { MBarea, MB0, MB1, MB2, MB3, MB4, MB5, MB6 } from "../../cinemas/MBcinemas";
import { CQarea, CQ0, CQ1, CQ2, CQ3, CQ4 } from "../../cinemas/CQcinemas";
import { Link } from "react-router-dom";
import axios from "axios";
import { useNavigate } from "react-router";
import { useSelector } from "react-redux";
import style from "../../css/GeneralBoardPage/GeneralBoardWritePage.module.css";

const GeneralBoardWritePage = () => {
let navigation = useNavigate();

const [array, setArray] = useState([]);
const [title, setTitle] = useState("");
const [content, setContent] = useState("");

Expand All @@ -25,13 +18,9 @@ const GeneralBoardWritePage = () => {
}, [])

const contentChange = (e) => {
// const a = content.replace("\n", <br/>)
// console.log(a);
setContent(e.target.value);
}

//const userId = useSelector(state => state.user.user_id);

//글쓰기 버튼 눌렀을 때
const writeClick = () => {
if (title === "" || content === ""){
Expand All @@ -42,7 +31,6 @@ const GeneralBoardWritePage = () => {

//이미지 파일 없을 때
if(imgFile === null){
fd.append("user_id", "1");
fd.append("title", title);
fd.append("content", content);

Expand All @@ -55,7 +43,7 @@ const GeneralBoardWritePage = () => {
.then(response => {
if(response.data.result) {
alert("게시글이 성공적으로 작성되었습니다.");
navigation('/GeneralBoard');
navigation('/generalBoard');
}
else {
alert("게시글 작성을 실패했습니다.")
Expand All @@ -70,7 +58,6 @@ const GeneralBoardWritePage = () => {
//이미지 파일 있을 때
else {
fd.append("image_url", imgFile[0])
fd.append("user_id", "1");
fd.append("title", title);
fd.append("content", content);

Expand All @@ -83,7 +70,7 @@ const GeneralBoardWritePage = () => {
.then(response => {
if(response.data.result) {
alert("게시글이 성공적으로 작성되었습니다.");
navigation('/GeneralBoard');
navigation('/generalBoard');
}
else {
alert("게시글 작성을 실패했습니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ const MainContent = () => {
<Route path="/informationShare/*" element={<InformationSharePage/>}/>
<Route path="/informationShareWrite" element={<InformationShareWritePage/>}/>
<Route path="/informationShare/:postid" element={<InformationShareDetailPage/>}/>
<Route path="/GeneralBoard/*" element={<GeneralBoardPage/>}/>
<Route path="/GeneralBoardWrite" element={<GeneralBoardWritePage/>}/>
<Route path="/GeneralBoard/:postid" element={<GeneralBoardDetailPage/>}/>
<Route path="/generalBoard/*" element={<GeneralBoardPage/>}/>
<Route path="/generalBoardWrite" element={<GeneralBoardWritePage/>}/>
<Route path="/generalBoard/:postid" element={<GeneralBoardDetailPage/>}/>
<Route path="/transaction/*" element={<TransactionPage/>}/>
<Route path="/DM" element={<DMPage/>}/>
<Route path="/mypage" element={<MyPageNormal/>}>
<Route path="myevents" element={<MyEvents/>}/>
<Route path="mytransactions" element={<MyTransactions/>}/>
<Route path="myliketransactions" element={<MyLikeTransactions/>}/>
<Route path="myliketransactions" element={<sMyLikeTransactions/>}/>
<Route path="myposts" element={<MyPosts/>}/>
<Route path="mycomments" element={<MyComments/>}/>
</Route>
Expand Down

0 comments on commit 6c52ef3

Please sign in to comment.