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

feat: 게시글 신고 Toast mds로 변경 및 멤버 신고/차단 기능 추가 #1555

Merged
merged 18 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@radix-ui/react-tooltip": "^1.0.5",
"@sopt-makers/colors": "^3.0.0",
"@sopt-makers/fonts": "^1.0.0",
"@sopt-makers/icons": "^1.0.5",
"@sopt-makers/ui": "^2.0.5",
"@tanstack/react-query": "^5.4.3",
"@toss/emotion-utils": "^1.1.10",
Expand Down
8 changes: 8 additions & 0 deletions public/icons/icon-dots-vertical.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions src/api/endpoint/members/postBlockMember.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { useMutation } from '@tanstack/react-query';
import { z } from 'zod';

import { createEndpoint } from '@/api/typedAxios';

interface RequestBody {
blockedMemberId: number;
}

export const postBlockMember = createEndpoint({
request: (requestBody: RequestBody) => ({
method: 'PATCH',
url: `api/v1/members/block/activate`,
data: requestBody,
}),
serverResponseScheme: z.unknown(),
});

export const usePostBlockMemberMutation = () => {
return useMutation({
mutationFn: (requestBody: RequestBody) => postBlockMember.request(requestBody),
});
};
23 changes: 23 additions & 0 deletions src/api/endpoint/members/postReportMember.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { useMutation } from '@tanstack/react-query';
import { z } from 'zod';

import { createEndpoint } from '@/api/typedAxios';

interface RequestBody {
reportMemberId: number;
}

export const postReportMember = createEndpoint({
request: (requestBody: RequestBody) => ({
method: 'POST',
url: `api/v1/members/report`,
data: requestBody,
}),
serverResponseScheme: z.unknown(),
});

export const usePostReportMemberMutation = () => {
return useMutation({
mutationFn: (requestBody: RequestBody) => postReportMember.request(requestBody),
});
};
7 changes: 6 additions & 1 deletion src/components/common/Modal/parts/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { fonts } from '@sopt-makers/fonts';

import { MOBILE_MEDIA_QUERY } from '@/styles/mediaQuery';
import { textStyles } from '@/styles/typography';
Expand All @@ -16,7 +17,11 @@ export const ModalTitle = styled.h1`
margin-bottom: 12px;
line-height: 24px;

${textStyles.SUIT_18_B}
${fonts.TITLE_20_SB}

@media ${MOBILE_MEDIA_QUERY} {
${fonts.TITLE_18_SB}
}
`;

export const ModalDescription = styled.div`
Expand Down
4 changes: 4 additions & 0 deletions src/components/common/Modal/useConfirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,8 @@ const StyleModalDescription = styled.div`
line-height: 26px;
white-space: pre-wrap;
color: ${colors.gray100};

@media ${MOBILE_MEDIA_QUERY} {
${fonts.BODY_14_R}
}
`;
10 changes: 8 additions & 2 deletions src/components/feed/common/FeedDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ const DropdownPortal = dynamic(() => import('@radix-ui/react-dropdown-menu').the

interface FeedDropdownProps {
trigger?: ReactNode;
style?: React.CSSProperties;
}

const Base = ({ trigger, children }: PropsWithChildren<FeedDropdownProps>) => {
const Base = ({ trigger, style, children }: PropsWithChildren<FeedDropdownProps>) => {
return (
<DropdownMenu.Root>
<DropdownMenu.Trigger>{trigger}</DropdownMenu.Trigger>
<DropdownPortal>
<StyledContent initial={{ opacity: 0, y: -4 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.3 }}>
<StyledContent
initial={{ opacity: 0, y: -4 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.3 }}
style={style}
>
{children}
</StyledContent>
</DropdownPortal>
Expand Down
29 changes: 16 additions & 13 deletions src/components/feed/common/hooks/useReportFeed.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useToast } from '@sopt-makers/ui';
import { useCallback } from 'react';

import { usePostReportPostMutation } from '@/api/endpoint/feed/postReportPost';
import useAlert from '@/components/common/Modal/useAlert';
import useConfirm from '@/components/common/Modal/useConfirm';
import usePopup from '@/components/common/Modal/usePopup';
import { zIndex } from '@/styles/zIndex';

interface Options {
postId: string;
Expand All @@ -12,36 +12,39 @@ interface Options {

export const useReportFeed = () => {
const { confirm } = useConfirm();
const { alert } = useAlert();
const { mutate } = usePostReportPostMutation();
const { popup } = usePopup();
const { open } = useToast();

const handleReport = useCallback(
async (options: Options) => {
const result = await confirm({
title: '이 글을 신고하시겠습니까?',
description: '글을 신고할 경우, 메이커스에서 검토를 거쳐 적절한 조치 및 게시자 제재를 취해요.',
description: '글을 신고할 경우, 메이커스에서 검토를 거쳐 적절한 조치 및 게시자 제재를 취할 예정이에요.',
okButtonText: '신고하기',
cancelButtonText: '취소',
maxWidth: 324,
maxWidth: 400,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분은 코드 리뷰보다는 질문에 가까운데.. 이번에는 피그마에 있는 Dialog 디자인을 따르는게 아닌 기존의 Confirm 공동 컴포넌트를 활용한거일까요?! 약간의 차이가 있어서 노티남깁니다(closed버튼 등등). 만약 맞다면 나중에 mds 도입때 같이 처리하면 될 것 같아요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mds를 사용하지는 않았어요! 추후 mds로 같이 마이그레이션 할 필요는 있어 보입니다!
그리고 어떤 부분에서 디자인이 다를까요? 다른 점을 잘 못찾겠어서요,,,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 closed 버튼(x자 버튼 유무) 이나 line height같은게 조금 다른 부분이 저도 작업하다가 있더라고요!! mds를 사용하지 않았다면 나중에 같이 마이그레이션 하면 될 것 같아요 :)

zIndex: zIndex.헤더,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기 zIndex의 기준이 있을까요?! 번외로 저도 개발할때 똑같은 이슈가 있었는데, 한번 다같이 zIndex 기준을 정해야할 필요는 있어보입니다..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zIndex가 헤더보다 낮아서 헤더에 가려지더라구요,,, 그래서 일단 헤더와 같은 zIndex로 설정했습니다!

한번 다같이 zIndex 기준을 정해야할 필요는 있어보입니다..

그리고 이 의견에 동의합니다!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

z-index 위계를 한 번 쭉 정의내릴 필요는 있어보여요...! 저도 맨날 하나씩 확인해서 올리고 그랬어서...

});

if (result) {
mutate(options.postId, {
onSuccess: () => {
popup({
icon: '/icons/check_box_field.svg',
title: '신고해주셔서 감사해요',
description:
'메이커스에서 빠르게 검토 후 적절한 조치를 취할게요 :) 건전한 커뮤니티를 만드는데 기여해주셔서 감사해요!',
maxWidth: 324,
open({
icon: 'success',
content: '신고가 완료되었어요.\n건전한 커뮤니티를 함께 만들어주셔서 감사해요!',
style: {
content: {
whiteSpace: 'pre-wrap',
},
},
});

options.onSuccess?.();
},
});
}
},
[confirm, alert, mutate],
[confirm, open, mutate],
);

return { handleReport };
Expand Down
50 changes: 33 additions & 17 deletions src/components/feed/detail/FeedDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { colors } from '@sopt-makers/colors';
import { IconAlertTriangle, IconTrash, IconWrite } from '@sopt-makers/icons';
import { useQueryClient } from '@tanstack/react-query';
import { Flex } from '@toss/emotion-utils';
import { ErrorBoundary } from '@toss/error-boundary';
import Link from 'next/link';
import { playgroundLink } from 'playground-common/export';
Expand Down Expand Up @@ -75,30 +78,43 @@ const FeedDetail = ({ postId, renderCategoryLink, renderBackLink }: FeedDetailPr
}
>
{postData.isMine ? (
<Link href={playgroundLink.feedEdit(postId)}>
<FeedDropdown.Item>수정</FeedDropdown.Item>
</Link>
) : null}
{postData.isMine ? (
<>
<Link href={playgroundLink.feedEdit(postId)}>
<FeedDropdown.Item>
<Flex align='center' css={{ gap: '10px', color: `${colors.gray10} ` }}>
<IconWrite css={{ width: '16px', height: '16px' }} />
수정
</Flex>
</FeedDropdown.Item>
</Link>

<FeedDropdown.Item
type='danger'
onClick={(e) => {
e.stopPropagation();
handleDeleteFeed({ postId });
}}
>
<Flex align='center' css={{ gap: '10px' }}>
<IconTrash css={{ width: '16px', height: '16px' }} />
삭제
</Flex>
</FeedDropdown.Item>
</>
) : (
<FeedDropdown.Item
type='danger'
onClick={(e) => {
e.stopPropagation();
handleDeleteFeed({ postId });
handleReportFeed({ postId });
}}
>
삭제
<Flex align='center' css={{ gap: '10px', color: `${colors.gray10}` }}>
<IconAlertTriangle css={{ width: '16px', height: '16px' }} />
신고
</Flex>
</FeedDropdown.Item>
) : null}
<FeedDropdown.Item
type='danger'
onClick={(e) => {
e.stopPropagation();
handleReportFeed({ postId });
}}
>
신고
</FeedDropdown.Item>
)}
</FeedDropdown>
</>
}
Expand Down
25 changes: 20 additions & 5 deletions src/components/feed/list/FeedListItems.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import styled from '@emotion/styled';
import { colors } from '@sopt-makers/colors';
import { IconAlertTriangle, IconShare, IconTrash, IconWrite } from '@sopt-makers/icons';
import { useQuery } from '@tanstack/react-query';
import { Flex } from '@toss/emotion-utils';
import Link from 'next/link';
Expand Down Expand Up @@ -160,10 +161,16 @@ const FeedListItems: FC<FeedListItemsProps> = ({ categoryId, renderFeedDetailLin
<FeedCard.Icon name='moreHorizon' />
</Flex>
}
style={{ minWidth: '133px', position: 'relative', top: '10px', right: '52px' }}
>
{post.isMine ? (
<Link href={playgroundLink.feedEdit(post.id)}>
<FeedDropdown.Item>수정</FeedDropdown.Item>
<FeedDropdown.Item>
<Flex align='center' css={{ gap: '10px', color: `${colors.gray10} ` }}>
<IconWrite css={{ width: '16px', height: '16px' }} />
수정
</Flex>
</FeedDropdown.Item>
</Link>
) : null}
<LoggingClick eventKey='feedShareButton' param={{ feedId: String(post.id), referral: 'list' }}>
Expand All @@ -173,7 +180,10 @@ const FeedListItems: FC<FeedListItemsProps> = ({ categoryId, renderFeedDetailLin
handleShareFeed(`${post.id}`);
}}
>
공유
<Flex align='center' css={{ gap: '10px', color: `${colors.gray10}` }}>
<IconShare css={{ width: '16px', height: '16px' }} />
공유
</Flex>
</FeedDropdown.Item>
</LoggingClick>
{post.isMine ? (
Expand All @@ -189,18 +199,23 @@ const FeedListItems: FC<FeedListItemsProps> = ({ categoryId, renderFeedDetailLin
}}
type='danger'
>
삭제
<Flex align='center' css={{ gap: '10px' }}>
<IconTrash css={{ width: '16px', height: '16px' }} />
삭제
</Flex>
</FeedDropdown.Item>
) : null}
{!post.isMine ? (
<FeedDropdown.Item
type='danger'
onClick={(e) => {
e.stopPropagation();
handleReport({ postId: `${post.id}` });
}}
>
신고
<Flex align='center' css={{ gap: '10px', color: `${colors.gray10}` }}>
<IconAlertTriangle css={{ width: '16px', height: '16px' }} />
신고
</Flex>
</FeedDropdown.Item>
) : null}
</FeedDropdown>
Expand Down
Loading
Loading