Skip to content

Conversation

@minkyung5x5
Copy link
Contributor

@minkyung5x5 minkyung5x5 commented Nov 13, 2024

πŸ”– Issue Ticket

Ticket

✍️ Description

λ‚˜μ˜ λͺ¨μž„ API μΆ”κ°€
헀더에 μ°œν•œμ•½μ† μΆ”κ°€

βœ… Checklist

PR

  • Branch Convention 확인

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

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

Test

  • 둜컬 μž‘λ™ 확인

Summary by CodeRabbit

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

    • μ‚¬μš©μž κ°€μž… 및 둜그인 κΈ°λŠ₯에 λŒ€ν•œ API μš”μ²­μ— νƒ€μž„μ•„μ›ƒ 및 응닡 처리 λ§€κ°œλ³€μˆ˜ μΆ”κ°€.
    • ν˜ΈμŠ€νŒ…λœ λͺ¨μž„ λͺ©λ‘μ„ κ°€μ Έμ˜€λŠ” μƒˆλ‘œμš΄ API κΈ°λŠ₯ μΆ”κ°€.
    • μ°Έμ—¬ν•œ λͺ¨μž„ λͺ©λ‘μ„ κ°€μ Έμ˜€λŠ” μƒˆλ‘œμš΄ API κΈ°λŠ₯ μΆ”κ°€.
    • ν˜ΈμŠ€νŒ…λœ λͺ¨μž„을 ν‘œμ‹œν•˜λŠ” μƒˆ νŽ˜μ΄μ§€ μ»΄ν¬λ„ŒνŠΈ μΆ”κ°€.
    • μ°Έμ—¬ν•œ λͺ¨μž„을 ν‘œμ‹œν•˜λŠ” μƒˆ νŽ˜μ΄μ§€ μ»΄ν¬λ„ŒνŠΈ μΆ”κ°€.
    • 헀더 λ‚΄λΉ„κ²Œμ΄μ…˜ 링크λ₯Ό λ™μ μœΌλ‘œ λ Œλ”λ§ν•˜λŠ” κΈ°λŠ₯ κ°œμ„ .
    • μš”μΌμ„ λ™μ μœΌλ‘œ ν‘œμ‹œν•˜λŠ” κΈ°λŠ₯ κ°œμ„ .
  • 버그 μˆ˜μ •

    • API μš”μ²­μ˜ 였λ₯˜ 처리 κ°œμ„ .
  • λ¬Έμ„œν™”

    • λ‚ μ§œ ν˜•μ‹μ„ μš”μ²­μ— 맞게 λ³€ν™˜ν•˜λŠ” μƒˆλ‘œμš΄ μœ ν‹Έλ¦¬ν‹° ν•¨μˆ˜ μΆ”κ°€.

@minkyung5x5 minkyung5x5 linked an issue Nov 13, 2024 that may be closed by this pull request
@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2024

Walkthrough

이 ν’€ λ¦¬ν€˜μŠ€νŠΈλŠ” μ‚¬μš©μž κ°€μž… 및 둜그인 API ν˜ΈμΆœμ„ μœ„ν•œ ν•¨μˆ˜μ— νƒ€μž„μ•„μ›ƒ 및 응닡 처리 λ§€κ°œλ³€μˆ˜λ₯Ό μΆ”κ°€ν•˜κ³ , μƒˆλ‘œμš΄ ν˜ΈμŠ€νŒ… 및 μ°Έμ—¬ λͺ¨μž„ λͺ©λ‘μ„ κ°€μ Έμ˜€λŠ” κΈ°λŠ₯을 μΆ”κ°€ν•©λ‹ˆλ‹€. λ˜ν•œ 기쑴의 λͺ¨μž„ κ΄€λ ¨ API 및 쿼리 ν•¨μˆ˜κ°€ μ‚­μ œλ˜κ±°λ‚˜ μˆ˜μ •λ˜μ—ˆμœΌλ©°, μƒˆλ‘œμš΄ νŽ˜μ΄μ§€ μ»΄ν¬λ„ŒνŠΈκ°€ μΆ”κ°€λ˜μ—ˆμŠ΅λ‹ˆλ‹€. μ „λ°˜μ μœΌλ‘œ API μš”μ²­ 및 데이터 처리 방식이 κ°œμ„ λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

Changes

파일 경둜 λ³€κ²½ μš”μ•½
src/_apis/auth/auth-apis.tsx signupUser 및 loginUser ν•¨μˆ˜μ— νƒ€μž„μ•„μ›ƒ(5000ms) 및 응닡 처리 λ§€κ°œλ³€μˆ˜ μΆ”κ°€. μš”μ²­ λ³Έλ¬Έ ν˜•μ‹ 정리.
src/_apis/gathering/gathering-apis.tsx getGathering ν•¨μˆ˜ μ‚­μ œ.
src/_apis/my-gathering/hosted-gathering-list-apis.ts getHostedGatheringList(startDate: string) ν•¨μˆ˜ μΆ”κ°€.
src/_apis/my-gathering/joined-gathering-list-apis.ts getJoinedGatheringList(startDate: string) ν•¨μˆ˜ μΆ”κ°€.
src/_queries/gathering/gathering-queries.tsx useGetGatheringQuery ν•¨μˆ˜ μ‚­μ œ.
src/_queries/my-gathering/hosted-gathering-list-queries.ts useGetHostedGatheringListQuery(startDate: string) ν•¨μˆ˜ μΆ”κ°€.
src/_queries/my-gathering/joined-gathering-list-queries.ts useGetJoinedGatheringListQuery(startDate: string) ν•¨μˆ˜ μΆ”κ°€.
src/app/(crew)/my-gathering/_component/gathering-list-with-date.tsx getDayOfWeek ν•¨μˆ˜ μ‚¬μš©μœΌλ‘œ μš”μΌ ν‘œμ‹œ 방식 λ³€κ²½.
src/app/(crew)/my-gathering/creation/page.tsx CreationPage μ»΄ν¬λ„ŒνŠΈ μ‚­μ œ.
src/app/(crew)/my-gathering/hosted/page.tsx MyGatheringHostedPage μ»΄ν¬λ„ŒνŠΈ μΆ”κ°€.
src/app/(crew)/my-gathering/joined/page.tsx MyGatheringJoinedPage μ»΄ν¬λ„ŒνŠΈ μΆ”κ°€.
src/app/(crew)/my-gathering/layout.tsx myGatheringTabs λ°°μ—΄μ—μ„œ νƒ­ ID 및 경둜 μ—…λ°μ΄νŠΈ.
src/app/(crew)/my-gathering/page.tsx λ¦¬λ””λ ‰μ…˜ 경둜 λ³€κ²½: /my-gathering/participationμ—μ„œ /my-gathering/joined둜.
src/app/(crew)/my-gathering/participation/page.tsx ParticipationPage μ»΄ν¬λ„ŒνŠΈ μ‚­μ œ.
src/components/common/header/presenter.tsx λ‚΄λΉ„κ²Œμ΄μ…˜ 링크 λ°°μ—΄ μΆ”κ°€ 및 λ Œλ”λ§ 방식 λ‹¨μˆœν™”.
src/utils/api.ts ApiError 클래슀 및 fetchApi ν•¨μˆ˜ μˆ˜μ •, μƒˆλ‘œμš΄ λ§€κ°œλ³€μˆ˜ μΆ”κ°€ 및 였λ₯˜ 처리 κ°œμ„ .
src/utils/format-date.ts getDayOfWeek 및 formatDateToRequest ν•¨μˆ˜ μΆ”κ°€.
tailwind.config.ts 높이 μœ ν‹Έλ¦¬ν‹° 13 μΆ”κ°€.

Possibly related PRs

  • Feat/101/login signup apiΒ #106: 이 PR은 signupUser 및 loginUser ν•¨μˆ˜μ™€ κ΄€λ ¨λœ λ³€κ²½ μ‚¬ν•­μœΌλ‘œ, 인증 API μ—”λ“œν¬μΈνŠΈ 및 응닡 처리λ₯Ό μˆ˜μ •ν•˜μ—¬ 전체 API μƒν˜Έμž‘μš©μ„ ν–₯μƒμ‹œν‚΅λ‹ˆλ‹€.
  • DetailPage api μ—°κ²°Β #114: 이 PR은 μ„ΈλΆ€ νŽ˜μ΄μ§€μ— λŒ€ν•œ μƒˆλ‘œμš΄ API 연결을 λ„μž…ν•˜λ©°, getCrewDetail ν•¨μˆ˜λ₯Ό μˆ˜μ •ν•˜μ—¬ μ£Όμš” PR의 API μƒν˜Έμž‘μš© 및 응닡 μ²˜λ¦¬μ™€ μΌμΉ˜ν•©λ‹ˆλ‹€.

Suggested labels

api, pages

Suggested reviewers

  • Rangbyeolang
  • HaeJungg
  • yulrang

🐰 λ³€ν™”μ˜ μˆœκ°„, κΈ°λ»ν•˜λ©°
μƒˆλ‘œμš΄ λͺ¨μž„이 νŽΌμ³μ§€λ„€!
κ°€μž…κ³Ό 둜그인, 더 λΉ λ₯΄κ²Œ,
ν•¨κ»˜ν•˜λŠ” λ‚ λ“€, 즐거움이 가득해! 🌼✨


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

🧹 Outside diff range and nitpick comments (12)
src/app/(crew)/my-gathering/page.tsx (1)

4-5: 도달할 수 μ—†λŠ” return 문이 μžˆμŠ΅λ‹ˆλ‹€.

redirect ν•¨μˆ˜ 호좜 μ΄ν›„μ˜ return null ꡬ문은 μ‹€ν–‰λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. μ½”λ“œμ˜ λͺ…확성을 μœ„ν•΄ λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€:

-  redirect('/my-gathering/joined');
-  return null;
+  redirect('/my-gathering/joined');
src/_queries/my-gathering/hosted-gathering-list-queries.ts (1)

4-10: 캐싱 μ„€μ • μΆ”κ°€λ₯Ό κ³ λ €ν•΄λ³΄μ„Έμš”.

μ„±λŠ₯ μ΅œμ ν™”λ₯Ό μœ„ν•΄ staleTimeκ³Ό cacheTime 섀정을 μΆ”κ°€ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

 export function useGetHostedGatheringListQuery(startDate: string) {
   return {
     queryKey: ['gatheringDetail', startDate],
     queryFn: () => getHostedGatheringList(startDate),
     select: (data: GatheringCardProps[]) => data,
+    staleTime: 5 * 60 * 1000, // 5λΆ„
+    cacheTime: 30 * 60 * 1000, // 30λΆ„
   };
 }
src/_queries/my-gathering/joined-gathering-list-queries.ts (1)

6-6: 쿼리 ν‚€ ꡬ쑰 κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

ν˜„μž¬ 쿼리 ν‚€κ°€ λ„ˆλ¬΄ μΌλ°˜μ μž…λ‹ˆλ‹€. 더 ꡬ체적인 ν‚€λ₯Ό μ‚¬μš©ν•˜μ—¬ μΊμ‹œ μΆ©λŒμ„ λ°©μ§€ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

-    queryKey: ['gatheringDetail', startDate],
+    queryKey: ['joinedGatheringList', startDate],
src/_apis/my-gathering/hosted-gathering-list-apis.ts (1)

4-12: μ„±λŠ₯ μ΅œμ ν™”λ₯Ό μœ„ν•œ 캐싱 μ „λž΅ μ œμ•ˆ

λͺ¨μž„ λͺ©λ‘ λ°μ΄ν„°λŠ” 자주 λ³€κ²½λ˜μ§€ μ•Šμ„ κ²ƒμœΌλ‘œ μ˜ˆμƒλ˜λ―€λ‘œ, React Query의 캐싱 κΈ°λŠ₯을 ν™œμš©ν•˜λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€. λ‹€μŒκ³Ό 같은 섀정을 κ³ λ €ν•΄λ³΄μ„Έμš”:

  1. staleTime μ„€μ •μœΌλ‘œ λΆˆν•„μš”ν•œ API 호좜 κ°μ†Œ
  2. cacheTime μ„€μ •μœΌλ‘œ μΊμ‹œ μœ μ§€ κΈ°κ°„ μ΅œμ ν™”
  3. ν•„μš”ν•œ 경우 μˆ˜λ™ μΊμ‹œ λ¬΄νš¨ν™” 둜직 μΆ”κ°€
src/utils/format-date.ts (2)

22-28: μž…λ ₯κ°’ μœ νš¨μ„± 검사 μΆ”κ°€ ν•„μš”

λ‚ μ§œ λ¬Έμžμ—΄μ΄ μœ νš¨ν•˜μ§€ μ•Šμ€ 경우 μ²˜λ¦¬κ°€ ν•„μš”ν•©λ‹ˆλ‹€. 잘λͺ»λœ μž…λ ₯κ°’μœΌλ‘œ μΈν•œ 였λ₯˜λ₯Ό λ°©μ§€ν•˜κΈ° μœ„ν•΄ λ‹€μŒκ³Ό 같은 κ°œμ„ μ„ μ œμ•ˆν•©λ‹ˆλ‹€.

 export function getDayOfWeek(dateString: string) {
   const daysInKorean = ['μΌμš”μΌ', 'μ›”μš”μΌ', 'ν™”μš”μΌ', 'μˆ˜μš”μΌ', 'λͺ©μš”일', 'κΈˆμš”μΌ', 'ν† μš”μΌ'];
+  if (!dateString || isNaN(new Date(dateString).getTime())) {
+    throw new Error('μœ νš¨ν•˜μ§€ μ•Šμ€ λ‚ μ§œ ν˜•μ‹μž…λ‹ˆλ‹€.');
+  }
   const date = new Date(dateString);
   const dayIndex = date.getDay();

   return daysInKorean[dayIndex];
 }

30-36: μž…λ ₯κ°’ μœ νš¨μ„± 검사 및 νƒ€μž… μ•ˆμ „μ„± κ°œμ„  ν•„μš”

Date 객체의 μœ νš¨μ„±μ„ κ²€μ‚¬ν•˜κ³  νƒ€μž… μ•ˆμ „μ„±μ„ 높이기 μœ„ν•œ κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

-export function formatDateToRequest(date: Date) {
+export function formatDateToRequest(date: Date | null | undefined) {
+  if (!date || !(date instanceof Date) || isNaN(date.getTime())) {
+    throw new Error('μœ νš¨ν•œ Date 객체가 ν•„μš”ν•©λ‹ˆλ‹€.');
+  }
+
   const year = date.getFullYear();
   const month = String(date.getMonth() + 1).padStart(2, '0');
   const day = String(date.getDate()).padStart(2, '0');

   return `${year}-${month}-${day}`;
 }
src/_apis/auth/auth-apis.tsx (1)

5-16: νƒ€μž„μ•„μ›ƒ κ°’μ˜ μƒμˆ˜ν™” ν•„μš”

ν•˜λ“œμ½”λ”©λœ νƒ€μž„μ•„μ›ƒ κ°’(5000ms)을 μƒμˆ˜λ‘œ λΆ„λ¦¬ν•˜μ—¬ κ΄€λ¦¬ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€. μ΄λŠ” μœ μ§€λ³΄μˆ˜μ„±μ„ ν–₯μƒμ‹œν‚€κ³  λ‹€λ₯Έ API 호좜과의 일관성을 보μž₯ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μƒμˆ˜λ₯Ό μΆ”κ°€ν•˜λŠ” 것을 μ œμ•ˆν•©λ‹ˆλ‹€:

+const AUTH_API_TIMEOUT = 5000;

 export function signupUser(data: SignupRequest): Promise<{ data: SignupResponse }> {
   return fetchApi<{ data: SignupResponse; headers: Headers }>(
     '/auths/signup',
     {
       method: 'POST',
       headers: {
         'Content-Type': 'application/json',
       },
       body: JSON.stringify(data),
     },
-    5000,
+    AUTH_API_TIMEOUT,
     true,
   ).then((response) => {
src/app/(crew)/my-gathering/hosted/page.tsx (2)

1-10: μž„ν¬νŠΈ ꡬ문 정리가 ν•„μš”ν•©λ‹ˆλ‹€

μž„ν¬νŠΈ ꡬ문을 λ‹€μŒκ³Ό 같은 μˆœμ„œλ‘œ μ •λ¦¬ν•˜λ©΄ μ½”λ“œμ˜ 가독성이 ν–₯상될 것 κ°™μŠ΅λ‹ˆλ‹€:

  1. μ™ΈλΆ€ 라이브러리 (react, @tanstack/react-query)
  2. μ»€μŠ€ν…€ 쿼리/API
  3. μœ ν‹Έλ¦¬ν‹°
  4. μ»΄ν¬λ„ŒνŠΈ
  5. νƒ€μž…
'use client';

import { useEffect, useState } from 'react';
import { useQuery } from '@tanstack/react-query';

import { useGetHostedGatheringListQuery } from '@/src/_queries/my-gathering/hosted-gathering-list-queries';

import { formatDateToRequest } from '@/src/utils/format-date';

import GatheringListWithDate from '@/src/app/(crew)/my-gathering/_component/gathering-list-with-date';
import PopOverCalendar from '@/src/components/common/input/pop-over-calendar';

import { GatheringCardProps } from '@/src/types/gathering-data';

27-35: μ ‘κ·Όμ„± κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€

μ‹œλ§¨ν‹± HTMLκ³Ό μ ‘κ·Όμ„± 속성을 μΆ”κ°€ν•˜μ—¬ μ‚¬μš©μž κ²½ν—˜μ„ κ°œμ„ ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

  return (
-   <div>
+   <main role="main" aria-label="λ‚΄κ°€ μ£Όμ΅œν•œ λͺ¨μž„">
-     <div className="py-4 md:py-6">
+     <section className="py-4 md:py-6" aria-label="λ‚ μ§œ 선택">
        <PopOverCalendar value={selectedDate} onChange={(d) => setSelectedDate(d)} />
-     </div>
+     </section>
      {hostedGatheringList && <GatheringListWithDate gatheringList={hostedGatheringList} />}
-   </div>
+   </main>
  );
src/app/(crew)/my-gathering/joined/page.tsx (1)

19-25: useEffect μ΅œμ ν™” ν•„μš”

ν˜„μž¬ κ΅¬ν˜„λœ 두 개의 useEffect에 κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같은 κ°œμ„ μ‚¬ν•­μ„ μ œμ•ˆλ“œλ¦½λ‹ˆλ‹€:

  1. joinedGatheringList μƒνƒœλŠ” λΆˆν•„μš”ν•˜λ―€λ‘œ μ œκ±°ν•˜κ³  dataλ₯Ό 직접 μ‚¬μš©
  2. refetchλ₯Ό μ˜μ‘΄μ„± 배열에 μΆ”κ°€
- useEffect(() => {
-   setJoinedGatheringList(data);
- }, [data]);

  useEffect(() => {
    refetch();
-  }, [selectedDate]);
+  }, [selectedDate, refetch]);
src/components/common/header/presenter.tsx (1)

29-29: μŠ€νƒ€μΌλ§ μƒμˆ˜ν™”λ₯Ό κ³ λ €ν•΄λ³΄μ„Έμš”.

ν˜„μž¬ ν•˜λ“œμ½”λ”©λœ spacing κ°’λ“€(space-x-2, space-x-5 λ“±)을 theme μƒμˆ˜λ‚˜ μ„€μ • 파일둜 λΆ„λ¦¬ν•˜λ©΄ 일관성 μžˆλŠ” λ””μžμΈ μ‹œμŠ€ν…œ ꡬ좕에 도움이 될 것 κ°™μŠ΅λ‹ˆλ‹€.

Also applies to: 31-31

tailwind.config.ts (1)

45-45: 높이 μœ ν‹Έλ¦¬ν‹° μΆ”κ°€κ°€ μ μ ˆν•΄ λ³΄μž…λ‹ˆλ‹€.

height-13 μœ ν‹Έλ¦¬ν‹°μ˜ μΆ”κ°€κ°€ κΈ°μ‘΄ νŒ¨ν„΄μ„ 잘 λ”°λ₯΄κ³  μžˆμŠ΅λ‹ˆλ‹€. λ‹€λ§Œ, 이 νŠΉμ • 높이값(52px)이 μ–΄λ–€ UI μš”μ†Œλ₯Ό μœ„ν•΄ μΆ”κ°€λ˜μ—ˆλŠ”μ§€ μ£Όμ„μœΌλ‘œ λ¬Έμ„œν™”ν•˜λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 주석을 μΆ”κ°€ν•˜λŠ” 것을 μ œμ•ˆν•©λ‹ˆλ‹€:

  height: {
    7.5: '30px',
    12.5: '50px',
-   13: '52px',
+   13: '52px', // λͺ¨μž„ κ΄€λ ¨ UI μ»΄ν¬λ„ŒνŠΈμ˜ κΈ°λ³Έ 높이값
    27.5: '110px',
  },
πŸ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between a8816c8 and e47db68.

πŸ“’ Files selected for processing (18)
  • src/_apis/auth/auth-apis.tsx (1 hunks)
  • src/_apis/gathering/gathering-apis.tsx (0 hunks)
  • src/_apis/my-gathering/hosted-gathering-list-apis.ts (1 hunks)
  • src/_apis/my-gathering/joined-gathering-list-apis.ts (1 hunks)
  • src/_queries/gathering/gathering-queries.tsx (0 hunks)
  • src/_queries/my-gathering/hosted-gathering-list-queries.ts (1 hunks)
  • src/_queries/my-gathering/joined-gathering-list-queries.ts (1 hunks)
  • src/app/(crew)/my-gathering/_component/gathering-list-with-date.tsx (2 hunks)
  • src/app/(crew)/my-gathering/creation/page.tsx (0 hunks)
  • src/app/(crew)/my-gathering/hosted/page.tsx (1 hunks)
  • src/app/(crew)/my-gathering/joined/page.tsx (1 hunks)
  • src/app/(crew)/my-gathering/layout.tsx (1 hunks)
  • src/app/(crew)/my-gathering/page.tsx (1 hunks)
  • src/app/(crew)/my-gathering/participation/page.tsx (0 hunks)
  • src/components/common/header/presenter.tsx (1 hunks)
  • src/utils/api.ts (2 hunks)
  • src/utils/format-date.ts (1 hunks)
  • tailwind.config.ts (1 hunks)
πŸ’€ Files with no reviewable changes (4)
  • src/_apis/gathering/gathering-apis.tsx
  • src/_queries/gathering/gathering-queries.tsx
  • src/app/(crew)/my-gathering/creation/page.tsx
  • src/app/(crew)/my-gathering/participation/page.tsx
πŸ”‡ Additional comments (15)
src/app/(crew)/my-gathering/page.tsx (1)

4-4: λ¦¬λ‹€μ΄λ ‰μ…˜ κ΅¬ν˜„μ΄ μ μ ˆν•©λ‹ˆλ‹€.

Next.js의 redirect ν•¨μˆ˜λ₯Ό μ‚¬μš©ν•˜μ—¬ κΈ°λ³Έ κ²½λ‘œμ—μ„œ '/my-gathering/joined'둜 λ¦¬λ‹€μ΄λ ‰μ…˜ν•˜λŠ” κ΅¬ν˜„μ΄ κΉ”λ”ν•©λ‹ˆλ‹€.

src/_queries/my-gathering/hosted-gathering-list-queries.ts (1)

4-10: κ΅¬ν˜„μ΄ κΉ”λ”ν•˜κ³  νƒ€μž…μ΄ 잘 μ •μ˜λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€!

React Query νŒ¨ν„΄μ„ 잘 λ”°λ₯΄κ³  있으며, νƒ€μž…μŠ€ν¬λ¦½νŠΈλ₯Ό 적절히 ν™œμš©ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

src/_queries/my-gathering/joined-gathering-list-queries.ts (1)

1-2: LGTM! ν•„μš”ν•œ μ˜μ‘΄μ„±λ“€μ΄ 잘 μž„ν¬νŠΈλ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

νƒ€μž…κ³Ό API ν•¨μˆ˜κ°€ μ μ ˆν•˜κ²Œ μž„ν¬νŠΈλ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

src/_apis/my-gathering/hosted-gathering-list-apis.ts (1)

1-2: μž„ν¬νŠΈ ꡬ문이 적절히 κ΅¬μ„±λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€!

ν•„μš”ν•œ μœ ν‹Έλ¦¬ν‹°μ™€ νƒ€μž…μ΄ λͺ…ν™•ν•˜κ²Œ μž„ν¬νŠΈλ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

src/_apis/my-gathering/joined-gathering-list-apis.ts (2)

1-2: μž„ν¬νŠΈ ꡬ문이 μ μ ˆν•©λ‹ˆλ‹€!

ν•„μš”ν•œ μœ ν‹Έλ¦¬ν‹°μ™€ νƒ€μž…μ„ μ ˆλŒ€ 경둜둜 μ˜¬λ°”λ₯΄κ²Œ μž„ν¬νŠΈν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.


5-5: API μ—”λ“œν¬μΈνŠΈ μ‚¬μš© 검증이 ν•„μš”ν•©λ‹ˆλ‹€.

이 API μ—”λ“œν¬μΈνŠΈκ°€ ν”„λ‘œμ νŠΈ μ „μ²΄μ—μ„œ μΌκ΄€λ˜κ²Œ μ‚¬μš©λ˜λŠ”μ§€ 확인이 ν•„μš”ν•©λ‹ˆλ‹€.

βœ… Verification successful

API μ—”λ“œν¬μΈνŠΈ μ‚¬μš©μ΄ ν”„λ‘œμ νŠΈ μ „μ²΄μ—μ„œ μΌκ΄€λ˜κ²Œ ν™•μΈλ˜μ—ˆμŠ΅λ‹ˆλ‹€.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# API μ—”λ“œν¬μΈνŠΈ μ‚¬μš© 검증
rg -g '!*.{json,md}' "/api/gatherings/joined" .

Length of output: 165

src/app/(crew)/my-gathering/layout.tsx (2)

8-9: 넀이밍이 더 λͺ…ν™•ν•΄μ‘ŒμŠ΅λ‹ˆλ‹€! πŸ‘

'participation'μ—μ„œ 'joined'둜, 'creation'μ—μ„œ 'hosted'둜의 변경은 각 νƒ­μ˜ κΈ°λŠ₯을 더 μ§κ΄€μ μœΌλ‘œ ν‘œν˜„ν•©λ‹ˆλ‹€. μ΄λŠ” μ½”λ“œμ˜ 가독성과 μœ μ§€λ³΄μˆ˜μ„±μ„ ν–₯μƒμ‹œν‚΅λ‹ˆλ‹€.


8-9: 라우트 변경사항 검증이 ν•„μš”ν•©λ‹ˆλ‹€.

μƒˆλ‘œμš΄ 라우트 경둜둜의 변경이 λ‹€λ₯Έ μ»΄ν¬λ„ŒνŠΈλ‚˜ νŽ˜μ΄μ§€μ— 영ν–₯을 λ―ΈμΉ  수 μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒ 슀크립트둜 라우트 μ°Έμ‘°λ₯Ό ν™•μΈν•΄μ£Όμ„Έμš”:

βœ… Verification successful

라우트 변경사항이 λ‹€λ₯Έ μ»΄ν¬λ„ŒνŠΈλ‚˜ νŽ˜μ΄μ§€μ— 영ν–₯을 λ―ΈμΉ˜μ§€ μ•ŠμŒμ„ ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: 이전 λΌμš°νŠΈμ™€ μƒˆλ‘œμš΄ 라우트 μ°Έμ‘° 검사

echo "이전 라우트 μ°Έμ‘° 검사:"
rg -l "my-gathering/(participation|creation)"

echo "\nμƒˆλ‘œμš΄ 라우트 κ΅¬ν˜„ 확인:"
fd -e tsx -e ts "joined|hosted" src/app/\(crew\)/my-gathering/

Length of output: 192

src/_apis/auth/auth-apis.tsx (1)

5-34: 인증 κ΄€λ ¨ νƒ€μž… μ•ˆμ „μ„± κ°œμ„  ν•„μš”

isAuth νŒŒλΌλ―Έν„°κ°€ μΆ”κ°€λ˜μ—ˆμ§€λ§Œ, 이에 λŒ€ν•œ νƒ€μž… μ •μ˜κ°€ λͺ…ν™•ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. λ˜ν•œ 응닡 ν—€λ”μ˜ νƒ€μž… μ•ˆμ „μ„±λ„ κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

헀더 νƒ€μž… μ‚¬μš©μ„ ν™•μΈν•˜κΈ° μœ„ν•΄ λ‹€μŒ 슀크립트λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€:

src/app/(crew)/my-gathering/hosted/page.tsx (1)

11-14: μƒνƒœ 관리가 잘 κ΅¬ν˜„λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€

λ‚ μ§œ 선택과 λͺ¨μž„ λͺ©λ‘μ— λŒ€ν•œ μƒνƒœ 관리가 μ μ ˆν•˜κ²Œ κ΅¬ν˜„λ˜μ–΄ 있으며, νƒ€μž… μ•ˆμ „μ„±λ„ 잘 κ³ λ €λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

src/app/(crew)/my-gathering/joined/page.tsx (1)

1-10: ν•„μš”ν•œ λͺ¨λ“  μ˜μ‘΄μ„±μ΄ μ˜¬λ°”λ₯΄κ²Œ μž„ν¬νŠΈλ˜μ—ˆμŠ΅λ‹ˆλ‹€.

λͺ¨λ“  μž„ν¬νŠΈκ°€ μ μ ˆν•˜κ²Œ κ΅¬μ„±λ˜μ–΄ 있으며, λΆˆν•„μš”ν•œ μž„ν¬νŠΈκ°€ μ—†μŠ΅λ‹ˆλ‹€.

src/app/(crew)/my-gathering/_component/gathering-list-with-date.tsx (2)

4-4: κΉ”λ”ν•œ import ꡬ문 κ΅¬μ„±μž…λ‹ˆλ‹€!

formatDate와 getDayOfWeek ν•¨μˆ˜λ₯Ό ν•œ μ€„λ‘œ κΉ”λ”ν•˜κ²Œ import ν–ˆμŠ΅λ‹ˆλ‹€.


30-32: μš”μΌ ν‘œμ‹œ κ°œμ„ μ΄ 잘 μ΄λ£¨μ–΄μ‘ŒμŠ΅λ‹ˆλ‹€!

ν•˜λ“œμ½”λ”©λœ μš”μΌ λŒ€μ‹  getDayOfWeek ν•¨μˆ˜λ₯Ό μ‚¬μš©ν•˜μ—¬ λ™μ μœΌλ‘œ μš”μΌμ„ ν‘œμ‹œν•˜λ„λ‘ κ°œμ„ ν•œ 것이 μ’‹μŠ΅λ‹ˆλ‹€. μ΄λŠ” λ‹€μŒκ³Ό 같은 μž₯점이 μžˆμŠ΅λ‹ˆλ‹€:

  • μœ μ§€λ³΄μˆ˜μ„± ν–₯상
  • λ‚ μ§œμ— λ”°λ₯Έ μ •ν™•ν•œ μš”μΌ ν‘œμ‹œ
  • μ½”λ“œ μž¬μ‚¬μš©μ„± 증가
src/components/common/header/presenter.tsx (2)

16-20: λ„€λΉ„κ²Œμ΄μ…˜ 링크 ꡬ쑰가 κ°œμ„ λ˜μ—ˆμŠ΅λ‹ˆλ‹€!

링크 정보λ₯Ό λ°°μ—΄λ‘œ λΆ„λ¦¬ν•˜μ—¬ κ΄€λ¦¬ν•˜λŠ” 것은 μœ μ§€λ³΄μˆ˜μ„±μ„ λ†’μ΄λŠ” 쒋은 μ ‘κ·Ό λ°©μ‹μž…λ‹ˆλ‹€.


16-51: λ„€λΉ„κ²Œμ΄μ…˜ 경둜 검증이 ν•„μš”ν•©λ‹ˆλ‹€.

μƒˆλ‘œ μΆ”κ°€λœ κ²½λ‘œλ“€μ΄ μ‹€μ œ νŽ˜μ΄μ§€ μ»΄ν¬λ„ŒνŠΈμ™€ μ˜¬λ°”λ₯΄κ²Œ λ§€ν•‘λ˜μ–΄ μžˆλŠ”μ§€ 확인이 ν•„μš”ν•©λ‹ˆλ‹€.

βœ… Verification successful

λ„€λΉ„κ²Œμ΄μ…˜ κ²½λ‘œκ°€ μ˜¬λ°”λ₯΄κ²Œ λ§€ν•‘λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of page components for each route

# Check for the existence of page components
echo "Checking page components for navigation routes..."
for route in "my-crew" "my-gathering" "my-favorite"; do
  fd -t f "page.tsx" "src/app" | grep -i "${route}"
done

Length of output: 607

export function useGetHostedGatheringListQuery(startDate: string) {
return {
queryKey: ['gatheringDetail', startDate],
queryFn: () => getHostedGatheringList(startDate),
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 호좜 μ‹€νŒ¨ μ‹œμ˜ μ—λŸ¬ μ²˜λ¦¬κ°€ λˆ„λ½λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. queryFnμ—μ„œ μ—λŸ¬λ₯Ό 적절히 μ²˜λ¦¬ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

-    queryFn: () => getHostedGatheringList(startDate),
+    queryFn: async () => {
+      try {
+        return await getHostedGatheringList(startDate);
+      } 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
queryFn: () => getHostedGatheringList(startDate),
queryFn: async () => {
try {
return await getHostedGatheringList(startDate);
} catch (error) {
console.error('λͺ¨μž„ λͺ©λ‘μ„ λΆˆλŸ¬μ˜€λŠ”λ° μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€:', error);
throw new Error('λͺ¨μž„ λͺ©λ‘μ„ λΆˆλŸ¬μ˜€λŠ”λ° μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.');
}
},

Comment on lines +4 to +10
export function useGetJoinedGatheringListQuery(startDate: string) {
return {
queryKey: ['gatheringDetail', startDate],
queryFn: () => getJoinedGatheringList(startDate),
select: (data: GatheringCardProps[]) => 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

μ—λŸ¬ 처리 및 νƒ€μž… μ•ˆμ „μ„± κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

  1. μ—λŸ¬ 처리 섀정이 λˆ„λ½λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.
  2. API 응닡 νƒ€μž…μ΄ λͺ…μ‹œμ μœΌλ‘œ μ •μ˜λ˜μ–΄ μžˆμ§€ μ•ŠμŠ΅λ‹ˆλ‹€.
  3. select ν•¨μˆ˜κ°€ 데이터λ₯Ό κ·ΈλŒ€λ‘œ λ°˜ν™˜ν•˜λ―€λ‘œ λΆˆν•„μš”ν•©λ‹ˆλ‹€.

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

-export function useGetJoinedGatheringListQuery(startDate: string) {
+export function useGetJoinedGatheringListQuery(startDate: string) {
+  type ApiResponse = GatheringCardProps[];
+
   return {
-    queryKey: ['gatheringDetail', startDate],
+    queryKey: ['joinedGatheringList', startDate],
-    queryFn: () => getJoinedGatheringList(startDate),
+    queryFn: async (): Promise<ApiResponse> => {
+      try {
+        return await getJoinedGatheringList(startDate);
+      } catch (error) {
+        throw new Error(`λͺ¨μž„ λͺ©λ‘μ„ κ°€μ Έμ˜€λŠ”λ° μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€: ${error}`);
+      }
+    },
     retry: 1,
     staleTime: 5 * 60 * 1000, // 5λΆ„
-    select: (data: GatheringCardProps[]) => 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
export function useGetJoinedGatheringListQuery(startDate: string) {
return {
queryKey: ['gatheringDetail', startDate],
queryFn: () => getJoinedGatheringList(startDate),
select: (data: GatheringCardProps[]) => data,
};
}
export function useGetJoinedGatheringListQuery(startDate: string) {
type ApiResponse = GatheringCardProps[];
return {
queryKey: ['joinedGatheringList', startDate],
queryFn: async (): Promise<ApiResponse> => {
try {
return await getJoinedGatheringList(startDate);
} catch (error) {
throw new Error(`λͺ¨μž„ λͺ©λ‘μ„ κ°€μ Έμ˜€λŠ”λ° μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€: ${error}`);
}
},
retry: 1,
staleTime: 5 * 60 * 1000, // 5λΆ„
};
}

Comment on lines +4 to +12
export function getHostedGatheringList(startDate: string): Promise<GatheringCardProps[]> {
const url = `/api/gatherings/hosted?startDate=${startDate}`;
return fetchApi<{ data: GatheringCardProps[] }>(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
}).then((response) => 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

API κ΅¬ν˜„μ— λŒ€ν•œ κ°œμ„  μ œμ•ˆ

λ‹€μŒ 사항듀을 κ³ λ €ν•΄ μ£Όμ‹œκΈ° λ°”λžλ‹ˆλ‹€:

  1. startDate λ§€κ°œλ³€μˆ˜μ— λŒ€ν•œ μœ νš¨μ„± 검사가 ν•„μš”ν•©λ‹ˆλ‹€
  2. URL νŒŒλΌλ―Έν„°μ˜ μ•ˆμ „ν•œ 인코딩이 ν•„μš”ν•©λ‹ˆλ‹€
  3. 였λ₯˜ 처리λ₯Ό λ³΄κ°•ν•˜λ©΄ μ’‹κ² μŠ΅λ‹ˆλ‹€

λ‹€μŒκ³Ό 같이 κ°œμ„ ν•΄ λ³΄μ‹œλŠ” 것을 μ œμ•ˆλ“œλ¦½λ‹ˆλ‹€:

-export function getHostedGatheringList(startDate: string): Promise<GatheringCardProps[]> {
-  const url = `/api/gatherings/hosted?startDate=${startDate}`;
+export function getHostedGatheringList(startDate: string): Promise<GatheringCardProps[]> {
+  if (!startDate || !isValidDate(startDate)) {
+    throw new Error('μœ νš¨ν•˜μ§€ μ•Šμ€ λ‚ μ§œ ν˜•μ‹μž…λ‹ˆλ‹€');
+  }
+
+  const url = `/api/gatherings/hosted?startDate=${encodeURIComponent(startDate)}`;
+
   return fetchApi<{ data: GatheringCardProps[] }>(url, {
     method: 'GET',
     headers: {
       'Content-Type': 'application/json',
     },
-  }).then((response) => response.data);
+  })
+    .then((response) => response.data)
+    .catch((error) => {
+      console.error('λͺ¨μž„ λͺ©λ‘μ„ κ°€μ Έμ˜€λŠ” 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€:', error);
+      throw error;
+    });

μΆ”κ°€λ‘œ λ‚ μ§œ μœ νš¨μ„± 검사λ₯Ό μœ„ν•œ 헬퍼 ν•¨μˆ˜λ„ ν•„μš”ν•©λ‹ˆλ‹€:

function isValidDate(dateString: string): boolean {
  const date = new Date(dateString);
  return date instanceof Date && !isNaN(date.getTime());
}

Comment on lines +4 to +12
export function getJoinedGatheringList(startDate: string): Promise<GatheringCardProps[]> {
const url = `/api/gatherings/joined?startDate=${startDate}`;
return fetchApi<{ data: GatheringCardProps[] }>(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
}).then((response) => 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

API κ΅¬ν˜„μ— λŒ€ν•œ λͺ‡ κ°€μ§€ κ°œμ„ μ‚¬ν•­μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

λ‹€μŒ 사항듀을 κ³ λ €ν•΄μ£Όμ‹œκΈ° λ°”λžλ‹ˆλ‹€:

  1. startDate νŒŒλΌλ―Έν„°μ— λŒ€ν•œ μœ νš¨μ„± 검사가 ν•„μš”ν•©λ‹ˆλ‹€.
  2. μ—λŸ¬ 처리 둜직이 λˆ„λ½λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.
  3. URL νŒŒλΌλ―Έν„° ꡬ성 μ‹œ 인코딩이 ν•„μš”ν•©λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 κ°œμ„ ν•˜λŠ” 것을 μ œμ•ˆλ“œλ¦½λ‹ˆλ‹€:

 export function getJoinedGatheringList(startDate: string): Promise<GatheringCardProps[]> {
+  if (!startDate || !/^\d{4}-\d{2}-\d{2}$/.test(startDate)) {
+    throw new Error('μœ νš¨ν•˜μ§€ μ•Šμ€ λ‚ μ§œ ν˜•μ‹μž…λ‹ˆλ‹€.');
+  }
-  const url = `/api/gatherings/joined?startDate=${startDate}`;
+  const url = `/api/gatherings/joined?startDate=${encodeURIComponent(startDate)}`;
   return fetchApi<{ data: GatheringCardProps[] }>(url, {
     method: 'GET',
     headers: {
       'Content-Type': 'application/json',
     },
-  }).then((response) => response.data);
+  }).then((response) => response.data)
+    .catch((error) => {
+      console.error('λͺ¨μž„ λͺ©λ‘μ„ κ°€μ Έμ˜€λŠ”λ° μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€:', error);
+      throw error;
+    });
 }

μΆ”κ°€λ‘œ, 응닡 νƒ€μž…μ˜ μ•ˆμ „μ„±μ„ μœ„ν•΄ zodλ‚˜ λ‹€λ₯Έ λŸ°νƒ€μž„ νƒ€μž… 검증 λ„κ΅¬μ˜ μ‚¬μš©μ„ κ³ λ €ν•΄λ³΄μ‹œκΈ° λ°”λžλ‹ˆλ‹€.

πŸ“ 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 function getJoinedGatheringList(startDate: string): Promise<GatheringCardProps[]> {
const url = `/api/gatherings/joined?startDate=${startDate}`;
return fetchApi<{ data: GatheringCardProps[] }>(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
}).then((response) => response.data);
}
export function getJoinedGatheringList(startDate: string): Promise<GatheringCardProps[]> {
if (!startDate || !/^\d{4}-\d{2}-\d{2}$/.test(startDate)) {
throw new Error('μœ νš¨ν•˜μ§€ μ•Šμ€ λ‚ μ§œ ν˜•μ‹μž…λ‹ˆλ‹€.');
}
const url = `/api/gatherings/joined?startDate=${encodeURIComponent(startDate)}`;
return fetchApi<{ data: GatheringCardProps[] }>(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
}).then((response) => response.data)
.catch((error) => {
console.error('λͺ¨μž„ λͺ©λ‘μ„ κ°€μ Έμ˜€λŠ”λ° μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€:', error);
throw error;
});
}

Comment on lines 23 to 34
return fetchApi<{ data: LoginResponse; headers: Headers }>(
'/auths/login',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
},
body: JSON.stringify(data),
}).then((response) => {
5000,
true,
).then((response) => {
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

μ—λŸ¬ 처리 κ°œμ„  ν•„μš”

νƒ€μž„μ•„μ›ƒμ΄λ‚˜ λ„€νŠΈμ›Œν¬ 였λ₯˜ λ°œμƒ μ‹œ μ μ ˆν•œ μ—λŸ¬ μ²˜λ¦¬κ°€ ν•„μš”ν•©λ‹ˆλ‹€. ν˜„μž¬λŠ” 기본적인 Promise rejection만 처리되고 μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μ—λŸ¬ 처리λ₯Ό κ°œμ„ ν•˜λŠ” 것을 μ œμ•ˆν•©λ‹ˆλ‹€:

 export function loginUser(data: LoginRequest): Promise<{ data: LoginResponse }> {
   return fetchApi<{ data: LoginResponse; headers: Headers }>(
     '/auths/login',
     {
       method: 'POST',
       headers: {
         'Content-Type': 'application/json',
       },
       body: JSON.stringify(data),
     },
     5000,
     true,
-  ).then((response) => {
+  ).then((response) => {
     const token = response.headers.get('Authorization');
+    if (!token) {
+      throw new Error('인증 토큰이 μ—†μŠ΅λ‹ˆλ‹€');
+    }
     return { data: { token } };
+  }).catch((error) => {
+    if (error.name === 'TimeoutError') {
+      throw new Error('둜그인 μš”μ²­ μ‹œκ°„μ΄ μ΄ˆκ³Όλ˜μ—ˆμŠ΅λ‹ˆλ‹€');
+    }
+    throw 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
return fetchApi<{ data: LoginResponse; headers: Headers }>(
'/auths/login',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
},
body: JSON.stringify(data),
}).then((response) => {
5000,
true,
).then((response) => {
return fetchApi<{ data: LoginResponse; headers: Headers }>(
'/auths/login',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
},
5000,
true,
).then((response) => {
const token = response.headers.get('Authorization');
if (!token) {
throw new Error('인증 토큰이 μ—†μŠ΅λ‹ˆλ‹€');
}
return { data: { token } };
}).catch((error) => {
if (error.name === 'TimeoutError') {
throw new Error('둜그인 μš”μ²­ μ‹œκ°„μ΄ μ΄ˆκ³Όλ˜μ—ˆμŠ΅λ‹ˆλ‹€');
}
throw error;
});

Comment on lines +27 to +35
return (
<div>
<div className="py-4 md:py-6">
<PopOverCalendar value={selectedDate} onChange={(d) => setSelectedDate(d)} />
</div>
{joinedGatheringList && <GatheringListWithDate gatheringList={joinedGatheringList} />}
</div>
);
}
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

UI μƒνƒœ 처리 및 μ ‘κ·Όμ„± κ°œμ„  ν•„μš”

λ‘œλ”© μƒνƒœ, μ—λŸ¬ μƒνƒœ ν‘œμ‹œ 및 μ ‘κ·Όμ„± 속성이 λˆ„λ½λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같은 κ°œμ„ μ„ μ œμ•ˆλ“œλ¦½λ‹ˆλ‹€:

  return (
-   <div>
+   <div role="main" aria-label="μ°Έμ—¬ν•œ λͺ¨μž„ λͺ©λ‘">
      <div className="py-4 md:py-6">
        <PopOverCalendar value={selectedDate} onChange={(d) => setSelectedDate(d)} />
      </div>
+     {isLoading && <div>λ‘œλ”© 쀑...</div>}
+     {error && <div role="alert">데이터λ₯Ό λΆˆλŸ¬μ˜€λŠ” 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {error.message}</div>}
-     {joinedGatheringList && <GatheringListWithDate gatheringList={joinedGatheringList} />}
+     {!isLoading && !error && data && <GatheringListWithDate gatheringList={data} />}
    </div>
  );

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +15 to +17
const { data, refetch } = useQuery(
useGetJoinedGatheringListQuery(formatDateToRequest(selectedDate)),
);
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

useQuery ν›… μ΅œμ ν™” ν•„μš”

ν˜„μž¬ κ΅¬ν˜„μ—μ„œ μ€‘μš”ν•œ useQuery κΈ°λŠ₯듀이 λˆ„λ½λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 κ°œμ„ ν•˜λŠ” 것을 μ œμ•ˆλ“œλ¦½λ‹ˆλ‹€:

- const { data, refetch } = useQuery(
+ const { data, error, isLoading, refetch } = useQuery(
    useGetJoinedGatheringListQuery(formatDateToRequest(selectedDate)),
+   {
+     retry: 1,
+     onError: (error) => setError(error),
+     staleTime: 5 * 60 * 1000, // 5λΆ„
+   }
  );

Committable suggestion skipped: line range outside the PR's diff.

src/utils/api.ts Outdated
}

return { data: await response.json() } as T;

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 응닡을 κ°•μ œλ‘œ T νƒ€μž…μœΌλ‘œ λ³€ν™˜ν•˜κ³  μžˆμ–΄ λŸ°νƒ€μž„ μ—λŸ¬κ°€ λ°œμƒν•  수 μžˆμŠ΅λ‹ˆλ‹€. 응닡 λ°μ΄ν„°μ˜ ν˜•νƒœλ₯Ό 보μž₯ν•˜κΈ° μœ„ν•΄ λ‹€μŒκ³Ό 같은 κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€:

- return { data: await response.json() } as T;
+ const responseData = await response.json();
+ if (!responseData || typeof responseData !== 'object') {
+   throw new ApiError(500, '잘λͺ»λœ 응닡 ν˜•μ‹');
+ }
+ return { data: responseData } as T;

λ˜ν•œ μ œλ„€λ¦­ νƒ€μž… T에 λŒ€ν•œ μ œμ•½ 쑰건을 μΆ”κ°€ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€:

export async function fetchApi<T extends { data: unknown }>(

url: string,
options: RequestInit = {},
timeout = 5000,
isAuth = false,
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

μ‚¬μš©λ˜μ§€ μ•ŠλŠ” λ§€κ°œλ³€μˆ˜ 발견

isAuth λ§€κ°œλ³€μˆ˜κ°€ ν•¨μˆ˜ λ‚΄λΆ€μ—μ„œ μ „ν˜€ μ‚¬μš©λ˜μ§€ μ•Šκ³  μžˆμŠ΅λ‹ˆλ‹€. ν˜„μž¬ 인증은 useAuthStoreμ—μ„œ κ°€μ Έμ˜¨ 토큰을 톡해 이미 처리되고 μžˆμŠ΅λ‹ˆλ‹€. λΆˆν•„μš”ν•œ λ§€κ°œλ³€μˆ˜λŠ” μ œκ±°ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

export async function fetchApi<T>(
  url: string,
  options: RequestInit = {},
  timeout = 5000,
-  isAuth = false,
): Promise<T> {
πŸ“ 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
isAuth = false,
isAuth = false,
```
↓
```suggestion

Comment on lines +43 to +51
{links.map(({ href, label }) => (
<Link
key={href}
href={isAuth ? href : '/login'}
className={`${pathname.startsWith(href) ? 'text-white' : 'text-blue-300'} ml-4`}
>
{label}
</Link>
))}
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

인증 처리 둜직 κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

ν˜„μž¬ 비인증 μƒνƒœμ—μ„œ λͺ¨λ“  링크가 /login으둜 λ¦¬λ‹€μ΄λ ‰νŠΈλ˜λŠ”λ°, λ‹€μŒκ³Ό 같은 κ°œμ„ μ‚¬ν•­μ„ κ³ λ €ν•΄λ³΄μ„Έμš”:

  1. 둜그인 ν›„ μ›λž˜ μ˜λ„ν–ˆλ˜ νŽ˜μ΄μ§€λ‘œ λ¦¬λ‹€μ΄λ ‰νŠΈ
  2. 비인증 μ‚¬μš©μžμ—κ²ŒλŠ” 링크λ₯Ό λΉ„ν™œμ„±ν™”ν•˜κ±°λ‚˜ 툴팁으둜 μ•ˆλ‚΄

μ˜ˆμ‹œ μ½”λ“œ:

- href={isAuth ? href : '/login'}
+ href={isAuth ? href : `/login?redirect=${encodeURIComponent(href)}`}
+ title={!isAuth ? '둜그인이 ν•„μš”ν•œ μ„œλΉ„μŠ€μž…λ‹ˆλ‹€' : ''}
πŸ“ 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
{links.map(({ href, label }) => (
<Link
key={href}
href={isAuth ? href : '/login'}
className={`${pathname.startsWith(href) ? 'text-white' : 'text-blue-300'} ml-4`}
>
{label}
</Link>
))}
{links.map(({ href, label }) => (
<Link
key={href}
href={isAuth ? href : `/login?redirect=${encodeURIComponent(href)}`}
className={`${pathname.startsWith(href) ? 'text-white' : 'text-blue-300'} ml-4`}
title={!isAuth ? '둜그인이 ν•„μš”ν•œ μ„œλΉ„μŠ€μž…λ‹ˆλ‹€' : ''}
>
{label}
</Link>
))}

@github-actions
Copy link

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

@HaeJungg HaeJungg left a comment

Choose a reason for hiding this comment

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

μˆ˜κ³ ν•˜μ…¨μŠ΅λ‹ˆλ‹€!πŸ‘

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

λ‚˜μ˜ 약속 νŽ˜μ΄μ§€ api

4 participants