Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
22 changes: 22 additions & 0 deletions src/api/activityLog.api.ts
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);
}
};
Copy link

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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 getMyComments = async () => {
try {
const response = await httpClient.get<ApiMyComments>(`user/my-comments`);
return response.data.data;
} catch (e) {
console.error('내 댓글 에러', e);
return [];
}
};


export const getMyInquiries = async () => {
try {
const response = await httpClient.get<ApiMyInquiries>(`user/my-inquiries`);

return response.data.data;
} catch (e) {
console.error('내 문의글 에러 ', e);
}
};
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

에러 발생 시 반환 값 처리가 필요합니다.

현재 getMyInquiries 함수는 에러 발생 시 아무 값도 반환하지 않습니다. 이로 인해 함수 호출 시 예상치 못한 동작이 발생할 수 있습니다. 에러 발생 시에도 일관된 반환 값을 제공하는 것이 좋습니다.

다음과 같이 수정해 주세요:

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const getMyInquiries = async () => {
try {
const response = await httpClient.get<ApiMyInquiries>(`user/my-inquiries`);
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);
return [];
}
};

2 changes: 1 addition & 1 deletion src/api/inquiry.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export const postInquiry = async (formData: FormData) => {
});
console.log(response);
} catch (e) {
console.log('문의하기 에러', e);
console.error('문의하기 에러', e);
}
};
6 changes: 3 additions & 3 deletions src/api/projectLists.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export const getProjectLists = async (params: SearchFilters) => {
params,
paramsSerializer: { indexes: null },
});

return response.data.data;
} catch (e) {
console.log('getProjectLists', e);
console.error('getProjectLists', e);
}
};

Expand All @@ -26,6 +26,6 @@ export const getProjectStatistic = async () => {

return response.data.data;
} catch (e) {
console.log('getProjectStatistic', e);
console.error('getProjectStatistic', e);
}
};
6 changes: 3 additions & 3 deletions src/api/projectSearchFiltering.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const getSkillTag = async () => {

return response.data.data;
} catch (e) {
console.log('getSkillTag', e);
console.error('getSkillTag', e);
}
};

Expand All @@ -16,7 +16,7 @@ export const getPositionTag = async () => {
const response = await httpClient.get<ApiPositionTag>('/position-tag');
return response.data.data;
} catch (e) {
console.log('getPositionTag', e);
console.error('getPositionTag', e);
}
};

Expand All @@ -25,6 +25,6 @@ export const getMethodTag = async () => {
const response = await httpClient.get<ApiMethodTag>('/method-type');
return response.data.data;
} catch (e) {
console.log('getMethodTag', e);
console.error('getMethodTag', e);
}
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from 'styled-components';

export const container = styled.div`
export const Container = styled.div`
height: 100%;
`;

Expand All @@ -9,3 +9,16 @@ export const WrapperNoContent = styled.div`
display: flex;
align-items: center;
`;

export const CommentsWrapper = styled.div`
padding: 1.5rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
`;

export const CommentBorder = styled.div`
width: 100%;
height: 0.5px;
background: ${({ theme }) => theme.color.placeholder};
`;
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
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

CommentWrapper 스타일 컴포넌트가 사용되지 않았습니다.

CommentActivity.styled.ts에 정의된 CommentWrapper 스타일 컴포넌트가 사용되지 않고 있습니다. Link 컴포넌트를 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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>
);
}
export default function CommentActivity({ list }: CommentActivityProps) {
return (
<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>
</S.CommentWrapper>
);
}

44 changes: 33 additions & 11 deletions src/components/mypage/activityLog/inquiries/Inquiries.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,41 @@ export const container = styled.div`
height: 100%;
`;

export const WrapperButton = styled.div`
height: 5%;
display: flex;
justify-content: end;
gap: 1rem;
export const InquiriesContainer = styled.div`
padding: 1rem;
width: 100%;
`;

export const InquiriesTableHeadWrapper = styled.div`
width: 100%;
display: grid;
grid-template-columns: 8% 18% 62% 12%;
font-size: 1.3rem;
font-weight: 600;
margin-bottom: 0.5rem;
`;

export const InquiriesTableHeaderNo = styled.div`
text-align: center;
`;

export const InquiriesTableHeaderCategory = styled.div`
padding-left: 0.5rem;
`;

export const InquiriesTableHeaderTitle = styled.div`
text-align: start;
padding-left: 3rem;
`;

export const Button = styled.button`
font-size: 1rem;
width: 5rem;
background: ${({ theme }) => theme.color.navy};
border-radius: ${({ theme }) => theme.borderRadius.primary};
color: ${({ theme }) => theme.color.white};
export const InquiriesTableHeaderState = styled.div`
text-align: center;
`;

export const InquiriesWrapper = styled.div`
display: flex;
flex-direction: column;
gap: 0.5rem;
`;

export const WrapperNoContent = styled.div`
Expand Down
41 changes: 38 additions & 3 deletions src/components/mypage/activityLog/inquiries/Inquiries.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,47 @@
import { useGetMyInquires } from '../../../../hooks/useGetMyInquires';
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();

if (isLoading) {
return <Spinner size='50px' color='#3e5879;' />;
}

if (!myCommentsData) return;

if (myCommentsData.length === 0)
return (
<S.WrapperNoContent>
<NoContent type='inquiries' />
<NoContent type='comment' />
</S.WrapperNoContent>
);

myCommentsData.map(console.log);

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}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

더 안정적인 키 값이 필요합니다.

리스트의 keylist.title을 사용하는 것은 제목이 중복될 경우 문제가 될 수 있습니다. list.id와 같은 고유 식별자를 사용하는 것이 더 안정적입니다.

            <Inquiry
-              key={list.title}
+              key={list.id}
              list={list}
              no={myCommentsData.length - index}
            />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
key={list.title}
<Inquiry
key={list.id}
list={list}
no={myCommentsData.length - index}
/>

list={list}
no={myCommentsData.length - index}
/>
))}
</S.InquiriesWrapper>
</S.InquiriesContainer>
</S.container>
);
}
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``;
Loading
Loading