-
Notifications
You must be signed in to change notification settings - Fork 2
fix: 자잘한 이슈 수정 #86
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
fix: 자잘한 이슈 수정 #86
Changes from all commits
bfcebf2
92acb37
262c85b
81828a7
69cbecd
03a1eec
c222cb6
74c30f7
28518f1
b0a8097
68531c7
f9930bc
1077e8e
d1a078c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,69 +25,85 @@ const LetterBoardDetailPage = ({ confirmDisabled }: ShareLetterPreviewProps) => | |
| const [isLike, setIsLike] = useState(false); | ||
| const isWriter = false; | ||
| const [activeReportModal, setActiveReportModal] = useState(false); | ||
| const sharePostId: string = location.pathname.split('/')[3]; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오잉 데이터가 어떻게 넘어오는진 모르겠지만 문자열을 split해서 배열로 만드시네용 백엔드분이 데이터를 보내주실때 그렇게 받아지는건가용?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아니면 params로 값을 출력하는 방식이 아니라 url path에서 아이디값을 저렇게 가져오고 계신건가용? |
||
| // const location = useLocation(); | ||
| const navigate = useNavigate(); | ||
| // const isShareLetterPreview = location.state?.isShareLetterPreview || false; | ||
| const isShareLetterPreview = false; | ||
| const [postDetail, setPostDetail] = useState<SharePost>(); | ||
|
|
||
| const postLike = async () => { | ||
| try { | ||
| const response = await postSharePostLike(sharePostId); | ||
| if (!response) throw new Error('error while fetching like count'); | ||
| console.log('✅ 편지 좋아요 추가됨:', response); | ||
| } catch (error) { | ||
| console.error('❌ 편지 좋아요 추가 중 에러가 발생했습니다', error); | ||
| throw new Error('편지 좋아요 추가 실패'); | ||
| } | ||
| }; | ||
|
|
||
| const handleToggleLike = () => { | ||
| setLikeCount((prev) => prev + (isLike ? -1 : 1)); | ||
| setIsLike((prev) => !prev); | ||
| postLike(); | ||
| }; | ||
|
|
||
| const location = useLocation(); | ||
| const navigate = useNavigate(); | ||
| const handleProposalApproval = async ( | ||
| action: 'approve' | 'reject', | ||
| shareProposalId: number = location.state?.postDetail?.sharePostId, | ||
| ) => { | ||
| try { | ||
| const result = await postShareProposalApproval(shareProposalId, action); | ||
| console.log(`✅ 편지 공유 ${action === 'approve' ? '수락' : '거절'}됨:`, result); | ||
|
|
||
| const isShareLetterPreview = location.state?.isShareLetterPreview || false; | ||
| const [postDetail, setPostDetail] = useState<SharePost>(); | ||
| navigate('/'); | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| const { sharePostId } = location.state.postDetail; | ||
| const fetchPostDetail = async (postId: number) => { | ||
| const fetchPostDetail = async (postId: string) => { | ||
| try { | ||
| console.log('sharePostId:', postId); | ||
|
|
||
| const data = await getSharePostDetail(postId); | ||
|
|
||
| setPostDetail(data); | ||
| } catch (error) { | ||
| console.error('❌ 공유 게시글 상세 조회에 실패했습니다.', error); | ||
| } | ||
| }; | ||
|
|
||
| const fetchLikeCounts = async (postId: number) => { | ||
| const fetchLikeCounts = async (postId: string) => { | ||
| try { | ||
| const response = await getSharePostLikeCount(postId); | ||
| if (!response) throw new Error('error while fetching like count'); | ||
| console.log(response); | ||
| setLikeCount(response.data.likeCount); | ||
| console.log('✅ 편지 좋아요 갯수:', response); | ||
| setLikeCount(response.likeCount); | ||
| setIsLike(response.liked); | ||
| } catch (error) { | ||
| console.error('❌ 편지 좋아요 갯수를 가져오는 중 에러가 발생했습니다', error); | ||
| throw new Error('편지 좋아요 갯수 가져오기 실패'); | ||
| } | ||
| }; | ||
|
|
||
| if (location.state?.postDetail) { | ||
| fetchPostDetail(sharePostId); | ||
| fetchLikeCounts(sharePostId); | ||
| } else { | ||
| console.warn('postDetail not found in location.state'); | ||
| } | ||
| }, [location.state]); | ||
|
|
||
| const handleProposalApproval = async ( | ||
| action: 'approve' | 'reject', | ||
| shareProposalId: number = location.state?.postDetail?.sharePostId, | ||
| ) => { | ||
| try { | ||
| const result = await postShareProposalApproval(shareProposalId, action); | ||
| console.log(`✅ 편지 공유 ${action === 'approve' ? '수락' : '거절'}됨:`, result); | ||
|
|
||
| navigate('/'); | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
| // if (location.state?.postDetail) { | ||
| fetchPostDetail(sharePostId); | ||
| fetchLikeCounts(sharePostId); | ||
| // } else { | ||
| // console.warn('postDetail not found in location.state'); | ||
| // } | ||
| // }, [location.state]); | ||
| }, []); | ||
|
|
||
| return ( | ||
| <> | ||
| {activeReportModal && <ReportModal onClose={() => setActiveReportModal(false)} />} | ||
| {activeReportModal && ( | ||
| <ReportModal | ||
| reportType="POST" | ||
| letterId={parseInt(sharePostId)} | ||
| onClose={() => setActiveReportModal(false)} | ||
| /> | ||
| )} | ||
| <div className="grow bg-white"> | ||
| <Header | ||
| likeCount={likeCount} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
감사합니당 ㅎㅎ