Skip to content

Conversation

@dbstj0403
Copy link
Collaborator

@dbstj0403 dbstj0403 commented May 20, 2025

🌟 어떤 이유로 MR를 하셨나요?

  • feature 병합()
  • 버그 수정(아래에 issue #를 남겨주세요)
  • 코드 개선
  • 코드 수정
  • 배포
  • 기타(아래에 자세한 내용 기입해주세요)

📝 세부 내용 - 왜 해당 MR이 필요한지 작업 내용을 자세하게 설명해주세요

  • 공고 쪽에 주관기관이 표기되지 않는 이슈 확인하여 수정하였습니다.
  • 찜한 장소의 좋아요 여부를 확인하는 리액트 훅을 작성하여 코드 중복을 해결하였습니다.

📸 작업 화면 스크린샷

X

⚠️ MR하기 전에 확인해주세요

  • 로컬테스트를 진행하셨나요?
  • 머지할 브랜치를 확인하셨나요?
  • 관련 label을 선택하셨나요?

Summary by CodeRabbit

  • 신규 기능

    • 찜(좋아요) 상태 및 로그인 상태 관리를 위한 커스텀 훅이 추가되었습니다.
    • 날짜 형식 유효성 검사 유틸리티 함수가 추가되었습니다.
  • 버그 수정

    • 데이터가 없을 때 발생할 수 있는 오류를 방지하기 위해 안전한 데이터 접근 방식이 도입되었습니다.
  • 리팩터

    • 찜(좋아요) 및 로그인 상태 관리 로직이 커스텀 훅으로 분리되어 관련 컴포넌트가 간소화되었습니다.
    • 날짜 관련 유틸리티 함수가 외부 모듈로 분리되었습니다.
    • 일부 데이터 필드명이 일관성 있게 변경되었습니다.
  • 스타일

    • 여러 페이지와 컴포넌트에서 레이아웃, 마진, 커서 스타일이 개선되었습니다.
    • 일부 컨테이너 클래스명이 일관성 있게 변경되었습니다.
  • 문서/주석

    • 불필요한 주석이 제거되어 코드가 간결해졌습니다.
  • 기타

    • 로딩 상태에서 스피너가 표시되어 사용자 경험이 향상되었습니다.
    • 불필요한 변수 및 주석이 삭제되었습니다.

@dbstj0403 dbstj0403 requested a review from shroqkf May 20, 2025 01:06
@dbstj0403 dbstj0403 self-assigned this May 20, 2025
@dbstj0403 dbstj0403 added the Refactor Good for newcomers label May 20, 2025
@vercel
Copy link

vercel bot commented May 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
morak ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 20, 2025 7:31am

@coderabbitai
Copy link

coderabbitai bot commented May 20, 2025

## Walkthrough

이 변경사항은 좋아요(찜) 상태 및 로그인 상태 관리를 위한 커스텀 훅 `useLikeToggle`을 도입하고, 관련 컴포넌트(`ReviewItem`, `PlaceInfo`)의 로직을 이 훅을 사용하도록 리팩토링합니다. 또한 여러 페이지에서 로딩 상태 표시, 스타일 클래스 수정, 유틸 함수 분리, 데이터 필드명 변경 등이 포함되어 있습니다.

## Changes

| 파일/경로 요약 | 변경 내용 요약 |
|---|---|
| src/hooks/useLikeToggle.js | 회사의 좋아요 상태와 로그인 상태를 관리하는 커스텀 훅 `useLikeToggle` 신설. 내부적으로 상태와 API 호출, 전역 스토어 동기화, 로그인 모달 제어 기능 포함. |
| src/pages/myPageDetail/MyPageDetailPage.jsx | 리뷰/응원 데이터 로딩 시 스피너 표시 추가, 섹션별 컨테이너 마진 스타일 조정 및 불필요한 헤더 제거. |
| src/pages/myPageDetail/components/ReviewItem.jsx<br>src/pages/review/components/PlaceInfo.jsx | 좋아요 및 로그인 상태 관련 내부 상태/로직 삭제, `useLikeToggle` 훅으로 대체하여 코드 단순화 및 관심사 분리. 로딩 스피너 및 로그인 모달 처리 포함. |
| src/pages/review/components/Reviews.jsx | 코드 내 설명 주석 3줄 삭제, 기능적 변화 없음. |
| src/pages/writeReview/components/WriteText.jsx | 사용하지 않는 변수 제거 및 불필요한 주석 삭제. |
| src/pages/support/FinancialProductDetailPage.jsx<br>src/pages/support/FinancialProductListPage.jsx<br>src/pages/support/SupportItemPage.jsx<br>src/pages/support/SupportListPage.jsx<br>src/pages/support/SupportRecommendPage.jsx | 컨테이너 div CSS 클래스 변경(`container` 적용), 일부 JSX 텍스트 한 줄 변환, 데이터 필드명(`agency``organization`) 변경, 로딩 상태 스피너 추가 및 옵셔널 체이닝 적용 등 UI 및 안정성 개선. |
| src/pages/support/components/FOAItem.jsx | 루트 div에 `cursor-pointer` 클래스 추가, 데이터 필드명 및 접근 방식(`agency``organization`, 옵셔널 체이닝) 변경, 신규 시각 요소 추가. |
| src/pages/support/utils/dateFunc.js | 날짜 형식 유효성 검사 함수 `isValidDateFormat` 추가. |
| src/pages/writeReview/components/Complete.jsx | 닫기 버튼 div에 `cursor-pointer` 클래스 추가. |
| src/pages/map/components/review/ReviewContent.jsx | `item` 객체 접근 시 옵셔널 체이닝 추가로 안전성 향상. |
| src/pages/support/components/FOACard.jsx | `announcementType` 접근 시 옵셔널 체이닝 추가로 안정성 향상. |

## Possibly related PRs

- [Morak-Team/Frontend#53](https://github.com/Morak-Team/Frontend/pull/53): `useLikeToggle` 훅 도입과 `PlaceInfo` 컴포넌트 리팩토링 관련, 좋아요 및 로그인 상태 관리 방식과 직접적 연관.

## Suggested labels

`Fix`

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f4c510 and bac7348.

📒 Files selected for processing (3)
  • src/pages/myPageDetail/MyPageDetailPage.jsx (5 hunks)
  • src/pages/myPageDetail/components/ReviewItem.jsx (2 hunks)
  • src/pages/review/components/PlaceInfo.jsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/pages/myPageDetail/components/ReviewItem.jsx
  • src/pages/review/components/PlaceInfo.jsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/pages/myPageDetail/MyPageDetailPage.jsx (3)
src/components/common/Spinner.jsx (1)
  • Spinner (3-9)
src/pages/myPageDetail/components/ReviewItem.jsx (1)
  • ReviewItem (10-65)
src/pages/myPageDetail/components/StoryItem.jsx (1)
  • StoryItem (3-33)
🪛 Biome (1.9.4)
src/pages/myPageDetail/MyPageDetailPage.jsx

[error] 72-89: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

🔇 Additional comments (5)
src/pages/myPageDetail/MyPageDetailPage.jsx (5)

9-9: 로딩 상태 처리 개선

Spinner 컴포넌트를 활용하여 데이터 로딩 중에 사용자에게 시각적 피드백을 제공한 것은 좋은 개선입니다. 이렇게 하면 데이터가 로드되기 전에 빈 화면이 표시되는 것을 방지하여 사용자 경험이 향상됩니다.

Also applies to: 24-30


50-50: 일관된 여백 스타일링 적용

아이콘과 제목 컨테이너에 my-2 클래스를 추가하여 수직 여백을 일관되게 적용한 것은 시각적으로 더 일관된 UI를 제공합니다.

Also applies to: 60-60


71-83: 리뷰 섹션 렌더링 로직 개선

로딩 상태를 명시적으로 확인하는 조건부 렌더링 로직으로 개선했습니다. 이렇게 하면 다음 세 가지 상태를 적절히 처리할 수 있습니다:

  1. 데이터가 로드되고 존재하는 경우
  2. 데이터가 로드되었지만 비어 있는 경우
  3. 데이터가 아직 로드 중인 경우 (아무것도 렌더링하지 않음)

이는 데이터 로딩 중에 "리뷰가 없어요" 메시지가 표시되는 것을 방지하여 사용자 경험을 개선합니다.


89-101: 응원 섹션 렌더링 로직 개선

리뷰 섹션과 마찬가지로, 응원 섹션도 로딩 상태를 명시적으로 확인하도록 개선되었습니다. 일관된 로딩 상태 처리는 전체 애플리케이션에서 사용자 경험을 향상시킵니다.


71-84: Fragment 사용에 대한 참고 사항

정적 분석 도구에서 불필요한 Fragment 사용에 대한 경고가 있지만, 이 경우에는 조건부 요소들을 그룹화하는 데 Fragment가 적절히 사용되고 있습니다. 이 경고는 무시해도 됩니다.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (6)
src/pages/support/utils/dateFunc.js (1)

22-24: 날짜 형식 검증 유틸리티 함수 추가는 좋은 리팩토링입니다.

날짜 형식을 검증하는 로직을 유틸리티 함수로 분리하여 코드 재사용성을 높였습니다. 이는 코드 중복 해소라는 PR 목표에 부합합니다.

다만, 현재 구현은 형식만 검증하고 실제 유효한 날짜인지는 검증하지 않습니다(예: "9999-99-99"도 통과). 필요하다면 실제 날짜 유효성도 검증하는 확장을 고려해보세요.

export const isValidDateFormat = (dateStr) => {
-  return /^\d{4}-\d{2}-\d{2}$/.test(dateStr);
+  // 형식 검증
+  if (!/^\d{4}-\d{2}-\d{2}$/.test(dateStr)) return false;
+  
+  // 날짜 유효성 검증
+  const parts = dateStr.split('-');
+  const year = parseInt(parts[0], 10);
+  const month = parseInt(parts[1], 10);
+  const day = parseInt(parts[2], 10);
+  
+  if (month < 1 || month > 12) return false;
+  
+  const daysInMonth = new Date(year, month, 0).getDate();
+  if (day < 1 || day > daysInMonth) return false;
+  
+  return true;
};
src/pages/support/components/FOAItem.jsx (1)

9-10: 디버깅용 console.log 제거 필요

프로덕션 코드에 console.log가 남아있습니다. 배포 전에 제거하는 것이 좋습니다.

-  console.log(data);
src/pages/support/SupportListPage.jsx (2)

11-17: 로딩 실패 시 예외‧에러 상태도 고려해주세요
isLoadingfalse가 되었을 때 API 호출이 실패했다면 현재 컴포넌트는 그대로 본문을 렌더링하려다 dataundefined여서 빈 화면이 나타날 수 있습니다. isError(또는 error) 상태를 함께 반환하도록 쿼리 훅을 수정하거나, 이곳에서 별도의 에러 UI를 분기 렌더링해 주는 편이 UX 측면에서 안전합니다.


35-37: key 로 인덱스 대신 식별자 사용 권장
map 반복에서 배열 인덱스를 key로 사용하면 항목 순서 변경·삭제 시 리렌더 성능 저하와 예기치 못한 UI 깜빡임이 발생할 수 있습니다. 가능하면 item.id 같이 고유한 식별자를 넘겨주세요.

-{data?.map((item, idx) => (
-  <FOAItem data={item} key={idx} />
+{data?.map((item) => (
+  <FOAItem data={item} key={item.id} />
))}
src/pages/support/SupportItemPage.jsx (1)

59-59: 기관명이 없을 때 대비한 폴백 텍스트 제안
data?.organization 이 undefined 인 경우 화면에 빈 문자열이 노출됩니다. 사용자 경험 향상을 위해 “기관 정보 없음” 등 기본값을 넣어두면 좋겠습니다.

src/hooks/useLikeToggle.js (1)

48-56: 서버 왕복 최소화를 위한 낙관적 업데이트 고려
토글 직후 UI를 즉시 반영하고, 실패 시 roll-back 하는 낙관적 업데이트 방식을 적용하면 사용자가 체감하는 반응 속도가 빨라집니다. 또한 이미 전역 likedMap 을 보유하므로 getLikedCompanies 호출을 매번 반복하기보다는 스토어 캐시 값을 우선 활용해 보세요.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94169cf and 098ca3b.

📒 Files selected for processing (14)
  • src/hooks/useLikeToggle.js (1 hunks)
  • src/pages/myPageDetail/MyPageDetailPage.jsx (4 hunks)
  • src/pages/myPageDetail/components/ReviewItem.jsx (2 hunks)
  • src/pages/review/components/PlaceInfo.jsx (3 hunks)
  • src/pages/review/components/Reviews.jsx (0 hunks)
  • src/pages/support/FinancialProductDetailPage.jsx (3 hunks)
  • src/pages/support/FinancialProductListPage.jsx (2 hunks)
  • src/pages/support/SupportItemPage.jsx (3 hunks)
  • src/pages/support/SupportListPage.jsx (2 hunks)
  • src/pages/support/SupportRecommendPage.jsx (1 hunks)
  • src/pages/support/components/FOAItem.jsx (2 hunks)
  • src/pages/support/utils/dateFunc.js (1 hunks)
  • src/pages/writeReview/components/Complete.jsx (1 hunks)
  • src/pages/writeReview/components/WriteText.jsx (1 hunks)
💤 Files with no reviewable changes (1)
  • src/pages/review/components/Reviews.jsx
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/pages/myPageDetail/MyPageDetailPage.jsx (1)
src/components/common/Spinner.jsx (1)
  • Spinner (3-9)
src/hooks/useLikeToggle.js (2)
src/pages/review/components/PlaceInfo.jsx (1)
  • useLikeToggle (17-24)
src/store/authStore.js (1)
  • useAuthStore (4-23)
src/pages/myPageDetail/components/ReviewItem.jsx (3)
src/store/userInfoStore.js (1)
  • useUserInfoStore (3-17)
src/store/useLikeStore.js (1)
  • useLikeStore (3-12)
src/pages/review/components/PlaceInfo.jsx (1)
  • useLikeToggle (17-24)
🔇 Additional comments (19)
src/pages/writeReview/components/Complete.jsx (1)

12-12: 닫기 버튼의 클릭 가능성을 시각적으로 표시한 개선 사항입니다.

cursor-pointer 클래스를 추가하여 사용자에게 이 요소가 클릭 가능함을 시각적으로 알려주는 좋은 UX 개선입니다.

src/pages/support/FinancialProductListPage.jsx (1)

90-90: 총 개수 표시 코드가 간결해졌습니다.

다중 라인 JSX에서 단일 라인으로 코드를 리팩토링하여 가독성이 개선되었습니다.

src/pages/writeReview/components/WriteText.jsx (1)

30-30: 관련 주석이 제거되었지만 기능은 동일하게 유지됩니다.

리뷰 등록 과정에서 업로딩 상태를 관리하는 코드가 정리되었습니다. 주석은 제거되었지만 기능적으로는 동일합니다: 비동기 작업 전에 setIsUploading(true)로 모달을 표시하고, 작업 완료 또는 실패 후 setIsUploading(false)로 모달을 숨기는 흐름이 유지되었습니다.

Also applies to: 34-35, 38-39

src/pages/support/FinancialProductDetailPage.jsx (4)

40-40: 컨테이너 스타일 개선

고정 높이 스타일(h-[calc(100vh-5.25rem)])을 컨테이너 클래스로 대체하여 더 일관된 레이아웃 스타일링을 적용했습니다. 이는 다른 지원 관련 페이지의 스타일링과도 일치합니다.


89-89: 텍스트 가독성 향상

방식과 기본 금리 정보 텍스트에 font-medium 클래스를 추가하여 가독성을 향상시켰습니다.

Also applies to: 93-93


97-97: 텍스트 줄바꿈 개선

금융상품 소개 제목에 break-keep 클래스를 추가하여 텍스트 줄바꿈 처리가 개선되었습니다.


126-126: 버튼 텍스트 포맷팅 정리

멀티라인 JSX 요소를 싱글라인으로 변환하여 코드 일관성을 개선했습니다.

src/pages/myPageDetail/MyPageDetailPage.jsx (3)

9-9: 로딩 상태 표시를 위한 Spinner 컴포넌트 추가

데이터 로딩 중 상태를 사용자에게 시각적으로 표시하기 위한 Spinner 컴포넌트를 가져왔습니다.


24-30: 로딩 상태 처리 로직 개선

리뷰와 응원 데이터의 로딩 상태를 적절히 처리하는 로직이 추가되었습니다. 이제 데이터가 로딩 중일 때 Spinner 컴포넌트가 표시되어 사용자 경험이 향상됩니다.


50-50: 일관된 여백 적용

"찜" 및 "응원" 섹션의 아이콘과 제목 주변에 my-2 클래스를 추가하여 "리뷰" 섹션과 동일한 여백을 갖도록 스타일링이 개선되었습니다.

Also applies to: 60-60

src/pages/support/components/FOAItem.jsx (2)

13-13: 사용자 상호작용 피드백 개선

상호작용 가능한 요소임을 시각적으로 나타내기 위해 cursor-pointer 클래스가 추가되어 사용자 경험이 향상되었습니다.


43-43: 속성 접근 안전성 향상 및 필드명 수정

데이터 속성에 접근할 때 옵셔널 체이닝(?.)을 사용하여 안전성을 높였고, 주관기관 표시 필드명이 agency에서 organization으로 수정되었습니다. 이는 PR 설명에서 언급된 "주관기관 표기" 문제를 해결합니다.

Also applies to: 44-44

src/pages/support/SupportItemPage.jsx (1)

20-20: 레이아웃 변경이 의도한 높이·스크롤 정책과 맞는지 확인 바랍니다
기존 h-[calc(100vh-5.25rem)] 고정 높이를 container 클래스로 교체하면서 뷰포트 높이에 맞춘 스크롤 관리가 달라질 수 있습니다. 모바일 환경에서 하단 영역이 잘리지 않는지 한번 더 확인해주세요.

src/pages/myPageDetail/components/ReviewItem.jsx (2)

50-53: 비로그인 상태에서도 이전 ‘좋아요’ 캐시가 표시될 가능성
현재 아이콘 노출 조건이 isLoggedIn && isGloballyLiked 입니다. 캐시가 true 여도 로그인하지 않으면 빈 하트가 그려집니다. 사용자 관점에서 ‘좋아요가 해제된 것처럼’ 혼동될 수 있으니,

  1. 비로그인 상태엔 회색 하트 등 별도 표현을 두거나
  2. 로그인 시점에만 likedMap 을 초기화하여 불일치가 없도록 처리하는 방식을 검토해 주세요.

16-20: useLikeToggle 적용으로 컴포넌트가 깔끔해졌습니다!
중복 로직이 제거되어 유지보수가 쉬워졌네요. 좋은 리팩터링입니다.

src/pages/review/components/PlaceInfo.jsx (4)

10-11: 필요한 컴포넌트와 훅 추가 적절함

로딩 상태를 표시하기 위한 Spinner 컴포넌트와 좋아요 상태를 관리하기 위한 useLikeToggle 훅을 추가한 것은 코드의 관심사 분리와 재사용성 측면에서 매우 좋은 접근입니다.


17-24: useLikeToggle 훅 사용으로 코드 중복 해소 완료

커스텀 훅 useLikeToggle을 사용하여 좋아요 상태 관리, 로그인 확인, 모달 표시 등의 로직을 추출한 것은 PR 목표에 부합하는 훌륭한 리팩토링입니다. 이를 통해 컴포넌트의 책임이 줄어들고 코드 재사용성이 향상되었습니다.


47-53: 로딩 상태 처리 추가 적절함

데이터 로딩 중 사용자 경험을 개선하기 위한 로딩 인디케이터 추가는 매우 좋은 개선사항입니다. Spinner 컴포넌트를 활용하여 일관된 로딩 UI를 제공하고 있습니다.


117-121: 이벤트 핸들러 간소화 적절함

이벤트 핸들러가 훅에서 제공하는 toggleLike 함수를 사용하여 간소화되었습니다. e.preventDefault()를 호출하여 기본 동작을 방지하는 것은 좋은 방어적 코딩 관행입니다.


return (
<div className="relative w-full h-[calc(100vh-5.25rem)] overflow-y-auto scrollbar-hide">
<div className="relative w-full conatiner overflow-y-auto scrollbar-hide">
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

클래스명 오타 수정이 필요합니다.

CSS 클래스명에 오타가 있습니다: conatinercontainer의 오타로 보입니다.

-    <div className="relative w-full conatiner overflow-y-auto scrollbar-hide">
+    <div className="relative w-full container overflow-y-auto scrollbar-hide">

이 오타는 다른 파일(FinancialProductListPage.jsx)에서도 발견되니 함께 수정하시길 권장합니다.

📝 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
<div className="relative w-full conatiner overflow-y-auto scrollbar-hide">
<div className="relative w-full container overflow-y-auto scrollbar-hide">
🤖 Prompt for AI Agents
In src/pages/support/SupportRecommendPage.jsx at line 36, there is a typo in the
CSS class name "conatiner" which should be corrected to "container". Fix this
typo by replacing "conatiner" with "container". Also, check the file
FinancialProductListPage.jsx for the same typo and correct it similarly.


return (
<div className="flex flex-col pr-5 pl-5 h-[calc(100vh-5.25rem)] overflow-y-auto pb-5 mb-5">
<div className="flex flex-col pr-5 pl-5 conatiner overflow-y-auto pb-5 mb-5">
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

클래스명 오타 수정이 필요합니다.

CSS 클래스명에 오타가 있습니다: conatinercontainer의 오타로 보입니다.

-    <div className="flex flex-col pr-5 pl-5 conatiner overflow-y-auto pb-5 mb-5">
+    <div className="flex flex-col pr-5 pl-5 container overflow-y-auto pb-5 mb-5">

이 오타는 SupportRecommendPage.jsx 파일에서도 동일하게 발견됩니다. 모든 관련 파일에서 일관되게 수정하시길 권장합니다.

🤖 Prompt for AI Agents
In src/pages/support/FinancialProductListPage.jsx at line 78, there is a typo in
the CSS class name "conatiner" which should be corrected to "container". Locate
the same typo in SupportRecommendPage.jsx and fix it there as well to maintain
consistency across related files.

Comment on lines 24 to 30
if (authenticated && companyId) {
const likedList = await getLikedCompanies();
const liked = likedList.some(
(c) => String(c.companyId) === String(companyId),
);
setIsLiked(liked);
setLike(companyId, liked);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

API 호출 오류 처리 누락
getLikedCompanies 실패 시 훅이 끝까지 loading 상태로 남거나 잘못된 isLiked 값을 사용하게 됩니다. try‧catch 로 감싸고 실패 시 setLoading(false) 와 오류 로그를 남겨주세요.

-        const likedList = await getLikedCompanies();
+        let likedList = [];
+        try {
+          likedList = await getLikedCompanies();
+        } catch (e) {
+          console.error("좋아요 목록 조회 실패:", e);
+        }
📝 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
if (authenticated && companyId) {
const likedList = await getLikedCompanies();
const liked = likedList.some(
(c) => String(c.companyId) === String(companyId),
);
setIsLiked(liked);
setLike(companyId, liked);
if (authenticated && companyId) {
let likedList = [];
try {
likedList = await getLikedCompanies();
} catch (e) {
console.error("좋아요 목록 조회 실패:", e);
}
const liked = likedList.some(
(c) => String(c.companyId) === String(companyId),
);
setIsLiked(liked);
setLike(companyId, liked);
🤖 Prompt for AI Agents
In src/hooks/useLikeToggle.js around lines 24 to 30, the call to
getLikedCompanies lacks error handling, causing the hook to remain in a loading
state or use incorrect isLiked values if the API call fails. Wrap the
getLikedCompanies call and subsequent logic in a try-catch block, and in the
catch block, call setLoading(false) and log the error to handle failures
gracefully.

@dbstj0403 dbstj0403 changed the title Fix: 지원 공고 페이지 주관기관 표기 및 코드 중복 해소 [Fix] 지원 공고 페이지 주관기관 표기 및 코드 중복 해소 May 20, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
src/pages/myPageDetail/MyPageDetailPage.jsx (1)

84-120: ⚠️ Potential issue

코드 중복 문제: 중복된 렌더링 로직 제거 필요

84-120줄의 코드는 38-71줄에서 이미 구현된 "리뷰"와 "응원" 렌더링 로직을 중복하고 있습니다. 새로 추가된 코드(38-71줄)는 로딩 상태 체크를 포함하고 있어 더 견고하므로, 이 중복 코드는 제거하는 것이 좋습니다.

아래와 같이 중복 코드를 제거하세요:

- <div className="flex flex-col gap-4 w-full bg-gray-2 p-5 min-h-screen">
-   {kind === "리뷰" && (
-     <>
-       {reviewsData?.length > 0 ? (
-         reviewsData.map((item, idx) => (
-           <ReviewItem data={item} key={idx} />
-         ))
-       ) : (
-         <div className="flex flex-col justify-center items-center mt-36">
-           <img src={noResult} />
-           <p className="h4 text-gray-9 text-center py-8">
-             아직 작성한 리뷰가
-             <br /> 없어요
-           </p>
-         </div>
-       )}
-     </>
-   )}
-
-   {kind === "응원" && (
-     <>
-       {cheersData?.length > 0 ? (
-         cheersData.map((item) => (
-           <StoryItem item={item} key={item.storyId} />
-         ))
-       ) : (
-         <div className="flex flex-col justify-center items-center mt-36">
-           <img src={noResult} />
-           <p className="h4 text-gray-9 text-center py-8">
-             아직 응원한 이야기가
-             <br /> 없어요
-           </p>
-         </div>
-       )}
-     </>
-   )}
- </div>
+ <div className="flex flex-col gap-4 w-full bg-gray-2 p-5 min-h-screen">
+   {/* 여기에 찜 목록을 위한 공간이 필요하다면 추가하세요 */}
+ </div>
🧰 Tools
🪛 Biome (1.9.4)

[error] 88-106: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

🧹 Nitpick comments (2)
src/pages/myPageDetail/MyPageDetailPage.jsx (2)

38-54: 리뷰 섹션의 불필요한 Fragment 제거 필요

불필요한 Fragment가 사용되었습니다. 단일 조건부 렌더링 표현식을 감싸는 Fragment는 제거해도 됩니다.

아래와 같이 코드를 수정하세요:

- {kind === "리뷰" && (
-   <>
-     {!isLoadingReviews && reviewsData?.length > 0 ? (
-       reviewsData?.map((item, idx) => (
-         <ReviewItem data={item} key={idx} />
-       ))
-     ) : !isLoadingReviews && reviewsData?.length === 0 ? (
-       <div className="flex flex-col justify-center items-center mt-36">
-         <img src={noResult} />
-         <p className="h4 text-gray-9 text-center py-8">
-           아직 작성한 리뷰가
-           <br /> 없어요
-         </p>
-       </div>
-     ) : null}
-   </>
- )}
+ {kind === "리뷰" && 
+   (!isLoadingReviews && reviewsData?.length > 0 ? (
+     reviewsData?.map((item, idx) => (
+       <ReviewItem data={item} key={idx} />
+     ))
+   ) : !isLoadingReviews && reviewsData?.length === 0 ? (
+     <div className="flex flex-col justify-center items-center mt-36">
+       <img src={noResult} />
+       <p className="h4 text-gray-9 text-center py-8">
+         아직 작성한 리뷰가
+         <br /> 없어요
+       </p>
+     </div>
+   ) : null)
+ }

56-71: 응원 섹션의 불필요한 Fragment 제거 필요

불필요한 Fragment가 사용되었습니다. Fragment 내에 단일 조건부 렌더링 표현식만 있으므로 Fragment를 제거하는 것이 좋습니다.

아래와 같이 코드를 수정하세요:

- {kind === "응원" && (
-   <>
-     {!isLoadingCheers && cheersData?.length > 0 ? (
-       cheersData?.map((item) => (
-         <StoryItem item={item} key={item.storyId} />
-       ))
-     ) : !isLoadingCheers && cheersData?.length === 0 ? (
-       <div className="flex flex-col justify-center items-center mt-36">
-         <img src={noResult} />
-         <p className="h4 text-gray-9 text-center py-8">
-           아직 응원한 이야기가
-           <br /> 없어요
-         </p>
-       </div>
-     ) : null}
-   </>
- )}
+ {kind === "응원" && 
+   (!isLoadingCheers && cheersData?.length > 0 ? (
+     cheersData?.map((item) => (
+       <StoryItem item={item} key={item.storyId} />
+     ))
+   ) : !isLoadingCheers && cheersData?.length === 0 ? (
+     <div className="flex flex-col justify-center items-center mt-36">
+       <img src={noResult} />
+       <p className="h4 text-gray-9 text-center py-8">
+         아직 응원한 이야기가
+         <br /> 없어요
+       </p>
+     </div>
+   ) : null)
+ }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ed43b2 and 3896b8c.

📒 Files selected for processing (2)
  • src/pages/map/components/review/ReviewContent.jsx (1 hunks)
  • src/pages/myPageDetail/MyPageDetailPage.jsx (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/pages/myPageDetail/MyPageDetailPage.jsx (3)
src/components/common/Spinner.jsx (1)
  • Spinner (3-9)
src/pages/myPageDetail/components/ReviewItem.jsx (2)
  • navigate (11-11)
  • ReviewItem (10-65)
src/pages/myPageDetail/components/StoryItem.jsx (2)
  • navigate (4-4)
  • StoryItem (3-33)
🪛 Biome (1.9.4)
src/pages/myPageDetail/MyPageDetailPage.jsx

[error] 40-56: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)


[error] 58-75: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

🔇 Additional comments (4)
src/pages/map/components/review/ReviewContent.jsx (1)

11-11: 안전한 속성 접근 방식으로 개선됨!

item 객체가 null 또는 undefined일 때 발생할 수 있는 런타임 오류를 방지하기 위해 선택적 체이닝 연산자(?.)를 사용한 좋은 방어적 프로그래밍 기법입니다. 또한 profileColor 속성이 없을 경우 "gray"를 기본값으로 사용하여 UI가 항상 일관되게 렌더링되도록 보장합니다.

src/pages/myPageDetail/MyPageDetailPage.jsx (3)

9-9: Spinner 컴포넌트 추가로 로딩 상태 시각화 구현

Spinner 컴포넌트를 불러오는 import 문을 추가하여 로딩 상태를 시각적으로 표시할 수 있게 되었습니다. 사용자 경험 향상에 좋은 변화입니다.


24-30: 로딩 상태 처리 로직 개선

데이터 로딩 중일 때 Spinner를 표시하는 로직이 잘 구현되었습니다. 이는 사용자에게 현재 데이터를 가져오는 중임을 명확히 알려줍니다.


76-76: UI 일관성을 위한 여백 조정

'찜' 섹션 헤더에 my-2 마진을 추가하여 일관된 간격과 레이아웃을 유지하도록 개선했습니다.

Copy link
Collaborator

@shroqkf shroqkf left a comment

Choose a reason for hiding this comment

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

스크린샷 2025-05-20 오후 4 00 28

D가 두번 보이는 오류 있습니다!

Copy link
Collaborator

@shroqkf shroqkf left a comment

Choose a reason for hiding this comment

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

지원사업 부분에서 태그 UI가 피그마랑 다르게 되어 있습니다! 확인하고 수정 바랍니다

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/pages/support/components/FOACard.jsx (2)

7-8: 다른 속성도 선택적 체이닝 적용 고려

announcementType에는 선택적 체이닝을 적용했지만, data.endDate, data.title, data.organization 등 다른 속성들에는 적용되지 않았습니다. 일관성 있는 방어적 코딩을 위해 이러한 속성에도 선택적 체이닝을 적용하는 것을 고려해보세요.

- const formattedEndDate = formatEndDate(data.endDate);
- const dday = calculateDday(data.endDate);
+ const formattedEndDate = formatEndDate(data?.endDate);
+ const dday = calculateDday(data?.endDate);

47-48: 다른 텍스트 속성도 선택적 체이닝 적용 필요

제목과 기관명을 표시하는 부분에도 선택적 체이닝을 적용하여 데이터가 없는 경우에도 안전하게 처리할 수 있도록 하는 것이 좋습니다.

- <p className="h3 leading-snug line-clamp-2">{data.title}</p>
- <p className="b5 text-gray-6">{data.organization}</p>
+ <p className="h3 leading-snug line-clamp-2">{data?.title}</p>
+ <p className="b5 text-gray-6">{data?.organization}</p>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3896b8c and 0f4c510.

📒 Files selected for processing (3)
  • src/pages/support/SupportItemPage.jsx (4 hunks)
  • src/pages/support/components/FOACard.jsx (1 hunks)
  • src/pages/support/components/FOAItem.jsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/pages/support/components/FOAItem.jsx
  • src/pages/support/SupportItemPage.jsx
🔇 Additional comments (1)
src/pages/support/components/FOACard.jsx (1)

45-45: 선택적 체이닝 추가로 안정성 향상 👍

data?.announcementType와 같이 선택적 체이닝을 추가하여 data가 null이나 undefined일 때 발생할 수 있는 런타임 오류를 방지했습니다. 이는 코드의 안정성을 향상시키는 좋은 변경입니다.

@shroqkf shroqkf merged commit 1ffbcda into develop May 20, 2025
4 checks passed
@shroqkf shroqkf deleted the feature/fixSupport branch May 20, 2025 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants