Skip to content

Conversation

@HaeJungg
Copy link
Contributor

@HaeJungg HaeJungg commented Nov 20, 2024

πŸ”– Issue Ticket

#153

✍️ Description

λ””ν…ŒμΌ νŽ˜μ΄μ§€ μŠ€μΌˆλ ˆν†€ ui 적용, 404νŽ˜μ΄μ§€ 이동

βœ… Checklist

PR

  • Branch Convention 확인

    feat/ 피쳐, fix/ 버그 μˆ˜μ •, refactor/ κ°œμ„ 

  • Base Branch 확인
  • μ μ ˆν•œ Label μ§€μ •
  • Assignee 및 Reviewer μ§€μ •

Test

  • 둜컬 μž‘λ™ 확인

Summary by CodeRabbit

  • μƒˆλ‘œμš΄ κΈ°λŠ₯

    • CrewDetailSkeleton 및 GatheringSkeletonListλ₯Ό ν†΅ν•œ λ‘œλ”© μƒνƒœ κ°œμ„ .
    • 였λ₯˜ 처리 및 μ‚¬μš©μž ν”Όλ“œλ°± κ°œμ„ .
    • 데이터가 없을 λ•Œ μ‚¬μš©μžμ—κ²Œ μƒˆλ‘œμš΄ λͺ¨μž„ 생성을 ꢌμž₯ν•˜λŠ” λ©”μ‹œμ§€ μΆ”κ°€.
  • 버그 μˆ˜μ •

    • 였λ₯˜ λ©”μ‹œμ§€ 일관성 ν–₯상 및 κ°„μ†Œν™”λœ 였λ₯˜ 처리 둜직 적용.
  • μŠ€νƒ€μΌ

    • μŠ€μΌˆλ ˆν†€ μ»΄ν¬λ„ŒνŠΈμ˜ λ ˆμ΄μ•„μ›ƒ 및 μŠ€νƒ€μΌ κ°œμ„ .

@HaeJungg HaeJungg self-assigned this Nov 20, 2024
@HaeJungg HaeJungg linked an issue Nov 20, 2024 that may be closed by this pull request
2 tasks
@coderabbitai
Copy link

coderabbitai bot commented Nov 20, 2024

Important

Review skipped

Review was skipped due to path filters

β›” Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

이 λ³€κ²½ 사항은 DetailCrewContainer 및 GatheringListSection μ»΄ν¬λ„ŒνŠΈμ˜ λ‘œλ”© 및 였λ₯˜ 처리 방식을 κ°œμ„ ν•©λ‹ˆλ‹€. Loader μ»΄ν¬λ„ŒνŠΈκ°€ 각각 CrewDetailSkeletonκ³Ό GatheringSkeletonList둜 λŒ€μ²΄λ˜μ–΄ μ‚¬μš©μž κ²½ν—˜μ΄ ν–₯μƒλ©λ‹ˆλ‹€. 였λ₯˜ 처리 둜직이 κ°„μ†Œν™”λ˜μ—ˆμœΌλ©°, 였λ₯˜ λ©”μ‹œμ§€κ°€ μΌκ΄€λ˜κ²Œ ν‘œμ‹œλ©λ‹ˆλ‹€. μƒˆλ‘œμš΄ CrewDetailSkeleton μ»΄ν¬λ„ŒνŠΈκ°€ μΆ”κ°€λ˜μ—ˆκ³ , GatheringSkeleton의 ꡬ쑰가 μ‹œκ°μ μœΌλ‘œ κ°œμ„ λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

Changes

파일 경둜 λ³€κ²½ μš”μ•½
src/app/(crew)/crew/detail/[id]/_components/detail-crew-container.tsx Loaderλ₯Ό CrewDetailSkeleton으둜 λŒ€μ²΄, 였λ₯˜ 처리 둜직 κ°„μ†Œν™” 및 μƒˆλ‘œμš΄ renderErrorState ν•¨μˆ˜ λ„μž….
src/app/(crew)/crew/detail/[id]/_components/gathering-list-section.tsx Loaderλ₯Ό GatheringSkeletonList둜 λŒ€μ²΄, 였λ₯˜ λ©”μ‹œμ§€ κ°„μ†Œν™” 및 데이터 μ—†μŒ λ©”μ‹œμ§€ κ°œμ„ .
src/components/common/skeleton/crew-detail-skeleton/index.tsx μƒˆλ‘œμš΄ CrewDetailSkeleton μ»΄ν¬λ„ŒνŠΈ μΆ”κ°€, λ‘œλ”© μŠ€μΌˆλ ˆν†€ UI κ΅¬ν˜„.
src/components/common/skeleton/gathering-skeleton-list/index.tsx className 속성 μ—…λ°μ΄νŠΈλ‘œ κ·Έλ¦¬λ“œμ˜ λ„ˆλΉ„ 및 μ΅œλŒ€ λ„ˆλΉ„ μ‘°μ •.
src/components/common/skeleton/gathering-skeleton/index.tsx ꡬ쑰 및 μŠ€νƒ€μΌ λ³€κ²½, μƒˆλ‘œμš΄ λ ˆμ΄μ•„μ›ƒ 및 μŠ€μΌˆλ ˆν†€ μš”μ†Œ μΆ”κ°€.

Possibly related PRs

  • Feat/111/gathering apiΒ #120: 이 PR은 λͺ¨μž„ μ„ΈλΆ€ 정보λ₯Ό κ΄€λ¦¬ν•˜κΈ° μœ„ν•œ μƒˆλ‘œμš΄ API κΈ°λŠ₯을 λ„μž…ν•˜λ©°, μ΄λŠ” DetailCrewContainer μ»΄ν¬λ„ŒνŠΈμ˜ κΈ°λŠ₯κ³Ό 관련이 μžˆμŠ΅λ‹ˆλ‹€.
  • Feat/127/update detail pageΒ #130: 이 PR은 DetailCrewContainer μ»΄ν¬λ„ŒνŠΈλ₯Ό ν¬ν•¨ν•˜λŠ” 상세 νŽ˜μ΄μ§€λ₯Ό μ—…λ°μ΄νŠΈν•˜μ—¬ κ΄€λ ¨ APIμ™€μ˜ 톡합을 κ°•ν™”ν•©λ‹ˆλ‹€.
  • Feat/139/gathering card UI - λͺ¨λ‹¬ API μ—°κ²°Β #141: 이 PR의 μˆ˜μ • 사항은 GatheringCard μ»΄ν¬λ„ŒνŠΈλ₯Ό κ°œμ„ ν•˜λ©°, μ΄λŠ” GatheringListSectionκ³Ό 관련이 μžˆμŠ΅λ‹ˆλ‹€.
  • Fix/146/gathering detailΒ #149: 이 PR은 λͺ¨μž„ 상세 보기의 μˆ˜μ •μ„ 닀루며, DetailCrewContainer μ»΄ν¬λ„ŒνŠΈμ˜ λ³€κ²½ 사항과 μ§μ ‘μ μœΌλ‘œ 관련이 μžˆμŠ΅λ‹ˆλ‹€.

Suggested labels

api, pages

Suggested reviewers

  • yulrang
  • minkyung5x5

πŸ‡ λ³€ν™”μ˜ 좀을 μΆ”λ©°,
μŠ€μΌˆλ ˆν†€μ΄ λ°˜μ§μ΄λ„€.
였λ₯˜λŠ” 사라지고,
λ°μ΄ν„°λŠ” 흐λ₯΄λ„€.
μƒˆλ‘œμš΄ λ©”μ‹œμ§€λ‘œ,
μ‚¬μš©μžμ™€ ν•¨κ»˜ν•΄!
πŸŽ‰


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❀️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

@github-actions
Copy link

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: 1

🧹 Outside diff range and nitpick comments (6)
src/components/common/skeleton/gathering-skeleton-list/index.tsx (1)

Line range hint 13-16: Array 생성 μ΅œμ ν™”λ₯Ό κ³ λ €ν•΄λ³΄μ„Έμš”

ν˜„μž¬ κ΅¬ν˜„μ€ μž‘λ™ν•˜μ§€λ§Œ, μ„±λŠ₯ μ΅œμ ν™”λ₯Ό μœ„ν•΄ λ‹€μŒκ³Ό 같은 방법을 μ œμ•ˆν•©λ‹ˆλ‹€:

-      {[...Array(num)].map((_, index) => (
+      {Array.from({ length: num }).map((_, index) => (

Array.from()을 μ‚¬μš©ν•˜λ©΄ 더 λͺ…μ‹œμ μ΄κ³  λ©”λͺ¨λ¦¬ 효율적인 λ°©μ‹μœΌλ‘œ 배열을 생성할 수 μžˆμŠ΅λ‹ˆλ‹€.

src/components/common/skeleton/gathering-skeleton/index.tsx (2)

5-5: λ°˜μ‘ν˜• 높이 μ μš©μ„ κ³ λ €ν•΄λ³΄μ„Έμš”.

ν˜„μž¬ κ³ μ •λœ 높이(h-[380px])λ₯Ό μ‚¬μš©ν•˜κ³  μžˆλŠ”λ°, λ‹€μ–‘ν•œ ν™”λ©΄ ν¬κΈ°μ—μ„œ 더 μžμ—°μŠ€λŸ¬μš΄ ν‘œν˜„μ„ μœ„ν•΄ λ°˜μ‘ν˜• 높이λ₯Ό μ μš©ν•˜λŠ” 것이 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

-<div className="relative h-[380px] w-full overflow-hidden rounded-lg bg-white shadow-sm">
+<div className="relative min-h-[380px] h-auto w-full overflow-hidden rounded-lg bg-white shadow-sm">

7-7: μŠ€μΌˆλ ˆν†€ UI에 aria-label μΆ”κ°€λ₯Ό ꢌμž₯λ“œλ¦½λ‹ˆλ‹€.

λ‘œλ”© μƒνƒœμž„μ„ 슀크린 리더 μ‚¬μš©μžμ—κ²Œλ„ μ•Œλ €μ£ΌκΈ° μœ„ν•΄ 각 Skeleton μ»΄ν¬λ„ŒνŠΈμ— aria-label을 μΆ”κ°€ν•˜λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

-<Skeleton className="h-full w-full rounded-t-lg" />
+<Skeleton className="h-full w-full rounded-t-lg" aria-label="λͺ¨μž„ 이미지 λ‘œλ”© 쀑" />

-<Skeleton className="mb-2 h-6 w-1/3" />
-<Skeleton className="mb-4 h-6 w-2/3" />
-<Skeleton className="h-4 w-1/2" />
+<Skeleton className="mb-2 h-6 w-1/3" aria-label="λͺ¨μž„ 제λͺ© λ‘œλ”© 쀑" />
+<Skeleton className="mb-4 h-6 w-2/3" aria-label="λͺ¨μž„ μ„€λͺ… λ‘œλ”© 쀑" />
+<Skeleton className="h-4 w-1/2" aria-label="λͺ¨μž„ 정보 λ‘œλ”© 쀑" />

-<Skeleton className="h-4 w-1/3" />
+<Skeleton className="h-4 w-1/3" aria-label="λͺ¨μž„ μƒνƒœ λ‘œλ”© 쀑" />

Also applies to: 11-13, 16-16

src/app/(crew)/crew/detail/[id]/_components/gathering-list-section.tsx (2)

27-27: μ—λŸ¬ λ©”μ‹œμ§€λ₯Ό 더 λͺ…ν™•ν•˜κ²Œ κ°œμ„ ν•΄λ³΄λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

ν˜„μž¬ μ—λŸ¬ λ©”μ‹œμ§€κ°€ λ‹€μ†Œ κ°„λ‹¨ν•©λ‹ˆλ‹€. μ‚¬μš©μžμ—κ²Œ 더 ꡬ체적인 μ•ˆλ‚΄λ‚˜ ν•΄κ²° 방법을 μ œμ‹œν•˜λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

-        toast.error(`μ°œν•˜κΈ°μ— μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€`);
+        toast.error(`μ°œν•˜κΈ°μ— μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€. μž μ‹œ ν›„ λ‹€μ‹œ μ‹œλ„ν•΄ μ£Όμ„Έμš”.`);

-        toast.error(`μ°œν•˜κΈ° ν•΄μ œμ— μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€`);
+        toast.error(`μ°œν•˜κΈ° ν•΄μ œμ— μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€. μž μ‹œ ν›„ λ‹€μ‹œ μ‹œλ„ν•΄ μ£Όμ„Έμš”.`);

Also applies to: 37-37


68-71: 빈 μƒνƒœ UIκ°€ μ‚¬μš©μž μΉœν™”μ μœΌλ‘œ κ°œμ„ λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

빈 μƒνƒœλ₯Ό λ‹¨μˆœνžˆ "데이터 μ—†μŒ"으둜 ν‘œμ‹œν•˜λŠ” λŒ€μ‹ , μ‚¬μš©μžμ—κ²Œ 행동을 μœ λ„ν•˜λŠ” λ©”μ‹œμ§€λ₯Ό μΆ”κ°€ν•œ 것이 쒋은 κ°œμ„ μž…λ‹ˆλ‹€.

λ‹€λ§Œ, μ ‘κ·Όμ„± ν–₯상을 μœ„ν•΄ 이λͺ¨μ§€μ— aria-label을 μΆ”κ°€ν•˜λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

-          <p className="mt-2 text-base font-medium text-blue-400">μƒˆλ‘œμš΄ 약속을 λ§Œλ“€μ–΄λ³΄μ„Έμš”! πŸ™Œ</p>
+          <p className="mt-2 text-base font-medium text-blue-400">μƒˆλ‘œμš΄ 약속을 λ§Œλ“€μ–΄λ³΄μ„Έμš”! <span role="img" aria-label="ν™˜μ˜">πŸ™Œ</span></p>
src/app/(crew)/crew/detail/[id]/_components/detail-crew-container.tsx (1)

42-42: 데이터 μ²˜λ¦¬κ°€ μ΅œμ ν™”λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

μ°Έκ°€μž 수 확인 둜직이 κ°„λ‹¨ν•˜κ²Œ κ°œμ„ λ˜μ—ˆμŠ΅λ‹ˆλ‹€. 가독성을 μœ„ν•΄ λ³€μˆ˜λͺ…을 더 λͺ…ν™•ν•˜κ²Œ 지을 수 μžˆμŠ΅λ‹ˆλ‹€.

-setIsConfirmed(data.participantCount === data.totalCount);
+setIsConfirmed(data.currentParticipants === data.maxParticipants);
πŸ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 3fa083e and 0cb04ef.

πŸ“’ Files selected for processing (5)
  • src/app/(crew)/crew/detail/[id]/_components/detail-crew-container.tsx (3 hunks)
  • src/app/(crew)/crew/detail/[id]/_components/gathering-list-section.tsx (5 hunks)
  • src/components/common/skeleton/crew-detail-skeleton/index.tsx (1 hunks)
  • src/components/common/skeleton/gathering-skeleton-list/index.tsx (1 hunks)
  • src/components/common/skeleton/gathering-skeleton/index.tsx (1 hunks)
βœ… Files skipped from review due to trivial changes (1)
  • src/components/common/skeleton/crew-detail-skeleton/index.tsx
πŸ”‡ Additional comments (5)
src/components/common/skeleton/gathering-skeleton-list/index.tsx (1)

10-10: λ°˜μ‘ν˜• λ””μžμΈ κ°œμ„ μ΄ 잘 μ΄λ£¨μ–΄μ‘ŒμŠ΅λ‹ˆλ‹€!

className μ†μ„±μ˜ 변경사항이 λ‹€μŒκ³Ό 같은 이점을 μ œκ³΅ν•©λ‹ˆλ‹€:

  • w-full둜 μ»¨ν…Œμ΄λ„ˆ λ„ˆλΉ„λ₯Ό μ΅œλŒ€ν•œ ν™œμš©
  • 큰 ν™”λ©΄μ—μ„œ lg:max-w-[1200px]둜 μ μ ˆν•œ μ΅œλŒ€ λ„ˆλΉ„ μ œν•œ
  • λ°˜μ‘ν˜• κ·Έλ¦¬λ“œ λ ˆμ΄μ•„μ›ƒ μœ μ§€
src/components/common/skeleton/gathering-skeleton/index.tsx (1)

5-18: μŠ€μΌˆλ ˆν†€ UI ꡬ쑰가 잘 κ΅¬ν˜„λ˜μ—ˆμŠ΅λ‹ˆλ‹€!

μ»΄ν¬λ„ŒνŠΈμ˜ ꡬ쑰와 μŠ€νƒ€μΌλ§μ΄ κΉ”λ”ν•˜κ²Œ μ •λ¦¬λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. μ‹€μ œ μ»¨ν…μΈ μ˜ λ ˆμ΄μ•„μ›ƒμ„ 잘 λ°˜μ˜ν•˜κ³  μžˆμ–΄ μžμ—°μŠ€λŸ¬μš΄ λ‘œλ”© μƒνƒœλ₯Ό ν‘œν˜„ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

src/app/(crew)/crew/detail/[id]/_components/gathering-list-section.tsx (1)

10-10: μŠ€μΌˆλ ˆν†€ UI κ΅¬ν˜„μ΄ 적절히 μ΄λ£¨μ–΄μ‘ŒμŠ΅λ‹ˆλ‹€.

κΈ°μ‘΄ Loader μ»΄ν¬λ„ŒνŠΈλ₯Ό GatheringSkeletonList둜 κ΅μ²΄ν•œ 것은 μ‚¬μš©μž κ²½ν—˜ ν–₯상에 도움이 될 κ²ƒμœΌλ‘œ λ³΄μž…λ‹ˆλ‹€.

Also applies to: 54-54

src/app/(crew)/crew/detail/[id]/_components/detail-crew-container.tsx (2)

11-13: μ»΄ν¬λ„ŒνŠΈ μ˜μ‘΄μ„±μ΄ 적절히 μΆ”κ°€λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

μƒˆλ‘œμš΄ μŠ€μΌˆλ ˆν†€ UI와 μ—λŸ¬ 처리λ₯Ό μœ„ν•œ μ»΄ν¬λ„ŒνŠΈλ“€μ΄ 잘 μž„ν¬νŠΈλ˜μ—ˆμŠ΅λ‹ˆλ‹€.


115-115: μŠ€μΌˆλ ˆν†€ UI 적용이 잘 λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

일반 λ‘œλ” λŒ€μ‹  상세 νŽ˜μ΄μ§€μ— νŠΉν™”λœ μŠ€μΌˆλ ˆν†€ UIλ₯Ό μ‚¬μš©ν•˜μ—¬ μ‚¬μš©μž κ²½ν—˜μ΄ κ°œμ„ λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

Comment on lines +118 to +142
const renderErrorState = (message: string, actionLabel: string, action: () => void) => (
<div className="flex h-screen flex-col items-center justify-center">
<p className="mb-4 text-gray-500">{message} 😞</p>
<Button className="btn-filled" onClick={action}>
{actionLabel}
</Button>
</div>
);

if (fetchError || !data) {
if (fetchError instanceof ApiError) {
try {
const errorData = JSON.parse(fetchError.message);

if (errorData.status === 'NOT_FOUND') {
return <p>크루 정보λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€</p>;
}
} catch (parseError) {
return <p>{`Error ${fetchError.message}`}</p>;
if (fetchError.status === 404) {
router.push('/404');
return null;
}
toast.error(fetchError.message || '🚫 μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.');
} else if (fetchError) {
toast.error('🚫 데이터 톡신에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.');
}
return <p>데이터 톡신에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.</p>;
}

if (!data) {
return <p>데이터λ₯Ό 뢈러올 수 μ—†μŠ΅λ‹ˆλ‹€.</p>;
const errorMessage = fetchError
? '데이터λ₯Ό λΆˆλŸ¬μ˜€λŠ” 데 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.'
: '데이터λ₯Ό 뢈러올 수 μ—†μŠ΅λ‹ˆλ‹€.';

return renderErrorState(errorMessage, 'λ‹€μ‹œ μ‹œλ„', refetch);
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

μ—λŸ¬ 처리 둜직 κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

μ—λŸ¬ μ²˜λ¦¬κ°€ κ°œμ„ λ˜μ—ˆμ§€λ§Œ, λ‹€μŒ 사항듀을 κ³ λ €ν•΄λ³΄μ‹œκΈ° λ°”λžλ‹ˆλ‹€:

  1. μ—λŸ¬ λ©”μ‹œμ§€λ₯Ό μƒμˆ˜λ‘œ λΆ„λ¦¬ν•˜μ—¬ 쀑앙 관리
  2. ApiError νƒ€μž… 체크 둜직 κ°œμ„ 

λ‹€μŒκ³Ό 같이 κ°œμ„ ν•΄λ³΄μ„Έμš”:

+const ERROR_MESSAGES = {
+  FETCH_FAILED: '데이터λ₯Ό λΆˆλŸ¬μ˜€λŠ” 데 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.',
+  NO_DATA: '데이터λ₯Ό 뢈러올 수 μ—†μŠ΅λ‹ˆλ‹€.',
+  NETWORK_ERROR: '🚫 데이터 톡신에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.',
+} as const;

-    if (fetchError instanceof ApiError) {
-      if (fetchError.status === 404) {
+    if (fetchError instanceof ApiError && fetchError.status === 404) {
         router.push('/404');
         return null;
-      }
-      toast.error(fetchError.message || '🚫 μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.');
-    } else if (fetchError) {
-      toast.error('🚫 데이터 톡신에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.');
     }
+    
+    const errorMessage = fetchError instanceof ApiError
+      ? fetchError.message
+      : ERROR_MESSAGES.NETWORK_ERROR;
+    
+    toast.error(errorMessage);
πŸ“ 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 renderErrorState = (message: string, actionLabel: string, action: () => void) => (
<div className="flex h-screen flex-col items-center justify-center">
<p className="mb-4 text-gray-500">{message} 😞</p>
<Button className="btn-filled" onClick={action}>
{actionLabel}
</Button>
</div>
);
if (fetchError || !data) {
if (fetchError instanceof ApiError) {
try {
const errorData = JSON.parse(fetchError.message);
if (errorData.status === 'NOT_FOUND') {
return <p>크루 정보λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€</p>;
}
} catch (parseError) {
return <p>{`Error ${fetchError.message}`}</p>;
if (fetchError.status === 404) {
router.push('/404');
return null;
}
toast.error(fetchError.message || '🚫 μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.');
} else if (fetchError) {
toast.error('🚫 데이터 톡신에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.');
}
return <p>데이터 톡신에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.</p>;
}
if (!data) {
return <p>데이터λ₯Ό 뢈러올 수 μ—†μŠ΅λ‹ˆλ‹€.</p>;
const errorMessage = fetchError
? '데이터λ₯Ό λΆˆλŸ¬μ˜€λŠ” 데 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.'
: '데이터λ₯Ό 뢈러올 수 μ—†μŠ΅λ‹ˆλ‹€.';
return renderErrorState(errorMessage, 'λ‹€μ‹œ μ‹œλ„', refetch);
const ERROR_MESSAGES = {
FETCH_FAILED: '데이터λ₯Ό λΆˆλŸ¬μ˜€λŠ” 데 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.',
NO_DATA: '데이터λ₯Ό 뢈러올 수 μ—†μŠ΅λ‹ˆλ‹€.',
NETWORK_ERROR: '🚫 데이터 톡신에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.',
} as const;
const renderErrorState = (message: string, actionLabel: string, action: () => void) => (
<div className="flex h-screen flex-col items-center justify-center">
<p className="mb-4 text-gray-500">{message} 😞</p>
<Button className="btn-filled" onClick={action}>
{actionLabel}
</Button>
</div>
);
if (fetchError || !data) {
if (fetchError instanceof ApiError && fetchError.status === 404) {
router.push('/404');
return null;
}
const errorMessage = fetchError instanceof ApiError
? fetchError.message
: ERROR_MESSAGES.NETWORK_ERROR;
toast.error(errorMessage);
const errorMessage = fetchError
? '데이터λ₯Ό λΆˆλŸ¬μ˜€λŠ” 데 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.'
: '데이터λ₯Ό 뢈러올 수 μ—†μŠ΅λ‹ˆλ‹€.';
return renderErrorState(errorMessage, 'λ‹€μ‹œ μ‹œλ„', refetch);

Copy link
Contributor

@yulrang yulrang left a comment

Choose a reason for hiding this comment

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

μˆ˜κ³ ν•˜μ…¨μŠ΅λ‹ˆλ‹€!!!! 😭

@github-actions
Copy link

Copy link
Contributor

@minkyung5x5 minkyung5x5 left a comment

Choose a reason for hiding this comment

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

μˆ˜κ³ ν•˜μ…¨μŠ΅λ‹ˆλ‹€-!!

@github-actions
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

λ””ν…ŒμΌ νŽ˜μ΄μ§€ λ‘œλ”© μˆ˜μ •

4 participants