-
Notifications
You must be signed in to change notification settings - Fork 0
신고하기 구현 및 토스트 구현 (issue #254, issue #253, issue #236) #260
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
Merged
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
148b0b1
feat : 실시간 알림 데이터를 위한 Toast 띄우기
layout-SY 90a8c62
Merge branch 'develop' of https://github.com/devpalsPlus/frontend int…
layout-SY bab50a1
Merge branch 'develop' of https://github.com/devpalsPlus/frontend int…
layout-SY 3572213
style : 공고 상세 페이지 댓글 부분 하단에 여유 공간 추가
layout-SY 3c34e1e
feat : 신고하기 구현(API 미적용)
layout-SY 9abf6c2
fix : content 길이가 문단을 넘어가면 들여쓰기가 적용되지 않는 문제 해결
layout-SY 645108b
feat : 댓글이 없을 경우 추가
layout-SY b3a79c1
feat : 유저, 댓글/대댓글 등에 따른 신고 인터페이스 변경
layout-SY 0ad9c87
feat : 신고 후 모달 닫기
layout-SY 02db193
feat : 헤더의 알림 조회 스크롤 추가
layout-SY c5727fa
feat : 토스트 구현
layout-SY 80f0aae
fix : 빌드 에러 수정
layout-SY 1d18d2f
refactor : 타입 정리
layout-SY ee8e78e
refactor : 코드 리뷰 사항 적용
layout-SY 962152c
refactor : 파일 위치 변경
layout-SY bb0f4c2
feat : 실시간 알림 타입 토스트에 적용 및 토스트 알림에 route 추가
layout-SY 2310dc8
feat : 헤더 전체 알림에 route 추가
layout-SY 33e2a95
feat : 실시간 알림 타입 생성
layout-SY 51065f6
refactor : 코드 리뷰 수정 사항 반영
layout-SY a9b6503
refactor : 형준님 리뷰 사항 반영
layout-SY aafb853
feat : 현재 시간과 비교하여 알림 지난 시간 표시
layout-SY eb35eac
refactor : 토스트 테스트 버튼 삭제
layout-SY File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { ApiPostContent } from '../models/report'; | ||
| import { httpClient } from './http.api'; | ||
|
|
||
| export const postReport = async (formData: ApiPostContent) => { | ||
| try { | ||
| const response = await httpClient.post(`/report`, formData); | ||
| if (response.status !== 200) { | ||
| throw new Error(`${response.status}`); | ||
| } | ||
| return response.status; | ||
| } catch (error) { | ||
| console.error(error); | ||
| throw error; | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import useDeleteComment from '../../hooks/CommentHooks/useDeleteComment'; | ||
| import useDeleteReply from '../../hooks/CommentHooks/useDeleteReply'; | ||
| import { useModal } from '../../hooks/useModal'; | ||
| import ReportModal from '../reportComponent/ReportModal'; | ||
| import * as S from './DropDownItem.styled'; | ||
|
|
||
| interface DropdownProps { | ||
| projectId: number; | ||
| activateEditMode?: number | null; | ||
| commentId: number; | ||
| recommentId?: number; | ||
| loginUserId?: number; | ||
| commentUserId: number; | ||
| reportTitle: { userImg: string; userName: string } | string; | ||
| reply?: boolean; | ||
| onEdit?: () => void; | ||
| } | ||
|
|
||
| const DropDownItem = ({ | ||
| projectId, | ||
| onEdit, | ||
| activateEditMode, | ||
| commentId, | ||
| recommentId, | ||
| commentUserId, | ||
| loginUserId, | ||
| reply, | ||
| reportTitle, | ||
| }: DropdownProps) => { | ||
| const { removeComment } = useDeleteComment(projectId); | ||
| const { removeReply } = useDeleteReply(commentId, projectId); | ||
| const { isOpen, handleOpenReportModal, handleCloseReportModal } = useModal(); | ||
|
|
||
| const onDelete = (commentId: number, recommentId?: number) => { | ||
| if (reply && recommentId) { | ||
| if (confirm('답글을 완성히 삭제할까요?')) removeReply(recommentId); | ||
| } else { | ||
| if (confirm('댓글을 완성히 삭제할까요?')) removeComment(commentId); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <S.Container> | ||
| <S.Item onClick={handleOpenReportModal}>신고하기</S.Item> | ||
|
|
||
| {loginUserId === commentUserId && ( | ||
| <> | ||
| <S.Item onClick={onEdit}> | ||
| {activateEditMode === commentId ? '수정 취소하기' : '수정하기'} | ||
| </S.Item> | ||
| <S.Item onClick={() => onDelete(commentId, recommentId)}> | ||
| 삭제하기 | ||
| </S.Item>{' '} | ||
| </> | ||
| )} | ||
| </S.Container> | ||
| {isOpen && ( | ||
| <ReportModal | ||
| reportTitle={reportTitle} | ||
| targetId={recommentId ? recommentId : commentId} | ||
| type={recommentId ? 'recomment' : 'comment'} | ||
| onClose={handleCloseReportModal} | ||
| /> | ||
| )} | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default DropDownItem; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import styled, { keyframes } from 'styled-components'; | ||
|
|
||
| const fadeInUp = keyframes` | ||
| from { opacity: 0; transform: translateY(20px); } | ||
| to { opacity: 1; transform: translateY(0); } | ||
| `; | ||
| const fadeOut = keyframes` | ||
| from { opacity: 1; } | ||
| to { opacity: 0; } | ||
| `; | ||
|
|
||
| export const Container = styled.div` | ||
| position: fixed; | ||
| width: 330px; | ||
| bottom: 30px; | ||
| right: 30px; | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 8px; | ||
| z-index: 1000; | ||
| `; | ||
|
|
||
| export const Item = styled.div<{ $exiting: boolean }>` | ||
| background-color: ${({ theme }) => theme.buttonScheme.grey.color}; | ||
| padding: 12px 20px; | ||
| border-radius: ${({ theme }) => theme.borderRadius.small}; | ||
| animation: ${fadeInUp} 0.3s ease-out, | ||
| ${({ $exiting }) => $exiting && fadeOut} 0.3s ease-in forwards; | ||
| `; | ||
|
|
||
| export const LiveMessage = styled.p` | ||
| color: ${({ theme }) => theme.color.white}; | ||
| font-size: 0.95rem; | ||
| white-space: nowrap; | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| `; | ||
|
|
||
| export const LiveDate = styled.p` | ||
| color: ${({ theme }) => theme.color.white}; | ||
| font-size: 0.95rem; | ||
| white-space: nowrap; | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { createPortal } from 'react-dom'; | ||
| import { ToastMessage } from '../../../context/ToastContext'; | ||
| import ToastItem from './ToastItem'; | ||
| import * as S from './Toast.styled'; | ||
|
|
||
| interface ToastContainerProps { | ||
| toasts: ToastMessage[]; | ||
| onRemove: (id: string) => void; | ||
| } | ||
|
|
||
| const ToastContainer = ({ toasts, onRemove }: ToastContainerProps) => { | ||
| return createPortal( | ||
| <S.Container> | ||
| {toasts.map((toast) => ( | ||
| <ToastItem | ||
| key={toast.id} | ||
| {...toast} | ||
| onRemove={() => onRemove(toast.id)} | ||
| /> | ||
| ))} | ||
| </S.Container>, | ||
| document.body | ||
| ); | ||
| }; | ||
|
|
||
| export default ToastContainer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { useEffect, useState } from 'react'; | ||
| import * as S from './Toast.styled'; | ||
| import { AlarmLive } from '../../../models/alarm'; | ||
| import { Link } from 'react-router-dom'; | ||
| import { routeSelector } from '../../../util/routeSelector'; | ||
|
|
||
| interface ToastItemProps { | ||
| id: string; | ||
| content: AlarmLive; | ||
| duration: number; | ||
| onRemove: () => void; | ||
| } | ||
|
|
||
| const ToastItem = ({ content, duration, onRemove }: ToastItemProps) => { | ||
| const [exiting, setExiting] = useState(false); | ||
| const route = routeSelector(content.routingId, content.alarmFilterId); | ||
|
|
||
| useEffect(() => { | ||
| const timer = setTimeout(() => setExiting(true), duration); | ||
| return () => clearTimeout(timer); | ||
| }, [duration]); | ||
|
|
||
| const handleAnimationEnd = () => { | ||
| if (exiting) onRemove(); | ||
| }; | ||
|
|
||
| return ( | ||
| <Link to={route}> | ||
| <S.Item $exiting={exiting} onAnimationEnd={handleAnimationEnd}> | ||
| <S.LiveMessage>{content.message}</S.LiveMessage> | ||
| <S.LiveDate>{content.createAt}</S.LiveDate> | ||
| </S.Item> | ||
| </Link> | ||
| ); | ||
| }; | ||
|
|
||
| export default ToastItem; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
QueryErroBoundary를 통해서 에러나는 경우 감지하여 FallbackUI를 보여주게 되는데, ErrorMessage를 작성하신 이유가 궁금합니다!Uh oh!
There was an error while loading. Please reload this page.
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.
생각을 못했네요. 제외 하겠습니다.