Skip to content

Commit b33b576

Browse files
authored
fix: 롤링페이퍼 QA 반영 (#120)
* fix: 롤링페이퍼 QA 반영 - 신고 모달 추가 - 글자 길어질 때 줄바꿈이 생기지 않는 문제 발생 - 신고 버튼 추가 - 금칙어로 인한 에러 메시지 추가 * fix: 어드민 금칙어 에러 반영 * fix: 랜딩페이지 설명 순서 변경
1 parent 5fd9543 commit b33b576

File tree

6 files changed

+62
-25
lines changed

6 files changed

+62
-25
lines changed

src/pages/Admin/components/AddRollingPaperModal.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ChangeEvent, FormEvent, useState } from 'react';
33

44
import { postNewRollingPaper } from '@/apis/rolling';
55
import ModalOverlay from '@/components/ModalOverlay';
6+
import { AxiosError } from 'axios';
67

78
interface AddRollingPaperModalProps {
89
currentPage: number | string;
@@ -22,8 +23,12 @@ export default function AddRollingPaperModal({ currentPage, onClose }: AddRollin
2223
onClose();
2324
queryClient.invalidateQueries({ queryKey: ['admin-rolling-paper', currentPage] });
2425
},
25-
onError: () => {
26-
setError('편지 작성에 실패했어요. 다시 시도해주세요.');
26+
onError: (err: AxiosError<{ code: string; message: string }>) => {
27+
if (err.response?.data.code === 'MOD-003') {
28+
setError('금칙어가 포함되어 있어요. 다시 작성해주세요.');
29+
} else {
30+
setError('편지 작성에 실패했어요. 다시 시도해주세요.');
31+
}
2732
},
2833
});
2934

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
export const STYLE_CLASS = [
22
{
3-
imagePosition: 'left-[calc(50%-200px)]',
4-
mask: 'bottom-26 left-[calc(50%+65px)]',
5-
circle: 'h-41 w-41',
6-
textPosition: '-top-20 left-[calc(50%-30px)] text-right',
3+
imagePosition: 'left-[calc(50%+130px)]',
4+
mask: 'bottom-8 left-[calc(50%)]',
5+
circle: 'h-65 w-65',
6+
textPosition: '-top-14 left-1/2 text-center',
77
description:
8-
'따뜻한 편지 사례들을 모아 볼 수 있어요.\n응원이 필요한 사람들에게\n단체로 롤링페이퍼를 쓸 수도 있습니다.',
8+
'모르는 사람에게 고민을 털어 놓아 보세요.\n다른 사람에게도 위로, 응원, 축하를 보낼 수 있어요.',
99
},
1010
{
1111
imagePosition: 'left-[calc(50%-200px)]',
@@ -15,11 +15,11 @@ export const STYLE_CLASS = [
1515
description: '주고받은 편지 내역을 확인해 보세요.\n보는 것 만으로도 마음이 따뜻해집니다.',
1616
},
1717
{
18-
imagePosition: 'left-[calc(50%+130px)]',
19-
mask: 'bottom-8 left-[calc(50%)]',
20-
circle: 'h-65 w-65',
21-
textPosition: '-top-14 left-1/2 text-center',
18+
imagePosition: 'left-[calc(50%-200px)]',
19+
mask: 'bottom-26 left-[calc(50%+65px)]',
20+
circle: 'h-41 w-41',
21+
textPosition: '-top-20 left-[calc(50%-30px)] text-right',
2222
description:
23-
'모르는 사람에게 고민을 털어 놓아 보세요.\n다른 사람에게도 위로, 응원, 축하를 보낼 수 있어요.',
23+
'따뜻한 편지 사례들을 모아 볼 수 있어요.\n응원이 필요한 사람들에게\n단체로 롤링페이퍼를 쓸 수도 있습니다.',
2424
},
2525
];

src/pages/RollingPaper/components/Comment.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const Comment = ({ comment, onClick }: CommentProps) => {
99
return (
1010
<MemoWrapper className="cursor-pointer text-black" onClick={onClick}>
1111
<div className="z-1 h-full w-full">
12-
<p className="caption-r whitespace-pre-wrap">{comment.content}</p>
12+
<p className="caption-r break-all whitespace-pre-wrap">{comment.content}</p>
1313
<p className="caption-m mt-1 place-self-end">From. {comment.zipCode}</p>
1414
</div>
1515
</MemoWrapper>

src/pages/RollingPaper/components/CommentDetailModal.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,31 @@ interface CommentDetailModalProps {
66
isWriter: boolean;
77
onClose: () => void;
88
onDelete: () => void;
9+
onReport: () => void;
910
}
1011

11-
const CommentDetailModal = ({ comment, isWriter, onClose, onDelete }: CommentDetailModalProps) => {
12+
const CommentDetailModal = ({
13+
comment,
14+
isWriter,
15+
onClose,
16+
onDelete,
17+
onReport,
18+
}: CommentDetailModalProps) => {
19+
const handleButtonClick = () => {
20+
if (isWriter) onDelete();
21+
else onReport();
22+
};
23+
1224
return (
1325
<ModalOverlay closeOnOutsideClick onClose={onClose}>
1426
<>
15-
{isWriter && (
16-
<button type="button" className="body-b ml-auto text-white" onClick={onDelete}>
17-
삭제하기
18-
</button>
19-
)}
27+
<button type="button" className="body-b ml-auto text-white" onClick={handleButtonClick}>
28+
{isWriter ? '삭제하기' : '신고하기'}
29+
</button>
2030

2131
<MemoWrapper className="mt-1 flex max-h-1/2 w-78 overflow-y-auto px-5 text-black">
2232
<div className="z-1 flex flex-col gap-3">
23-
<p className="body-r leading-[26px] whitespace-pre-wrap">{comment.content}</p>
33+
<p className="body-r leading-[26px] break-all whitespace-pre-wrap">{comment.content}</p>
2434
<p className="body-m place-self-end">From. {comment.zipCode}</p>
2535
</div>
2636
</MemoWrapper>

src/pages/RollingPaper/components/WriteCommentButton.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { useMutation, useQueryClient } from '@tanstack/react-query';
2-
import { useState } from 'react';
2+
import { useEffect, useState } from 'react';
33

44
import { postRollingPaperComment } from '@/apis/rolling';
55
import EnvelopeImg from '@/assets/images/closed-letter.png';
66
import MessageModal from '@/components/MessageModal';
77
import useAuthStore from '@/stores/authStore';
8+
import { AxiosError } from 'axios';
89

910
interface WriteCommentButtonProps {
1011
rollingPaperId: string;
@@ -25,8 +26,12 @@ const WriteCommentButton = ({ rollingPaperId }: WriteCommentButtonProps) => {
2526
setError(null);
2627
setActiveMessageModal(false);
2728
},
28-
onError: () => {
29-
setError('편지 작성에 실패했어요. 다시 시도해주세요.');
29+
onError: (err: AxiosError<{ code: string; message: string }>) => {
30+
if (err.response?.data.code === 'MOD-003') {
31+
setError('금칙어가 포함되어 있어요. 다시 작성해주세요.');
32+
} else {
33+
setError('편지 작성에 실패했어요. 다시 시도해주세요.');
34+
}
3035
},
3136
});
3237

@@ -44,6 +49,10 @@ const WriteCommentButton = ({ rollingPaperId }: WriteCommentButtonProps) => {
4449
mutate(newMessage.trim());
4550
};
4651

52+
useEffect(() => {
53+
setError(null);
54+
}, [activeMessageModal]);
55+
4756
return (
4857
<>
4958
{activeMessageModal && (
@@ -62,7 +71,7 @@ const WriteCommentButton = ({ rollingPaperId }: WriteCommentButtonProps) => {
6271
)}
6372
<button
6473
type="button"
65-
className="sticky bottom-8 z-10 mt-4 -mb-4 self-start overflow-hidden rounded-sm"
74+
className="sticky bottom-8 z-10 mt-auto -mb-4 self-start overflow-hidden rounded-sm"
6675
onClick={() => setActiveMessageModal(true)}
6776
>
6877
<img src={EnvelopeImg} alt="편지지 이미지" className="h-12 w-auto opacity-70" />

src/pages/RollingPaper/index.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Comment from './components/Comment';
1414
import CommentDetailModal from './components/CommentDetailModal';
1515
import WriteCommentButton from './components/WriteCommentButton';
1616
import useAuthStore from '@/stores/authStore';
17+
import ReportModal from '@/components/ReportModal';
1718

1819
const MESSAGE_SIZE = 10;
1920

@@ -22,6 +23,7 @@ const RollingPaperPage = () => {
2223
const [activeComment, setActiveComment] = useState<RollingPaperComment | null>(null);
2324
const [activeDetailModal, setActiveDetailModal] = useState(false);
2425
const [activeDeleteModal, setActiveDeleteModal] = useState(false);
26+
const [activeReportModal, setActiveReportModal] = useState(false);
2527
const zipCode = useAuthStore((props) => props.zipCode);
2628
const queryClient = useQueryClient();
2729

@@ -69,6 +71,17 @@ const RollingPaperPage = () => {
6971
setActiveDetailModal(false);
7072
setActiveDeleteModal(true);
7173
}}
74+
onReport={() => {
75+
setActiveDetailModal(false);
76+
setActiveReportModal(true);
77+
}}
78+
/>
79+
)}
80+
{activeReportModal && (
81+
<ReportModal
82+
reportType="EVENT_COMMENT"
83+
letterId={Number(activeComment?.commentId)}
84+
onClose={() => setActiveReportModal(false)}
7285
/>
7386
)}
7487
{activeDeleteModal && (
@@ -90,7 +103,7 @@ const RollingPaperPage = () => {
90103
<main className="z-1 flex grow flex-col items-center px-5 pt-20 pb-12">
91104
<PageTitle className="mb-18 max-w-73 text-center">{title}</PageTitle>
92105
<p className="body-sb text-gray-60 mb-2 w-full">등록된 편지 {totalComments}</p>
93-
<section className="w-full">
106+
<section className="mb-4 w-full">
94107
<MasonryInfiniteGrid column={2} align="stretch" gap={16} onRequestAppend={handleLoadMore}>
95108
{isSuccess &&
96109
allComments.map((comment) => (

0 commit comments

Comments
 (0)