Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ff9d3f5
Squashed commit of the following:
yulrang Nov 11, 2024
bc4056a
[WIP] Feat: GetCrewList API 연결
yulrang Nov 11, 2024
6ac757f
Merge branch 'develop' into Feat/98/CrewAPI
yulrang Nov 11, 2024
0936ad1
✨ Feat: 백엔드 api 연결
yulrang Nov 11, 2024
e64877f
🐛 Fix: 처음 로딩시 카테고리 초기화
yulrang Nov 11, 2024
ab7d7a9
🐛 Fix: 카테고리 동작 개선
yulrang Nov 12, 2024
b4a70ff
🐛 Fix: 지역 필터링 동작 개선
yulrang Nov 12, 2024
22f3307
✨ Feat: 지역 전체 필터 추가
yulrang Nov 12, 2024
60a3b12
Merge branch 'develop' into Feat/98/CrewAPI
yulrang Nov 12, 2024
1026125
🚨 Fix: 타입 개선, 빌드 오류 수정
yulrang Nov 12, 2024
56bea37
🚧 Chore: workflow 수정
yulrang Nov 12, 2024
1d430b1
♻️ Refactor 코드 개선
yulrang Nov 12, 2024
3a7ce8e
🐛 Fix: 코드 개선
yulrang Nov 12, 2024
ecd941d
✨ Feat: 검색 버튼 추가
yulrang Nov 12, 2024
9a3f685
🐛 Fix: 동작 개선
yulrang Nov 12, 2024
89632d1
🚧 Chore: 경로 변경
yulrang Nov 12, 2024
04225e6
Merge branch 'develop' into Feat/98/CrewAPI
yulrang Nov 12, 2024
ae1729a
🐛 Fix: 콘솔에러 추가
yulrang Nov 12, 2024
b4b356c
⚡️ Fix: 검색 엔터방식으로 변경
yulrang Nov 12, 2024
67886c3
🐛 Fix: 동작개선, 에러메시지 보이기
yulrang Nov 12, 2024
3213309
Merge branch 'Feat/98/CrewAPI' of https://github.com/CodeitFESI4-Team…
yulrang Nov 12, 2024
b9b5cb5
💄 Design: 스타일 수정
yulrang Nov 12, 2024
5687085
🐛 Fix: 에러처리 추가
yulrang Nov 13, 2024
c3382b1
🚨 Fix: 빌드 오류 수정
yulrang Nov 13, 2024
be1480d
🐛 Fix: 타입 수정
yulrang Nov 13, 2024
3c567f3
🐛 Fix: 디폴트이미지 삭제, 데브툴 조건부렌더링
yulrang Nov 13, 2024
abdc917
Merge branch 'develop' into Feat/98/CrewAPI
yulrang Nov 13, 2024
7642e5b
🐛 Fix: 렌더링 방식 변경
yulrang Nov 13, 2024
84780af
🚨 Fix: 빌드 오류 수정
yulrang Nov 13, 2024
47f45c4
🐛 Fix: env 추가
yulrang Nov 13, 2024
8f150e0
🚚 Chore: 파일 이동, 파일명 변경
yulrang Nov 13, 2024
3febcae
🚚 Chore: 파일명 변경
yulrang Nov 13, 2024
1ce21b6
♿️ Fix: 접근성 개선
yulrang Nov 13, 2024
268e90f
Merge branch 'develop' into Feat/98/CrewAPI
yulrang Nov 13, 2024
9760c91
Merge branch 'develop' into Feat/98/CrewAPI
yulrang Nov 13, 2024
2b0587b
Merge branch 'Feat/98/CrewAPI' of https://github.com/CodeitFESI4-Team…
yulrang Nov 13, 2024
efd52d6
🐛 Fix: 바뀐 백엔드 API 적용
yulrang Nov 13, 2024
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
27 changes: 11 additions & 16 deletions src/_apis/crew/crew-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,16 @@ export async function getCrewList(condition: ConditionTypes, pageable: PageableT
const { keyword, mainLocation, mainCategory, subCategory, sortType } = condition;
const { page, size, sort = ['string'] } = pageable;

try {
const response = await fetchApi<MainCrewListResponse>(
`/api/crews/search?keyword=${keyword}&mainLocation=${mainLocation}&mainCategory=${mainCategory}&subCategory=${subCategory}&sortType=${sortType}&page=${page}&size=${size}&sort=${sort}`,
{
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include', // 인증 정보를 요청에 포함
const response: { data: MainCrewListResponse } = await fetchApi(
`/api/crews/search?keyword=${keyword}&mainLocation=${mainLocation}&mainCategory=${mainCategory}&subCategory=${subCategory}&sortType=${sortType}&page=${page}&size=${size}&sort=${sort}`,
{
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
);
return response;
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
return undefined;
}
credentials: 'include', // 인증 정보를 요청에 포함
},
);
Comment on lines +8 to +17
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

API 호출에서 오류 처리가 누락되었습니다.

API 호출 시 발생할 수 있는 네트워크 오류나 서버 오류에 대한 처리가 없습니다. 사용자 경험 향상을 위해 적절한 오류 처리가 필요합니다.

다음과 같이 오류 처리를 추가하는 것을 제안드립니다:

  async function getCrewList(condition: ConditionTypes, pageable: PageableTypes) {
    const { keyword, mainLocation, mainCategory, subCategory, sortType } = condition;
    const { page, size, sort = ['string'] } = pageable;

+   try {
      const response: { data: MainCrewListResponse } = await fetchApi(
        `/api/crews/search?keyword=${keyword}&mainLocation=${mainLocation}&mainCategory=${mainCategory}&subCategory=${subCategory}&sortType=${sortType}&page=${page}&size=${size}&sort=${sort}`,
        {
          method: 'GET',
          headers: {
            'Content-Type': 'application/json',
          },
          credentials: 'include',
        },
      );
      return response?.data;
+   } catch (error) {
+     console.error('크루 목록을 불러오는 중 오류가 발생했습니다:', error);
+     throw new Error('크루 목록을 불러오는데 실패했습니다.');
+   }
  }
📝 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
const response: { data: MainCrewListResponse } = await fetchApi(
`/api/crews/search?keyword=${keyword}&mainLocation=${mainLocation}&mainCategory=${mainCategory}&subCategory=${subCategory}&sortType=${sortType}&page=${page}&size=${size}&sort=${sort}`,
{
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
);
return response;
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
return undefined;
}
credentials: 'include', // 인증 정보를 요청에 포함
},
);
async function getCrewList(condition: ConditionTypes, pageable: PageableTypes) {
const { keyword, mainLocation, mainCategory, subCategory, sortType } = condition;
const { page, size, sort = ['string'] } = pageable;
try {
const response: { data: MainCrewListResponse } = await fetchApi(
`/api/crews/search?keyword=${keyword}&mainLocation=${mainLocation}&mainCategory=${mainCategory}&subCategory=${subCategory}&sortType=${sortType}&page=${page}&size=${size}&sort=${sort}`,
{
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include', // 인증 정보를 요청에 포함
},
);
return response?.data;
} catch (error) {
console.error('크루 목록을 불러오는 중 오류가 발생했습니다:', error);
throw new Error('크루 목록을 불러오는데 실패했습니다.');
}
}


return response?.data;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

응답 데이터 유효성 검증이 필요합니다.

response?.data를 바로 반환하기 전에 데이터의 유효성을 검증하는 것이 안전합니다.

다음과 같이 데이터 검증을 추가하는 것을 제안드립니다:

-  return response?.data;
+  if (!response?.data) {
+    throw new Error('서버로부터 유효하지 않은 응답을 받았습니다.');
+  }
+  return response.data;
📝 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
return response?.data;
if (!response?.data) {
throw new Error('서버로부터 유효하지 않은 응답을 받았습니다.');
}
return response.data;

Comment on lines +8 to +19
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

API 응답 구조가 변경되지 않았습니다.

src/_apis/crew/crew-list.ts 파일의 8-19번째 줄에서 여전히 .data를 사용하고 있습니다. MyCrewListResponse 인터페이스에 따라 datacontent로 변경해야 합니다.

  • src/_apis/crew/crew-list.ts 파일 (8-19번째 줄)
🔗 Analysis chain

API 응답 구조 변경 사항 확인이 필요합니다.

AI 요약에 따르면 MyCrewListResponse 인터페이스에서 datacontent로 변경되었다고 합니다. 이 변경사항이 현재 구현과 일치하는지 확인이 필요합니다.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the interface definition and its usage
ast-grep --pattern 'interface $interface {
  $$$
  content: $type
  $$$
}'

# Check for any remaining uses of the old property name
rg -l "\.data\b" --type ts

Length of output: 635

}
10 changes: 7 additions & 3 deletions src/components/common/crew-list/crew-card-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ function CrewCardList(
) {
const crewDataList =
(inWhere === 'my-crew'
? data?.pages.flatMap((page) => page?.data as MyCrewList[])
: data?.pages?.flatMap((page) => page?.content as MainCrewList[])) ?? [];
? data?.pages.flatMap((page) => page?.content)
: data?.pages?.flatMap((page) => page?.content)) ?? [];
const gridColsStyle = inWhere === 'my-crew' ? '' : 'lg:grid-cols-2';

if (data?.pages[0] === undefined)
Expand Down Expand Up @@ -63,7 +63,11 @@ function CrewCardList(
title={inform?.title}
mainLocation={inform?.mainLocation}
subLocation={inform?.subLocation}
imageUrl={inform?.imageUrl}
imageUrl={
inform?.imageUrl === 'string'
? 'https://media.istockphoto.com/id/1396814518/vector/image-coming-soon-no-photo-no-thumbnail-image-available-vector-illustration.jpg?s=612x612&w=0&k=20&c=hnh2OZgQGhf0b46-J2z7aHbIWwq8HNlSDaNp2wn_iko='
: inform?.imageUrl
}
totalCount={inform?.totalCount}
participantCount={
inWhere === 'my-crew'
Expand Down
2 changes: 1 addition & 1 deletion src/types/crew-card.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ export interface MyCrewList {
}

export interface MyCrewListResponse {
data: MyCrewList[];
content: MyCrewList[];
hasNext: boolean;
}
Comment on lines +68 to 70
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

일부 관련 컴포넌트들이 아직 'data' 속성을 사용하고 있습니다.

  • src/components/common/review-list/review-card-list.tsx
  • src/components/common/writable-gathering-card/writable-gathering-card-list.tsx
🔗 Analysis chain

관련 컴포넌트들의 업데이트 여부를 확인해주세요.

이 인터페이스를 사용하는 모든 컴포넌트들이 새로운 속성 이름(content)을 올바르게 참조하는지 확인이 필요합니다.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: 이 인터페이스를 사용하는 컴포넌트들을 검색하여 업데이트가 필요한 부분을 확인합니다.

# MyCrewListResponse 타입을 사용하는 파일들을 검색
echo "MyCrewListResponse를 사용하는 파일 검색:"
rg "MyCrewListResponse" --type ts --type tsx

# 이전 속성명 'data'를 여전히 사용하고 있는 코드를 검색
echo "\n이전 속성명 'data'를 사용하는 코드 검색:"
rg "data\?\.pages" --type ts --type tsx

Length of output: 288


Script:

#!/bin/bash
# Description: 이 인터페이스를 사용하는 컴포넌트들을 다시 검색하여 업데이트가 필요한 부분을 확인합니다.

# MyCrewListResponse 타입을 사용하는 파일들을 검색 (.ts, .tsx 파일)
echo "MyCrewListResponse를 사용하는 파일 검색 (ts, tsx):"
rg "MyCrewListResponse" -g "*.ts" -g "*.tsx"

# 이전 속성명 'data'를 여전히 사용하는 코드를 검색 (.ts, .tsx 파일)
echo "\n이전 속성명 'data'를 사용하는 코드 검색 (ts, tsx):"
rg "data\?\.pages" -g "*.ts" -g "*.tsx"

Length of output: 1202