Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ κ΄€λ¦¬μž ν”„λ‘œν•„ 뢈러였기 #89

Merged
merged 1 commit into from
Feb 2, 2025

Conversation

Ethen1264
Copy link
Contributor

@Ethen1264 Ethen1264 commented Feb 2, 2025

πŸ’‘ λ°°κ²½ 및 κ°œμš”

κ΄€λ¦¬μž ν”„λ‘œν•„ 뢈러였기

πŸ“ƒ μž‘μ—…λ‚΄μš©

admin νŽ˜μ΄μ§€μ— κ΄€λ¦¬μž ν”„λ‘œν•„μ„ λΆˆλŸ¬μ˜€λŠ” apiλ₯Ό ν†΅μ‹ ν–ˆλ‹€.

Summary by CodeRabbit

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

    • κ΄€λ¦¬μž νŽ˜μ΄μ§€μ—μ„œ 이름, 아이디, 이메일 λ“±μ˜ 정보가 λ™μ μœΌλ‘œ ν‘œμ‹œλ©λ‹ˆλ‹€.
    • 인증된 μš”μ²­μ„ 톡해 κ΄€λ¦¬μž 데이터λ₯Ό μ•ˆμ „ν•˜κ²Œ μ‘°νšŒν•  수 μžˆμŠ΅λ‹ˆλ‹€.
  • κ°œμ„  사항

    • 데이터 λ‘œλ”© 및 였λ₯˜ 처리 과정이 μ΅œμ ν™”λ˜μ–΄ κ΄€λ¦¬μž νŽ˜μ΄μ§€μ˜ μ•ˆμ •μ„±κ³Ό λ°˜μ‘ 속도가 ν–₯μƒλ˜μ—ˆμŠ΅λ‹ˆλ‹€.

@Ethen1264 Ethen1264 added ✨ Feature μ‹ κ·œ κΈ°λŠ₯ πŸ“¬ Type: API μ„œλ²„ API 톡신 labels Feb 2, 2025
@Ethen1264 Ethen1264 self-assigned this Feb 2, 2025
Copy link

coderabbitai bot commented Feb 2, 2025

Walkthrough

이 PR은 κ΄€λ¦¬μž κ΄€λ ¨ API와 UI의 κΈ°λŠ₯ ν™•μž₯을 ν¬ν•¨ν•©λ‹ˆλ‹€.
첫째, /admin/my μ—”λ“œν¬μΈνŠΈμ— λŒ€ν•œ GET 비동기 ν•¨μˆ˜κ°€ μΆ”κ°€λ˜μ–΄ μΏ ν‚€μ—μ„œ 토큰을 μΆ”μΆœν•œ ν›„ 인증 μš”μ²­μ„ μˆ˜ν–‰ν•˜λ©°, 성곡 및 μ—λŸ¬ 응닡을 적절히 μ²˜λ¦¬ν•©λ‹ˆλ‹€.
λ‘˜μ§Έ, AdminProfile μ»΄ν¬λ„ŒνŠΈκ°€ 이제 data prop을 λ°›μ•„ 동적 κ΄€λ¦¬μž 데이터λ₯Ό ν‘œμ‹œν•˜λ„λ‘ μ—…λ°μ΄νŠΈλ˜μ—ˆμœΌλ©°, 이λ₯Ό μœ„ν•΄ μƒˆ AdminData μΈν„°νŽ˜μ΄μŠ€κ°€ μΆ”κ°€λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
μ…‹μ§Έ, getAdminData ν•¨μˆ˜μ™€ 이λ₯Ό ν™œμš©ν•˜λŠ” useAdminData 훅이 λ„μž…λ˜μ–΄, AdminPageWrapperμ—μ„œ κ΄€λ¦¬μž 데이터λ₯Ό λ°›μ•„ UI에 λ°˜μ˜ν•©λ‹ˆλ‹€.

Changes

파일 경둜 λ³€κ²½ 사항 μš”μ•½
src/app/api/admin/my/route.ts GET 비동기 ν•¨μˆ˜ μΆ”κ°€: μΏ ν‚€μ—μ„œ 토큰 μΆ”μΆœ, 인증 헀더 포함 API 호좜, 성곡/μ—λŸ¬ 응닡 처리
src/entities/admin/ui/…/index.tsx AdminProfile μ»΄ν¬λ„ŒνŠΈμ— data prop μΆ”κ°€ 및 ν•˜λ“œμ½”λ”©λœ κ°’ λŒ€μ‹  동적 데이터(data.name, data.nickname, data.email) ν‘œμ‹œ
src/shared/types/admin/type.ts μƒˆλ‘œμš΄ AdminData μΈν„°νŽ˜μ΄μŠ€ μΆ”κ°€ (ν”„λ‘œνΌν‹°: name, nickname, email - λͺ¨λ‘ string νƒ€μž…)
src/widgets/admin/api/getAdminData.ts 및 src/widgets/admin/model/…/useAdminData.ts getAdminData 비동기 ν•¨μˆ˜ μΆ”κ°€ 및 useQueryλ₯Ό μ΄μš©ν•œ μƒˆλ‘œμš΄ 쿼리(requestAdminData) λ„μž…, κΈ°μ‘΄ ν›… λ°˜ν™˜κ°’μ— 쿼리 μΆ”κ°€
src/widgets/admin/ui/AdminPageWrapper/index.tsx useAdminData ν›… λ°˜ν™˜κ°’μ— requestAdminData λ³€μˆ˜ μΆ”κ°€, 이λ₯Ό ν™œμš©ν•΄ AdminProfile에 동적 데이터 전달

Sequence Diagram(s)

sequenceDiagram
    participant APW as AdminPageWrapper
    participant UA as useAdminData Hook
    participant GA as getAdminData
    participant API as API Server (/admin/my)

    APW ->> UA: useAdminData 호좜
    UA ->> GA: getAdminData 호좜
    GA ->> API: GET μš”μ²­ (토큰 포함)
    API -->> GA: 응닡 (AdminData)
    GA -->> UA: 데이터 λ°˜ν™˜
    UA -->> APW: 쿼리 κ²°κ³Ό λ°˜ν™˜
Loading

Possibly related PRs

Suggested reviewers

  • happytaeyoon

Poem

μ•ˆλ…•ν•˜μ„Έμš”, λ‚˜λŠ” λ―Όμ²©ν•œ 토끼!
μƒˆλ‘œ μΆ”κ°€λœ API와 ν•¨κ»˜ λ‹¬λ €λ‚˜κ°€λ„€ πŸ‡
μΏ ν‚€ 속 토큰 μ°Ύμ•„, 인증의 κΈΈ μ—΄κ³ ,
동적 데이터λ₯Ό ν’ˆμ–΄ AdminProfile에 빛을 λ”ν•˜λ‹ˆ,
μ½”λ“œ 숲 속을 즐겁게 λ›°λ…ΈλŠ” 우리 ν† λΌμ˜ λ…Έλž˜!

✨ Finishing Touches
  • πŸ“ Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 3

🧹 Nitpick comments (3)
src/app/api/admin/my/route.ts (1)

20-22: μ—λŸ¬ λ©”μ‹œμ§€ κ°œμ„  ν•„μš”

μ—λŸ¬ λ©”μ‹œμ§€κ°€ λ„ˆλ¬΄ μΌλ°˜μ μž…λ‹ˆλ‹€. 더 ꡬ체적인 μ—λŸ¬ λ©”μ‹œμ§€λ₯Ό μ œκ³΅ν•˜λ©΄ 디버깅에 도움이 될 것 κ°™μŠ΅λ‹ˆλ‹€.

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

     const message =
-      axiosError.response?.data?.message || 'admin data get failed';
+      axiosError.response?.data?.message || 'κ΄€λ¦¬μž 정보λ₯Ό κ°€μ Έμ˜€λŠ” 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.';
src/widgets/admin/model/useAdminData.ts (1)

20-23: 캐싱 μ„€μ • μΆ”κ°€ ꢌμž₯

κ΄€λ¦¬μž λ°μ΄ν„°μ˜ νŠΉμ„±μ„ κ³ λ €ν•˜μ—¬ μ μ ˆν•œ staleTimeκ³Ό cacheTime을 μ„€μ •ν•˜λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

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

   const requestAdminData = useQuery<AdminData, Error>({
     queryKey: ['requestAdminData'],
     queryFn: getAdminData,
+    staleTime: 5 * 60 * 1000, // 5λΆ„
+    cacheTime: 30 * 60 * 1000, // 30λΆ„
   });
src/entities/admin/ui/AdminProfile/index.tsx (1)

27-29: 데이터 바인딩이 μ˜¬λ°”λ₯΄κ²Œ κ΅¬ν˜„λ˜μ—ˆμŠ΅λ‹ˆλ‹€!

ProfileInfo μ»΄ν¬λ„ŒνŠΈλ₯Ό μž¬μ‚¬μš©ν•˜μ—¬ κ΄€λ¦¬μž 정보λ₯Ό 효율적으둜 ν‘œμ‹œν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

λ‹€λ§Œ, 데이터가 μ—†λŠ” κ²½μš°μ— λŒ€ν•œ 처리λ₯Ό μΆ”κ°€ν•˜λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

-          <ProfileInfo label="이름" value={data.name} />
-          <ProfileInfo label="아이디" value={data.nickname} />
-          <ProfileInfo label="이메일" value={data.email} />
+          <ProfileInfo label="이름" value={data.name ?? '-'} />
+          <ProfileInfo label="아이디" value={data.nickname ?? '-'} />
+          <ProfileInfo label="이메일" value={data.email ?? '-'} />
πŸ“œ Review details

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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between b3a4c4d and 473a4e5.

πŸ“’ Files selected for processing (6)
  • src/app/api/admin/my/route.ts (1 hunks)
  • src/entities/admin/ui/AdminProfile/index.tsx (3 hunks)
  • src/shared/types/admin/type.ts (1 hunks)
  • src/widgets/admin/api/getAdminData.ts (2 hunks)
  • src/widgets/admin/model/useAdminData.ts (2 hunks)
  • src/widgets/admin/ui/AdminPageWrapper/index.tsx (2 hunks)
πŸ”‡ Additional comments (4)
src/shared/types/admin/type.ts (1)

17-21: μΈν„°νŽ˜μ΄μŠ€ ꡬ쑰가 잘 μ •μ˜λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€!

κ΄€λ¦¬μž 데이터λ₯Ό μœ„ν•œ μΈν„°νŽ˜μ΄μŠ€κ°€ λͺ…ν™•ν•˜κ³  κ°„λ‹¨ν•˜κ²Œ μ •μ˜λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

src/widgets/admin/ui/AdminPageWrapper/index.tsx (2)

14-15: useAdminData ν›…μ˜ λ°˜ν™˜κ°’μ΄ μ˜¬λ°”λ₯΄κ²Œ κ΅¬μ‘°λΆ„ν•΄λ˜μ—ˆμŠ΅λ‹ˆλ‹€!

데이터와 λ‘œλ”© μƒνƒœλ₯Ό λͺ…ν™•ν•˜κ²Œ λΆ„λ¦¬ν•˜μ—¬ κ΄€λ¦¬ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.


26-26: 쑰건뢀 λ Œλ”λ§μ΄ μ μ ˆν•˜κ²Œ κ΅¬ν˜„λ˜μ—ˆμŠ΅λ‹ˆλ‹€!

requestAdmin 데이터가 μžˆμ„ λ•Œλ§Œ AdminProfile μ»΄ν¬λ„ŒνŠΈλ₯Ό λ Œλ”λ§ν•˜λŠ” 방식이 μ•ˆμ „ν•©λ‹ˆλ‹€.

Also applies to: 32-32

src/entities/admin/ui/AdminProfile/index.tsx (1)

3-3: νƒ€μž… μ •μ˜μ™€ props ꡬ쑰가 잘 κ΅¬ν˜„λ˜μ—ˆμŠ΅λ‹ˆλ‹€!

AdminData νƒ€μž…μ„ importν•˜κ³  μ»΄ν¬λ„ŒνŠΈμ˜ props둜 μ μ ˆν•˜κ²Œ μ‚¬μš©ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

Also applies to: 14-14

Comment on lines +14 to +17
export const getAdminData = async (): Promise<AdminData> => {
const response = await axios.get('/api/admin/my');
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

μ—λŸ¬ 처리 둜직 μΆ”κ°€ ν•„μš”

API 호좜 μ‹€νŒ¨ μ‹œμ˜ μ—λŸ¬ μ²˜λ¦¬κ°€ λˆ„λ½λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. try-catch 블둝을 μΆ”κ°€ν•˜μ—¬ μ—λŸ¬λ₯Ό 적절히 μ²˜λ¦¬ν•΄ μ£Όμ„Έμš”.

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

 export const getAdminData = async (): Promise<AdminData> => {
-  const response = await axios.get('/api/admin/my');
-  return response.data;
+  try {
+    const response = await axios.get('/api/admin/my');
+    return response.data;
+  } catch (error) {
+    console.error('κ΄€λ¦¬μž 데이터 쑰회 μ‹€νŒ¨:', 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
export const getAdminData = async (): Promise<AdminData> => {
const response = await axios.get('/api/admin/my');
return response.data;
};
export const getAdminData = async (): Promise<AdminData> => {
try {
const response = await axios.get('/api/admin/my');
return response.data;
} catch (error) {
console.error('κ΄€λ¦¬μž 데이터 쑰회 μ‹€νŒ¨:', error);
throw error;
}
};

Comment on lines +7 to +9
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

토큰 μœ νš¨μ„± 검사 μΆ”κ°€ ν•„μš”

accessToken이 μ—†λŠ” κ²½μš°μ— λŒ€ν•œ μ²˜λ¦¬κ°€ λˆ„λ½λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

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

   const cookieStore = cookies();
   const accessToken = cookieStore.get('accessToken')?.value;
+  
+  if (!accessToken) {
+    return NextResponse.json(
+      { error: '인증 토큰이 μ—†μŠ΅λ‹ˆλ‹€.' },
+      { status: 401 }
+    );
+  }
πŸ“ 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 cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;
if (!accessToken) {
return NextResponse.json(
{ error: '인증 토큰이 μ—†μŠ΅λ‹ˆλ‹€.' },
{ status: 401 }
);
}

@@ -13,7 +17,15 @@ export const useAdminData = () => {
queryFn: getRequestSignUp,
});

const isLoading = expoListData.isLoading || requestSignUpData.isLoading;
const requestAdminData = useQuery<AdminData, Error>({
queryKey: ['requestAdnubData'],
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

쿼리 ν‚€μ˜ μ˜€νƒ€λ₯Ό μˆ˜μ •ν•΄ μ£Όμ„Έμš”

'requestAdnubData'에 μ˜€νƒ€κ°€ μžˆμŠ΅λ‹ˆλ‹€.

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

-    queryKey: ['requestAdnubData'],
+    queryKey: ['requestAdminData'],
πŸ“ 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
queryKey: ['requestAdnubData'],
queryKey: ['requestAdminData'],

@Ethen1264 Ethen1264 merged commit 046e803 into develop Feb 2, 2025
2 checks passed
@Ethen1264 Ethen1264 deleted the feature/get-admin-data branch February 3, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature μ‹ κ·œ κΈ°λŠ₯ πŸ“¬ Type: API μ„œλ²„ API 톡신
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants