Skip to content

Commit

Permalink
Merge pull request #101 from KEEPER31337/feature/스터디_페이지_구현
Browse files Browse the repository at this point in the history
Feature/스터디 페이지 구현
  • Loading branch information
amaran-th authored Mar 20, 2022
2 parents 0f5721b + 29b878c commit 2d00e51
Show file tree
Hide file tree
Showing 31 changed files with 2,612 additions and 219 deletions.
13 changes: 13 additions & 0 deletions src/API/v1/member.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import axios from 'axios';

const API_URL = process.env.REACT_APP_API_URL;

async function getAllMembers() {
const options = {
method: 'GET',
url: API_URL + '/v1/common/members',
};
try {
const response = await axios(options);
return response.data;
} catch (error) {
return error.response.data;
}
}
async function getMember({ token }) {
const options = {
method: 'GET',
Expand Down Expand Up @@ -324,6 +336,7 @@ async function getCommonMembers() {
}

export default {
getAllMembers,
getMember,
getMembers,
updateEmail,
Expand Down
4 changes: 2 additions & 2 deletions src/API/v1/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function create({
formData.append('isSecret', isSecret);
formData.append('isTemp', isTemp);
formData.append('password', password);
formData.append('file', files);
files.forEach((file) => formData.append('file', file));
formData.append('thumbnail', thumbnailFile);

const config = {
Expand Down Expand Up @@ -150,7 +150,7 @@ async function modify({
formData.append('isTemp', isTemp);
formData.append('password', password);
formData.append('file', files);
formData.append('thumbnailFile', thumbnailFile);
formData.append('thumbnail', thumbnailFile);

const config = {
headers: {
Expand Down
122 changes: 122 additions & 0 deletions src/API/v1/study.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import axios from 'axios';

const API_URL = process.env.REACT_APP_API_URL;

async function getYears({ token }) {
const options = {
method: 'GET',
url: API_URL + '/v1/study/years',
headers: {
Authorization: `${token}`,
},
};
try {
const response = await axios(options);
return response.data;
} catch (error) {
return error.response.data;
}
}
async function getStudies({ token, year, season }) {
const options = {
method: 'GET',
url: API_URL + '/v1/study/list',
headers: {
Authorization: token,
},
params: { year: year, season: season },
};
try {
const response = await axios(options);
return response.data;
} catch (error) {
return error.response.data;
}
}
async function create({
year,
season,
title,
information,
memberIdList,
gitLink,
noteLink,
etcLink,
thumbnailFile,
ipAddress,
token,
}) {
const formData = new FormData();
formData.append('studyDto.title', title);
formData.append('studyDto.information', information);
formData.append('studyDto.year', year);
formData.append('studyDto.season', season);
formData.append('studyDto.ipAddress', ipAddress);
//formData.append('memberIdList', headMember);
formData.append('memberIdList[]', memberIdList);
formData.append('studyDto.gitLink', gitLink);
formData.append('studyDto.noteLink', noteLink);
formData.append('studyDto.etcLink', etcLink);
if (thumbnailFile) formData.append('thumbnail', thumbnailFile);

const config = {
headers: {
'content-type': 'multipart/form-data',
Authorization: `${token}`,
},
};
try {
const response = await axios.post(API_URL + '/v1/study', formData, config);
return response.data;
} catch (error) {
return error.response.data;
}
}
async function modify({
studyId,
year,
season,
title,
information,
memberIdList,
gitLink,
noteLink,
etcLink,
thumbnailFile,
ipAddress,
token,
}) {
const formData = new FormData();
formData.append('studyId', studyId);
formData.append('studyDto.title', title);
formData.append('studyDto.information', information);
formData.append('studyDto.year', year);
formData.append('studyDto.season', season);
formData.append('studyDto.ipAddress', ipAddress);
//formData.append('memberIdList', headMember);
formData.append('memberIdList[]', memberIdList);
formData.append('studyDto.gitLink', gitLink);
formData.append('studyDto.noteLink', noteLink);
formData.append('studyDto.etcLink', etcLink);
if (thumbnailFile) formData.append('thumbnail', thumbnailFile);

const config = {
headers: {
'content-type': 'multipart/form-data',
Authorization: `${token}`,
},
};
try {
const response = await axios.put(API_URL + '/v1/study', formData, config);
return response.data;
} catch (error) {
return error.response.data;
}
}

export default {
getYears,
getStudies,
create,
modify,
};
Binary file added src/assets/img/icons/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/icons/notion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 12 additions & 10 deletions src/page/Board/BoardMain.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ const Board = () => {
return (
<>
<AuthUser>
<div className="flex justify-center h-full dark:bg-mainBlack">
<div className="inline-block m-5 w-[90vw]">
<Info />
<Boards categoryId={categoryId} />
<div className="w-full flex justify-center">
<div className="flex justify-center min-h-screen dark:bg-mainBlack max-w-[70rem]">
<div className="inline-block m-5 w-[90vw]">
<Info />
<Boards categoryId={categoryId} />
</div>
</div>
<div
name="mobile 글쓰기 버튼"
className="fixed right-0 bottom-10 m-5 inline-block md:hidden"
>
<WriteButtonMobile />
</div>
</div>
<div
name="mobile 글쓰기 버튼"
className="fixed right-0 bottom-10 m-5 inline-block md:hidden"
>
<WriteButtonMobile />
</div>
</AuthUser>
</>
Expand Down
76 changes: 40 additions & 36 deletions src/page/Board/BoardView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,51 +63,55 @@ const BoardView = (props) => {
</div>
) : (
<AuthUser>
<ScrollToTop />
<div className="flex justify-center dark:bg-mainBlack">
<div className="inline-block m-5 w-[90vw]">
<Info />
{board?.id && prevBoard.id !== board.id ? (
<Content
board={board}
commentChangeFlag={commentChangeFlag}
likeChangeFlag={likeChangeFlag}
setLikeChangeFlag={setLikeChangeFlag}
/>
) : (
''
)}
{board?.allowComment == 0 ? (
<div className="text-center text-slate-400 text-xl h-[200px] pt-[80px]">
작성자가 댓글 작성을 허용하지 않은 게시글입니다.
</div>
) : (
<div>
<div className="w-full flex justify-center">
<div className="max-w-[70vw]">
<ScrollToTop />
<div className="flex justify-center dark:bg-mainBlack">
<div className="inline-block m-5 w-[90vw]">
<Info />
{board?.id && prevBoard.id !== board.id ? (
<Comments
boardId={board.id}
commentCount={board.commentCount}
<Content
board={board}
commentChangeFlag={commentChangeFlag}
setCommentChangeFlag={setCommentChangeFlag}
likeChangeFlag={likeChangeFlag}
setLikeChangeFlag={setLikeChangeFlag}
/>
) : (
''
)}
</div>
)}
{board?.allowComment == 0 ? (
<div className="text-center text-slate-400 text-xl h-[200px] pt-[80px]">
작성자가 댓글 작성을 허용하지 않은 게시글입니다.
</div>
) : (
<div>
{board?.id && prevBoard.id !== board.id ? (
<Comments
boardId={board.id}
commentCount={board.commentCount}
commentChangeFlag={commentChangeFlag}
setCommentChangeFlag={setCommentChangeFlag}
/>
) : (
''
)}
</div>
)}

<Boards
commentChangeFlag={commentChangeFlag}
categoryId={categoryId}
/>
<Boards
commentChangeFlag={commentChangeFlag}
categoryId={categoryId}
/>
</div>
</div>
<div
name="mobile 글쓰기 버튼"
className="fixed right-0 bottom-10 m-5 inline-block md:hidden"
>
<WriteButtonMobile />
</div>
</div>
</div>
<div
name="mobile 글쓰기 버튼"
className="fixed right-0 bottom-10 m-5 inline-block md:hidden"
>
<WriteButtonMobile />
</div>
</AuthUser>
)}
</>
Expand Down
12 changes: 7 additions & 5 deletions src/page/Board/BoardWrite.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ const BoardWrite = () => {
const redirectData = useLocation();
return (
<AuthUser>
<div className="flex justify-center dark:bg-mainBlack">
<div className="m-5 w-4/5">
<Info isWrite={true} />
<div>
<TextEditer redirectData={redirectData} />
<div className="w-full flex justify-center">
<div className="flex justify-center max-w-[70rem] dark:bg-mainBlack">
<div className="m-5 w-[90vw]">
<Info isWrite={true} />
<div>
<TextEditer redirectData={redirectData} />
</div>
</div>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions src/page/Board/Components/Boards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const setPageButton = (currentPage, page) => {

const getStyleIcon = (item) => {
if (item == styleList[0]) {
return <ViewListIcon className="inline-block h-5 w-5" />;
return <ViewListIcon className="inline-block h-5 w-5 -mt-[2px] mb-[2px]" />;
} else {
return <ViewGridIcon className="inline-block h-5 w-5" />;
return <ViewGridIcon className="inline-block h-5 w-5 -mt-[2px] mb-[2px]" />;
}
};

Expand Down Expand Up @@ -209,7 +209,7 @@ const Boards = ({ categoryId, commentChangeFlag, state, changeMode }) => {
}, [currentPage, viewStyle, commentChangeFlag]); //currentPage 값이 변경될 때마다

return (
<div className="dark:bg-mainBlack dark:text-mainWhite ">
<div className="w-full dark:bg-mainBlack dark:text-mainWhite ">
{noticeBoardContent.length === 0 && boardContent.length === 0 ? (
<div className="text-center text-slate-400 text-xl h-[400px] pt-[150px]">
<strong className="text-3xl">
Expand Down Expand Up @@ -502,9 +502,9 @@ const Boards = ({ categoryId, commentChangeFlag, state, changeMode }) => {
</div>
</div>
<div name="bottom" className="mb-10">
<div name="search" className="flex flex-col sm:block">
<div name="search" className="flex flex-col gap-y-2 sm:block">
<select
className="border mx-1 mb-2 my-2 py-1 w-fit text-xs focus:ring-mainYellow focus:border-mainYellow dark:border-darkPoint dark:bg-darkComponent dark:text-mainWhite"
className="border mx-1 w-fit text-xs focus:ring-mainYellow focus:border-mainYellow dark:border-darkPoint dark:bg-darkComponent dark:text-mainWhite"
name="search rule"
onChange={(e) => SetSelectedSearchVal(e.target.value)}
>
Expand Down
13 changes: 3 additions & 10 deletions src/page/Board/Components/Comments.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import ipAPI from 'API/v1/ip';
import commentAPI from 'API/v1/comment';
import { getDiffTimeWithFormat2 } from '../BoardUtil';

const API_URL = process.env.REACT_APP_API_URL;

const Comments = ({
boardId,
commentCount: commentCount,
Expand Down Expand Up @@ -45,6 +43,7 @@ const Comments = ({
})
.then((res) => {
setComments(res.list);
console.log(comments);
comments.map((comment) => {
if (comment.checkedLike)
setLikedComments([...likedComments, comment.id]);
Expand Down Expand Up @@ -212,9 +211,7 @@ const Comments = ({
<div className="border-4 w-[5em] h-[5em] mr-4 mt-2 rounded-full items-center shadow-lg flex-shrink-0 text-divisionGray hidden sm:flex dark:border-gray-500 dark:text-gray-500">
{comment.writerThumbnailId ? (
<img
src={
API_URL + '/v1/util/thumbnail/' + comment.writerThumbnailId
}
src={comment.writerThumbnailPath}
className="rounded-full"
/>
) : (
Expand Down Expand Up @@ -369,11 +366,7 @@ const Comments = ({
<div className="border-4 w-[3em] h-[3em] mr-4 mt-2 rounded-full items-center shadow-lg flex-shrink-0 text-divisionGray hidden sm:flex dark:border-gray-500 dark:text-gray-500">
{comment.writerThumbnailId ? (
<img
src={
API_URL +
'/v1/util/thumbnail/' +
comment.writerThumbnailId
}
src={comment.writerThumbnailPath}
className="round-full"
/>
) : (
Expand Down
Loading

0 comments on commit 2d00e51

Please sign in to comment.