Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SKRR-29 feat: club post etc #253

Merged
merged 15 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
ae107d3
fix: ๋Œ“๊ธ€ ๋ชฉ๋ก ์กฐํšŒ api ํƒ€์ž… ๋ณ€๊ฒฝ
colorkite10 Jan 26, 2024
83142c4
design: ๋Œ“๊ธ€ ์ž‘์„ฑ์ž ์ตœ์†Œ ๋„ˆ๋น„ ์„ค์ •
colorkite10 Jan 26, 2024
6b70e24
design: ๋Œ“๊ธ€ ๋ชฉ๋ก wrap ์†์„ฑ ์ œ๊ฑฐ
colorkite10 Jan 26, 2024
bd353e9
design: ๊ฒŒ์‹œ๊ธ€ ๋‚ด์šฉ ๊ธธ์–ด์งˆ ๋•Œ ellipsis ์ฒ˜๋ฆฌ
colorkite10 Jan 26, 2024
7e78d28
design: ๋Œ“๊ธ€ ์—†์„ ๋•Œ ์•ˆ๋‚ด๋ฌธ๊ตฌ ์ถœ๋ ฅ
colorkite10 Jan 26, 2024
bf27b6c
design: ํด๋Ÿฝ ๊ฒŒ์‹œ๋ฌผ ์—ฌ๋ฐฑ ์กฐ์ •
colorkite10 Jan 26, 2024
b3287cf
design: ํด๋Ÿฝ ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก ์ž‘์„ฑ์ž ๋ฐฐ์น˜ ๋ณ€๊ฒฝ
colorkite10 Feb 1, 2024
3f0dbe4
design: ํด๋Ÿฝ ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก ๊ตฌ๋ถ„์„  ์ถ”๊ฐ€
colorkite10 Feb 1, 2024
3cb96cc
fix: ๋Œ“๊ธ€์ œ์ถœ ํ›„ private ๊ฐ’ ์ดˆ๊ธฐํ™”
colorkite10 Feb 1, 2024
61143f7
design: ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก ์ด๋ฏธ์ง€ ํ‘œ์‹œ ๋ฐ ์ž‘์„ฑ์‹œ๊ฐ„ ์‚ญ์ œ
colorkite10 Feb 1, 2024
d1afc3f
design: ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก content์™€ data ๊ฐ„๊ฒฉ ์กฐ์ •
colorkite10 Feb 1, 2024
ba7a481
feat: ํด๋Ÿฝ ๊ฒŒ์‹œ๊ธ€ ์ˆ˜์ • ์‹œ ์ด์ „ ์‚ฌ์ง„ ๋ฐ˜์˜
colorkite10 Feb 1, 2024
1db6e49
design: ๋Œ“๊ธ€ ์ž…๋ ฅ ์ปดํฌ๋„ŒํŠธ ํ•˜์œ„ ์—ฌ๋ฐฑ ์ถ”๊ฐ€
colorkite10 Feb 1, 2024
6f7ed0e
design: ๋‚ด๊ฐ€ ์“ด ๊ธ€, ๋Œ“๊ธ€ ๋ฒ„ํŠผ ์‚ญ์ œ
colorkite10 Feb 1, 2024
9b9b2ef
design: ๋ฒ„ํŠผ ํฌ์ธํ„ฐ ์ฒ˜๋ฆฌ
colorkite10 Feb 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/apis/club/postCreateClubPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const postCreateClubPost = async ({ clubId, title, content, image }: PostCreateC
title,
content,
};

const formData = new FormData();
if (title || content) {
const blobRequest = new Blob([JSON.stringify(dataTransform)], { type: 'application/json' });
Expand Down
2 changes: 2 additions & 0 deletions src/components/ClubComment/ClubComment.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const AuthorInfoWrapper = styled.div`
display: flex;
align-items: center;
gap: 0.5rem;
min-width: 5rem;
font-size: ${Theme.fontSize.smallContent};
font-weight: 600;
`;
Expand Down Expand Up @@ -52,6 +53,7 @@ const DeleteButtonAreaStyled = styled.div`
align-items: center;
width: 1rem;
height: 1rem;
cursor: pointer;
`;

export {
Expand Down
60 changes: 43 additions & 17 deletions src/components/ClubComments/ClubComments.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,58 @@
import useGetClubCommentsQuery from '@/hooks/query/club/useGetClubCommentsQuery';
import { CommonEmptyEventsWrapper } from '@/styles/common';

import { useState } from 'react';

import ClubComment from '../ClubComment/ClubComment';
import Pagination from '../common/Pagination/Pagination';
import { CommentCountWrapper, CommentsContainer } from './ClubComments.style';

interface ClubCommentsProps {
postId: string;
}

const ClubComments = ({ postId }: ClubCommentsProps) => {
const { clubPostComments, pageData } = useGetClubCommentsQuery({ postId, pageNumber: 0 });
const totalComment = pageData?.numberOfElements;
const [currentPage, setCurrentPage] = useState(0);
const { clubPostComments, pageData } = useGetClubCommentsQuery({
postId,
pageNumber: currentPage,
});
if (!pageData) {
return null;
}
const { totalPages, size, totalElements } = pageData;

const handleChangePage = (page: number) => {
setCurrentPage(page);
};

return (
<CommentsContainer>
<CommentCountWrapper>{`๋Œ“๊ธ€ ${totalComment}`}</CommentCountWrapper>
{clubPostComments?.map((comment) => (
<ClubComment
key={comment.commentId}
commentId={comment.commentId}
authorImageUrl={comment.authorImageUrl}
authorId={comment.authorId}
author={comment.author}
content={comment.content}
createdDate={comment.createdDate}
isPrivate={comment.isPrivate}
/>
))}
</CommentsContainer>
<>
<CommentsContainer>
<CommentCountWrapper>{`๋Œ“๊ธ€ ${totalElements}`}</CommentCountWrapper>
{clubPostComments?.map((comment) => (
<ClubComment
key={comment.commentId}
commentId={comment.commentId}
authorImageUrl={comment.authorImageUrl}
authorId={comment.authorId}
author={comment.author}
content={comment.content}
createdDate={comment.createdDate}
isPrivate={comment.isPrivate}
/>
))}
{totalElements === 0 && (
<CommonEmptyEventsWrapper>๋Œ“๊ธ€์ด ์—†์Šต๋‹ˆ๋‹ค.</CommonEmptyEventsWrapper>
)}
</CommentsContainer>
<Pagination
totalPages={totalPages}
size={size}
onChangePage={handleChangePage}
currentPage={currentPage}
/>
</>
);
};

Expand Down
11 changes: 6 additions & 5 deletions src/components/ClubPost/ClubPost.style.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import Theme from '@/styles/Theme';
import { ellipsisText } from '@/styles/common';
import styled from '@emotion/styled';

const BoardContainer = styled.div`
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 2rem;
width: 90%;
height: 6.2rem;
padding: 0.5rem;
border-bottom: 1px solid ${Theme.color.tSemiWhite};

&:not(:last-of-type)::after {
width: 100%;
border-bottom: 1px solid ${Theme.color.tSeparator};
&:last-child {
border-bottom: none;
}
`;

Expand Down Expand Up @@ -53,7 +54,7 @@ const TitleStyled = styled.h1`
font-weight: 800;
`;

const ContentStyled = styled.p`
const ContentStyled = styled(ellipsisText)`
font-size: ${Theme.fontSize.mediumContent};
`;

Expand Down
19 changes: 11 additions & 8 deletions src/components/ClubPost/ClubPost.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { PATH } from '@/constants/path';
import Theme from '@/styles/Theme';
import { getDateStamp } from '@/utils/getTimeStamp';

import { IoMdImage } from 'react-icons/io';
import { useNavigate } from 'react-router-dom';

import Avatar from '../common/Avatar/Avatar';
Expand Down Expand Up @@ -38,21 +40,22 @@ const ClubPost = ({
const navigate = useNavigate();
const hasImage = Boolean(postImageUrl);
const postedDate = getDateStamp(createdDate.split('T')[0]);
const postedTime = createdDate.split('T')[1];

return (
<BoardContainer>
<BoardContentWrapper onClick={() => navigate(PATH.CLUB.POST(clubId, postId))}>
<TitleStyled>{title}</TitleStyled>
{hasImage && <div>image</div>}
<TitleStyled>
{title}
{hasImage && <IoMdImage fill={Theme.color.tSeparator} />}
</TitleStyled>
<ContentStyled>{content}</ContentStyled>
</BoardContentWrapper>
<BoardInfoWrapper>
<PostDateWrapper>
{postedDate} {postedTime}
</PostDateWrapper>
<Avatar avatarSize="small" profileImageSrc={authorImageUrl} />
<AuthorWrapper>{author}</AuthorWrapper>
<PostDateWrapper>{postedDate}</PostDateWrapper>
<AuthorWrapper>
<Avatar avatarSize="small" profileImageSrc={authorImageUrl} />
{author}
</AuthorWrapper>
</BoardInfoWrapper>
</BoardContainer>
);
Expand Down
7 changes: 7 additions & 0 deletions src/components/ClubPostDetail/ClubPostDetail.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const ClubPostDetailContainer = styled.div`
flex-direction: column;
gap: 1.5rem;
width: 100%;
padding: 1.5rem;
`;

const PostAuthorWrapper = styled.div`
Expand All @@ -23,6 +24,7 @@ const PostTitleStyled = styled.h1`
const PostContentStyled = styled.p`
font-size: ${Theme.fontSize.largeContent};
word-break: break-all;
white-space: pre-wrap;
`;

const PostedDateStyled = styled.div`
Expand All @@ -35,6 +37,10 @@ const PostSeparatorStyled = styled.div`
border-bottom: 1px solid ${Theme.color.tSeparator};
`;

const ImageStyled = styled.img`
max-width: 40rem;
`;

const ButtonWrapper = styled.div`
display: flex;
justify-content: end;
Expand All @@ -50,4 +56,5 @@ export {
PostedDateStyled,
PostSeparatorStyled,
ButtonWrapper,
ImageStyled,
};
5 changes: 3 additions & 2 deletions src/components/ClubPostDetail/ClubPostDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Button from '../common/Button/Button';
import {
ButtonWrapper,
ClubPostDetailContainer,
ImageStyled,
PostAuthorWrapper,
PostContentStyled,
PostSeparatorStyled,
Expand Down Expand Up @@ -84,13 +85,13 @@ const ClubPostDetail = ({ clubId, postId }: ClubPostDetailProps) => {
{author}
</PostAuthorWrapper>
<PostTitleStyled>{title}</PostTitleStyled>
{postImageUrl && <img src={postImageUrl} />}
{postImageUrl && <ImageStyled src={postImageUrl} />}
<PostContentStyled>{content}</PostContentStyled>
<PostedDateStyled>
{postedDate} {postedTime} {isEdited && <span>(ํŽธ์ง‘๋จ)</span>}
</PostedDateStyled>
<PostSeparatorStyled />
</ClubPostDetailContainer>
<PostSeparatorStyled />
</>
);
};
Expand Down
5 changes: 3 additions & 2 deletions src/components/WriteClubComment/WriteClubComment.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const WriteCommentContainer = styled.div`
gap: 1rem;
width: 100%;
min-width: 20rem;
padding: 1rem 1rem 0 1rem;
padding: 1rem 1rem 5rem 1rem;
`;

const UserInfoWrapper = styled.div`
Expand Down Expand Up @@ -54,8 +54,9 @@ const CommentButtonStyled = styled.button`
outline: none;
border: 0;
color: white;
background-color: ${Theme.color.tSeparator};
background-color: ${Theme.color.tSemiPurple};
border-radius: 0.5rem;
cursor: pointer;
`;

const PrivateWrapper = styled.div`
Expand Down
5 changes: 3 additions & 2 deletions src/components/WriteClubComment/WriteClubComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const WriteClubComment = ({ postId }: WriteClubCommentProps) => {
const {
register,
handleSubmit,
reset,
formState: { errors },
} = useForm<WriteClubCommentValue>({
defaultValues: {
Expand All @@ -45,9 +46,9 @@ const WriteClubComment = ({ postId }: WriteClubCommentProps) => {

const { username, profileImageUrl } = data;

const onSubmit: SubmitHandler<WriteClubCommentValue> = (data, event) => {
const onSubmit: SubmitHandler<WriteClubCommentValue> = (data) => {
postComment({ postId, content: data.content, isPrivate: data.isPrivate });
event?.target.reset();
reset();
};

return (
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/query/club/useGetClubCommentsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const useGetClubCommentsQuery = ({ postId, pageNumber }: GetClubCommentsRequest)
queryFn: () => getClubComments({ postId, pageNumber }),
});

const { data, sliceData } = comments ?? {};
const { data, pageData } = comments ?? {};

return { clubPostComments: data, pageData: sliceData };
return { clubPostComments: data, pageData };
};

export default useGetClubCommentsQuery;
28 changes: 2 additions & 26 deletions src/pages/club/ClubBoardPage/ClubBoardPage.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,8 @@ const ClubBoardContentWrapper = styled.div`

const ButtonWrapper = styled.div`
display: flex;
justify-content: space-between;
justify-content: flex-start;
width: 100%;
`;

const MyPostsCommentsButtonStyled = styled.button`
border: 0;
background-color: transparent;
cursor: pointer;
`;

const MyButtonsWrapper = styled.div`
display: flex;
width: fit-content;
gap: 0.5rem;

& > *:not(:last-of-type)::after {
content: '|';
margin-left: 0.5rem;
}
`;

export {
ClubBoardPageContainer,
ClubBoardTopWrapper,
ClubBoardContentWrapper,
ButtonWrapper,
MyPostsCommentsButtonStyled,
MyButtonsWrapper,
};
export { ClubBoardPageContainer, ClubBoardTopWrapper, ClubBoardContentWrapper, ButtonWrapper };
6 changes: 0 additions & 6 deletions src/pages/club/ClubBoardPage/ClubBoardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import {
ClubBoardContentWrapper,
ClubBoardPageContainer,
ClubBoardTopWrapper,
MyButtonsWrapper,
MyPostsCommentsButtonStyled,
} from './ClubBoardPage.style';

const ClubBoardPage = () => {
Expand All @@ -34,10 +32,6 @@ const ClubBoardPage = () => {
buttonText="๊ธ€ ์ž‘์„ฑํ•˜๊ธฐ"
onClick={() => navigate(PATH.CLUB.WRITE_POST(clubId))}
/>
<MyButtonsWrapper>
<MyPostsCommentsButtonStyled>๋‚ด๊ฐ€ ์“ด ๊ธ€</MyPostsCommentsButtonStyled>
<MyPostsCommentsButtonStyled>๋‚ด๊ฐ€ ์“ด ๋Œ“๊ธ€</MyPostsCommentsButtonStyled>
</MyButtonsWrapper>
</ButtonWrapper>
<ClubPosts clubId={clubId} />
</ClubBoardContentWrapper>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/club/ClubPostDetailPage/ClubPostDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ClubPostDetailPage = () => {
if (!clubId) {
throw new Error('ํด๋Ÿฝ ID๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค');
} else if (!postId) {
return null; //#TODO: ๊ฒŒ์‹œ๋ฌผ ์ฐพ์„ ์ˆ˜ ์—†๋‹ค๋Š” ๋ชจ๋‹ฌ์ฐฝ ๋„์šฐ๊ณ  ์ „ ํŽ˜์ด์ง€๋กœ ์ด๋™
return null;
}

return (
Expand Down
25 changes: 24 additions & 1 deletion src/pages/club/ClubPostWritePage/ClubPostWritePage.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,27 @@ const FileInputWrapper = styled.div`
display: flex;
justify-content: start;
width: 100%;
padding: 0.5rem;
`;

const FileInputLabelStyled = styled.label`
display: flex;
justify-content: center;
align-items: center;
width: 3rem;
height: 3rem;
background-color: ${Theme.color.tSeparator};
color: white;
cursor: pointer;
`;

const InputStyled = styled.input`
display: none;
`;

const PreviewImageStyled = styled.img`
width: 3rem;
height: 3rem;
object-fit: cover;
`;

const ErrorMessageStyled = styled.div`
Expand All @@ -61,4 +81,7 @@ export {
ContentStyled,
FileInputWrapper,
ErrorMessageStyled,
FileInputLabelStyled,
InputStyled,
PreviewImageStyled,
};
Loading
Loading