-
Notifications
You must be signed in to change notification settings - Fork 0
활동기록 구현 (#issue 261) #264
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
활동기록 구현 (#issue 261) #264
Changes from 2 commits
3674231
ec49b2f
e68aaed
68ef2e0
0808209
3e4632c
f8a38d2
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 | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||||||||||||||||||||||||||||||||||||
| import type { ApiMyComments, ApiMyInquiries } from './../models/activityLog'; | ||||||||||||||||||||||||||||||||||||||||
| import { httpClient } from './http.api'; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| export const getMyComments = async () => { | ||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||
| const response = await httpClient.get<ApiMyComments>(`user/my-comments`); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| return response.data.data; | ||||||||||||||||||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||||||||||||||||||
| console.error('내 댓글 에러', e); | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| export const getMyInquiries = async () => { | ||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||
| const response = await httpClient.get<ApiMyInquiries>(`user/my-inquiries`); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| return response.data.data; | ||||||||||||||||||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||||||||||||||||||
| console.error('내 문의글 에러 ', e); | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||
|
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. 🛠️ Refactor suggestion 에러 발생 시 반환 값 처리가 필요합니다. 현재 다음과 같이 수정해 주세요: export const getMyInquiries = async () => {
try {
const response = await httpClient.get<ApiMyInquiries>(`user/my-inquiries`);
return response.data.data;
} catch (e) {
console.error('내 문의글 에러 ', e);
+ return [];
}
};📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,39 @@ | ||
| import { Fragment } from 'react/jsx-runtime'; | ||
| import { useGetMyComments } from '../../../../hooks/useGetMyComments'; | ||
| import NoContent from '../../../common/noContent/NoContent'; | ||
| import Spinner from '../../Spinner'; | ||
| import CommentActivity from './commentActivity/CommentActivity'; | ||
| import * as S from './CommentsActivity.styled'; | ||
|
|
||
| export default function CommentsActivity() { | ||
| return ( | ||
| <S.container> | ||
| const { myCommentsData, isLoading } = useGetMyComments(); | ||
|
|
||
| if (isLoading) { | ||
| return <Spinner size='50px' color='#3e5879;' />; | ||
| } | ||
|
|
||
| if (!myCommentsData) return; | ||
|
|
||
| if (myCommentsData.length === 0) { | ||
| return ( | ||
| <S.WrapperNoContent> | ||
| <NoContent type='comment' /> | ||
| </S.WrapperNoContent> | ||
| </S.container> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <S.Container> | ||
| <S.CommentsWrapper> | ||
| {myCommentsData.map((list, idx: number) => ( | ||
| <Fragment key={list.id}> | ||
| <CommentActivity list={list} /> | ||
| {idx !== myCommentsData.length - 1 && ( | ||
| <S.CommentBorder></S.CommentBorder> | ||
| )} | ||
| </Fragment> | ||
| ))} | ||
| </S.CommentsWrapper> | ||
| </S.Container> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import styled from 'styled-components'; | ||
|
|
||
| export const CommentWrapper = styled.div` | ||
| cursor: pointer; | ||
| `; | ||
|
|
||
| export const CommentContent = styled.div``; | ||
|
|
||
| export const CommentDate = styled.div` | ||
| font-size: 0.8rem; | ||
| color: ${({ theme }) => theme.color.placeholder}; | ||
| `; | ||
|
|
||
| export const CommentProject = styled.div` | ||
| font-size: 0.9rem; | ||
| `; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||||||||||||||||||||||||||||||||||||||
| import { Link } from 'react-router-dom'; | ||||||||||||||||||||||||||||||||||||||||||
| import type { MyComments } from '../../../../../models/activityLog'; | ||||||||||||||||||||||||||||||||||||||||||
| import * as S from './CommentActivity.styled'; | ||||||||||||||||||||||||||||||||||||||||||
| import { formatDate } from '../../../../../util/formatDate'; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| interface CommentActivityProps { | ||||||||||||||||||||||||||||||||||||||||||
| list: MyComments; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| export default function CommentActivity({ list }: CommentActivityProps) { | ||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||
| <Link to={`/project-detail/${list.projectId}`}> | ||||||||||||||||||||||||||||||||||||||||||
| <S.CommentContent>{list.content}</S.CommentContent> | ||||||||||||||||||||||||||||||||||||||||||
| <S.CommentDate>{formatDate(list.createdAt)}</S.CommentDate> | ||||||||||||||||||||||||||||||||||||||||||
| <S.CommentProject>{list.projectTitle}</S.CommentProject> | ||||||||||||||||||||||||||||||||||||||||||
| </Link> | ||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+10
to
+18
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. 🛠️ Refactor suggestion CommentWrapper 스타일 컴포넌트가 사용되지 않았습니다.
export default function CommentActivity({ list }: CommentActivityProps) {
return (
- <Link to={`/project-detail/${list.projectId}`}>
+ <S.CommentWrapper>
+ <Link to={`/project-detail/${list.projectId}`}>
<S.CommentContent>{list.content}</S.CommentContent>
<S.CommentDate>{formatDate(list.createdAt)}</S.CommentDate>
<S.CommentProject>{list.projectTitle}</S.CommentProject>
- </Link>
+ </Link>
+ </S.CommentWrapper>
);
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,12 +1,47 @@ | ||||||||||||||
| import { useGetMyInquires } from '../../../../hooks/useGetMyInquires'; | ||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
| import NoContent from '../../../common/noContent/NoContent'; | ||||||||||||||
| import Spinner from '../../Spinner'; | ||||||||||||||
| import * as S from './Inquiries.styled'; | ||||||||||||||
| import Inquiry from './inquiry/Inquiry'; | ||||||||||||||
|
|
||||||||||||||
| export default function Inquiries() { | ||||||||||||||
| return ( | ||||||||||||||
| <S.container> | ||||||||||||||
| const { myCommentsData, isLoading } = useGetMyInquires(); | ||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| if (isLoading) { | ||||||||||||||
| return <Spinner size='50px' color='#3e5879;' />; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if (!myCommentsData) return; | ||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| if (myCommentsData.length === 0) | ||||||||||||||
| return ( | ||||||||||||||
| <S.WrapperNoContent> | ||||||||||||||
| <NoContent type='inquiries' /> | ||||||||||||||
| <NoContent type='comment' /> | ||||||||||||||
| </S.WrapperNoContent> | ||||||||||||||
| ); | ||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| myCommentsData.map(console.log); | ||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| return ( | ||||||||||||||
| <S.container> | ||||||||||||||
| <S.InquiriesContainer> | ||||||||||||||
| <S.InquiriesTableHeadWrapper> | ||||||||||||||
| <S.InquiriesTableHeaderNo>No</S.InquiriesTableHeaderNo> | ||||||||||||||
| <S.InquiriesTableHeaderCategory>구별</S.InquiriesTableHeaderCategory> | ||||||||||||||
| <S.InquiriesTableHeaderTitle>제목</S.InquiriesTableHeaderTitle> | ||||||||||||||
| <S.InquiriesTableHeaderState>상태</S.InquiriesTableHeaderState> | ||||||||||||||
| </S.InquiriesTableHeadWrapper> | ||||||||||||||
| <S.InquiriesWrapper> | ||||||||||||||
| {myCommentsData.length > 0 && | ||||||||||||||
| myCommentsData.map((list, index) => ( | ||||||||||||||
| <Inquiry | ||||||||||||||
| key={list.title} | ||||||||||||||
|
||||||||||||||
| key={list.title} | |
| <Inquiry | |
| key={list.id} | |
| list={list} | |
| no={myCommentsData.length - index} | |
| /> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import styled from 'styled-components'; | ||
|
|
||
| export const Container = styled.div` | ||
| width: 100%; | ||
| font-size: 1.1rem; | ||
| `; | ||
|
|
||
| export const InquiryTitleWrapper = styled.div` | ||
| display: grid; | ||
| grid-template-columns: 8% 18% 62% 12%; | ||
| cursor: pointer; | ||
| `; | ||
|
|
||
| export const InquiryNumber = styled.div` | ||
| text-align: center; | ||
| `; | ||
|
|
||
| export const InquiryCategory = styled.div``; | ||
|
|
||
| export const InquiryTitle = styled.div``; | ||
|
|
||
| export const InquiryState = styled.div` | ||
| text-align: center; | ||
| `; | ||
|
|
||
| export const InquiryContentWrapper = styled.div` | ||
| margin: 0.5rem 0; | ||
| background: ${({ theme }) => theme.color.white}; | ||
| padding: 1rem; | ||
| `; | ||
|
|
||
| export const InquiryContent = styled.div``; | ||
|
|
||
| export const InquiryImgWrapper = styled.div` | ||
| margin-top: 1rem; | ||
| cursor: pointer; | ||
| `; | ||
|
|
||
| export const InquiryModalImgWrapper = styled.div` | ||
| display: flex; | ||
| `; | ||
|
|
||
| export const InquiryImg = styled.img` | ||
| width: 5rem; | ||
| `; | ||
|
|
||
| export const ModalImgContainer = styled.div` | ||
| position: fixed; | ||
| top: 0; | ||
| left: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| width: 100vw; | ||
| height: 100vh; | ||
| z-index: 10; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| background: rgba(0, 0, 0, 0.7); | ||
| `; | ||
|
|
||
| export const ModalImgWrapper = styled.div` | ||
| margin-top: 1rem; | ||
| cursor: pointer; | ||
| background: ${({ theme }) => theme.color.white}; | ||
| border: 1px solid ${({ theme }) => theme.color.navy}; | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: center; | ||
| align-items: center; | ||
| width: fit-content; | ||
| `; | ||
|
|
||
| export const ModalImgButtonWrapper = styled.div` | ||
| width: 100%; | ||
| color: ${({ theme }) => theme.color.white}; | ||
| font-size: 0.8rem; | ||
| background: ${({ theme }) => theme.color.navy}; | ||
| padding: 0.2rem; | ||
| `; | ||
|
|
||
| export const ModalImg = styled.img``; |
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.
🛠️ Refactor suggestion
에러 발생 시 반환 값 처리가 필요합니다.
현재
getMyComments함수는 에러 발생 시 아무 값도 반환하지 않습니다. 이로 인해 함수 호출 시 예상치 못한 동작이 발생할 수 있습니다. 에러 발생 시에도 일관된 반환 값을 제공하는 것이 좋습니다.다음과 같이 수정해 주세요:
export const getMyComments = async () => { try { const response = await httpClient.get<ApiMyComments>(`user/my-comments`); return response.data.data; } catch (e) { console.error('내 댓글 에러', e); + return []; } };📝 Committable suggestion