Skip to content

Comments

Api(client): arcons get api 연결#77

Merged
jjangminii merged 9 commits intodevelopfrom
api/#72/get-level-arcon
Sep 11, 2025
Merged

Api(client): arcons get api 연결#77
jjangminii merged 9 commits intodevelopfrom
api/#72/get-level-arcon

Conversation

@jjangminii
Copy link
Collaborator

@jjangminii jjangminii commented Sep 11, 2025

📌 Related Issues

관련된 Issue를 태그해주세요. (e.g. - close #25)

📄 Tasks

  • 네비바, 레벨 체이지 도토리 연결

⭐ PR Point (To Reviewer)

  • 기존 사이드바 안에 있던 api 관련 파일들 shared로 옮겼습니다 기존에 위치해 있던건 setting 파일 만들어서 안에 넣어 놨어요

📷 Screenshot

image

Summary by CodeRabbit

  • 신기능
    • 도토리 개수가 실시간 데이터로 레벨 페이지와 사이드바에 표시됩니다.
    • 콘텐츠 영역이 세로 스크롤을 지원하도록 레이아웃을 개선했습니다.
  • 개선
    • 데이터 로딩/오류 시 빈 화면으로 안전 처리하여 깜빡임을 줄였습니다.
  • 리팩터링
    • 데이터 요청 로직과 훅을 통합·정리해 구조를 단순화했습니다.
    • 내부 모듈 경로를 정리했습니다.
  • 잡무
    • 환경변수 파일(.env)을 버전 관리에서 제외했습니다.

@jjangminii jjangminii self-assigned this Sep 11, 2025
@jjangminii jjangminii linked an issue Sep 11, 2025 that may be closed by this pull request
@coderabbitai
Copy link

coderabbitai bot commented Sep 11, 2025

Warning

Rate limit exceeded

@jjangminii has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 45 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 297a9ea and 890b676.

📒 Files selected for processing (3)
  • apps/client/src/layout/Layout.tsx (1 hunks)
  • apps/client/src/pages/level/Level.tsx (2 hunks)
  • apps/client/src/shared/components/sidebar/Sidebar.tsx (4 hunks)

Walkthrough

레벨/사이드바에서 도토리(acorn) 수를 API로 연동하고 로딩/에러 흐름을 추가했습니다. 공용 API/쿼리/타입/유틸을 신설·이동하며, 기존 사이드바 전용 axios 모듈을 제거했습니다. main.tsx의 getQueryClient 경로가 변경되었고, 클라이언트 .gitignore에 .env가 추가되었습니다.

Changes

Cohort / File(s) Change Summary
환경설정(ignore)
apps/client/.gitignore
.env 무시 항목 추가
쿼리 클라이언트 경로 변경
apps/client/src/main.tsx
getQueryClient import 경로를 @shared/apis/setting/query/...로 이동
공용 API 유틸 신설/이동
apps/client/src/shared/apis/axios.ts, apps/client/src/shared/utils/formatDateTime.ts, apps/client/src/shared/types/api.ts
공용 axios 헬퍼 추가: getDashboardCategories, postCategory, getAcorns; 로컬 시간 포매터 formatLocalDateTime 추가; AcornsResponse 타입 추가
React Query 훅 정리/추가
apps/client/src/shared/apis/queries.ts
axios 소스 경로를 공용으로 변경, getAcorns 연동, useGetArcons 훅 추가, 타입 import 정리
사이드바 전용 axios 제거
apps/client/src/shared/components/sidebar/apis/axios.ts
파일 삭제(대시보드 카테고리 API 헬퍼 제거; 공용 모듈로 대체)
도토리 연동 - 레벨 페이지
apps/client/src/pages/level/Level.tsx
useGetArcons 사용하여 acornCount를 API로 획득; 로딩/에러 분기 추가; UI prop을 acornCount로 연결
도토리 연동 - 사이드바
apps/client/src/shared/components/sidebar/Sidebar.tsx
useGetArcons 도입, 로딩/에러 분기 추가, MyLevelItemacorns={acornCount} 전달

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UI_Level as Level Page
  participant UI_Sidebar as Sidebar
  participant Queries as useGetArcons (React Query)
  participant API as getAcorns()
  participant HTTP as apiRequest (Axios)
  participant BE as Backend

  par Level fetch
    UI_Level->>Queries: useGetArcons()
  and Sidebar fetch
    UI_Sidebar->>Queries: useGetArcons()
  end

  Queries->>API: fetch()
  API->>API: now = formatLocalDateTime(new Date)
  API->>HTTP: GET /api/v1/users/acorns?now=...
  HTTP->>BE: Request
  BE-->>HTTP: { acornCount, remindDateTime }
  HTTP-->>Queries: data
  alt 성공
    Queries-->>UI_Level: data.acornCount
    Queries-->>UI_Sidebar: data.acornCount
    note over UI_Level,UI_Sidebar: 로딩 해제 → UI에 acornCount 반영
  else 에러
    Queries-->>UI_Level: isError
    Queries-->>UI_Sidebar: isError
    note over UI_Level,UI_Sidebar: 에러 분기(early return)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • jllee000
  • constantly-dev

Pre-merge checks (2 passed, 3 warnings)

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning 이 PR은 사이드바 및 레벨 페이지의 도토리 API 연결(#72)에 대한 변경을 반영하여 해당 이슈를 해결하였으나, 디자인 시스템의 프로그레스바 컴포넌트 구현을 요구하는 이슈(#25)에 대한 변경사항이 전혀 포함되어 있지 않습니다. 이슈 #25에 명시된 프로그레스바 컴포넌트 구현 작업을 추가하거나, 해당 이슈를 PR 링크에서 제거하여 연관성을 명확히 해주시기 바랍니다.
Out of Scope Changes Check ⚠️ Warning 도토리 API 연결(#72)과 직접 관련 없는 .env 무시 파일 추가, getDashboardCategories 및 postCategory API 헬퍼 추가, getQueryClient 경로 변경, formatLocalDateTime 유틸 추가 등 여러 변경이 함께 포함되어 있어 PR 범위가 불필요하게 확장되었습니다. API 연결 작업 외의 변경사항은 별도 PR로 분리하거나 불필요한 변경을 제거하여 PR 범위를 명확히 좁혀주시기 바랍니다.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed 제목 "Api(client): arcons get api 연결"은 이번 PR의 핵심인 클라이언트 측 arcons GET API 연결 작업을 명확하게 요약하며 간결한 형태로 작성되어 프로젝트 관례에 부합합니다.
Description Check ✅ Passed 현재 PR 설명은 Related Issues, Tasks, PR Point, Screenshot 섹션을 모두 포함하여 저장소의 템플릿 구조와 요구사항을 충족하고 있으며 각 섹션에 알맞은 내용이 구체적으로 기재되어 있습니다.

Poem

숲길을 톡톡, 도토리 카운트 셈해보니
오늘의 레벨, 새싹처럼 살포시 웃네 🌱
사이드바도 끄덕, “받았습니다!” 신호 보내고
시간은 T:HH:MM:SS로 반짝- 기록해두자
폴더는 정리, 경로는 새로, 힙하게 전진!
(\^_^)/ ᕱ⑅ᕱ — 코드토끼 출동!

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch api/#72/get-level-arcon

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the api api 연결 label Sep 11, 2025
@github-actions
Copy link

github-actions bot commented Sep 11, 2025

✅ Storybook chromatic 배포 확인:
🐿️ storybook

@jjangminii jjangminii merged commit e981d92 into develop Sep 11, 2025
5 checks passed
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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 41f03f2 and 297a9ea.

📒 Files selected for processing (9)
  • apps/client/.gitignore (1 hunks)
  • apps/client/src/main.tsx (1 hunks)
  • apps/client/src/pages/level/Level.tsx (2 hunks)
  • apps/client/src/shared/apis/axios.ts (1 hunks)
  • apps/client/src/shared/apis/queries.ts (2 hunks)
  • apps/client/src/shared/components/sidebar/Sidebar.tsx (4 hunks)
  • apps/client/src/shared/components/sidebar/apis/axios.ts (0 hunks)
  • apps/client/src/shared/types/api.ts (1 hunks)
  • apps/client/src/shared/utils/formatDateTime.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/client/src/shared/components/sidebar/apis/axios.ts
🧰 Additional context used
🧬 Code graph analysis (4)
apps/client/src/pages/level/Level.tsx (3)
apps/client/src/shared/apis/queries.ts (1)
  • useGetArcons (23-28)
apps/client/src/shared/utils/treeLevel.ts (1)
  • getTreeLevel (28-31)
apps/client/src/pages/level/components/TreeStatusCard.tsx (1)
  • TreeStatusCard (9-38)
apps/client/src/shared/apis/axios.ts (1)
apps/client/src/shared/utils/formatDateTime.ts (1)
  • formatLocalDateTime (1-9)
apps/client/src/shared/apis/queries.ts (2)
apps/client/src/shared/types/api.ts (1)
  • AcornsResponse (11-14)
apps/client/src/shared/apis/axios.ts (1)
  • getAcorns (16-22)
apps/client/src/shared/components/sidebar/Sidebar.tsx (1)
apps/client/src/shared/apis/queries.ts (1)
  • useGetArcons (23-28)
🔇 Additional comments (10)
apps/client/.gitignore (1)

25-25: 환경 변수 파일 추가가 적절합니다.

API 연동 작업에 필요한 환경 변수들을 보호하기 위해 .env 파일을 gitignore에 추가한 것이 좋습니다.

apps/client/src/shared/types/api.ts (1)

11-14: AcornsResponse 타입 정의가 명확합니다.

도토리 개수와 리마인드 시간을 포함하는 타입 정의가 적절하며, API 응답 구조를 잘 반영하고 있습니다.

apps/client/src/main.tsx (1)

5-5: 확인: getQueryClient가 새 경로에 존재합니다.
apps/client/src/shared/apis/setting/query/getQueryClient.ts 파일이 확인되었습니다.

apps/client/src/shared/utils/formatDateTime.ts (1)

1-9: 날짜 포맷팅 유틸리티가 잘 구현되었습니다.

ISO 8601 형식으로 로컬 시간을 포맷하는 함수가 명확하고 재사용 가능하게 작성되었습니다. padStart를 사용한 제로 패딩 처리도 적절합니다.

apps/client/src/pages/level/Level.tsx (2)

17-18: API 데이터 연동이 올바르게 구현되었습니다.

하드코딩된 값 대신 API에서 받은 acornCount를 사용하여 동적으로 레벨 정보를 계산하는 것이 좋습니다.


50-54: Badge 컴포넌트에 동적 데이터가 잘 연결되었습니다.

countNum={acornCount}로 실제 도토리 개수가 표시되도록 구현된 것이 적절합니다.

apps/client/src/shared/apis/queries.ts (2)

2-2: API 모듈 경로 변경이 적절합니다.

기존 사이드바 전용 API에서 공용 API 모듈로 이전한 것이 코드 구조 개선에 도움이 됩니다.


23-28: useGetArcons 훅이 올바르게 구현되었습니다.

React Query를 사용한 데이터 페칭 로직이 적절하며, 타입 정의도 명확합니다. 쿼리 키도 의미있게 설정되었습니다.

apps/client/src/shared/components/sidebar/Sidebar.tsx (1)

16-17: 도토리 API 연동이 성공적으로 구현되었습니다.

useGetArcons 훅을 사용하여 실시간 도토리 데이터를 가져오고, MyLevelItem에 동적으로 전달하는 구현이 올바릅니다.

Also applies to: 27-27, 72-72, 143-143

apps/client/src/shared/apis/axios.ts (1)

4-7: API 함수들이 잘 구현되었습니다.

getDashboardCategoriespostCategory 함수가 적절하게 구현되어 있고, 응답 구조도 일관성 있게 처리되고 있습니다.

Also applies to: 9-14

Comment on lines 14 to 15
if (isPending) return console.log('로딩중...');
if (isError) return console.log('에러...');
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

로딩 및 에러 상태 처리를 개선해주세요.

현재 console.log만 사용하고 있어서 사용자에게 적절한 피드백을 제공하지 못합니다. 사용자 경험을 위해 적절한 로딩 스피너나 에러 메시지를 표시해야 합니다.

다음과 같이 사용자 친화적인 상태 처리로 개선하세요:

-  if (isPending) return console.log('로딩중...');
-  if (isError) return console.log('에러...');
+  if (isPending) return <div>도토리 정보를 불러오는 중...</div>;
+  if (isError) return <div>도토리 정보를 불러오는데 실패했습니다. 다시 시도해주세요.</div>;
📝 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 (isPending) return console.log('로딩중...');
if (isError) return console.log('에러...');
if (isPending) return <div>도토리 정보를 불러오는 중...</div>;
if (isError) return <div>도토리 정보를 불러오는데 실패했습니다. 다시 시도해주세요.</div>;
🤖 Prompt for AI Agents
In apps/client/src/pages/level/Level.tsx around lines 14-15, replace the current
early returns that call console.log with proper JSX-based UI for loading and
error states: render a loading spinner or friendly "Loading..." component
(import or reuse your app's Spinner/Loader) when isPending is true, and render a
user-facing error message or an Error component (with optional retry button or
navigation) when isError is true; do not use console.log as a return value,
ensure the component returns valid JSX and imports any needed UI components and
styles.

Comment on lines +18 to +19
const { data } = await apiRequest.get('/api/v1/users/acorns?now=', {
params: { now },
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

getAcorns API 호출에서 쿼리 파라미터 구조를 확인해주세요.

현재 URL이 /api/v1/users/acorns?now=로 끝나고 있는데, params 옵션으로 now 값을 전달하면 실제로는 /api/v1/users/acorns?now=&now=TIMESTAMP 형태가 될 수 있습니다.

다음 스크립트로 실제 API 엔드포인트 구조를 확인해보세요:

올바른 형태는 다음 중 하나일 것입니다:

# 옵션 1: URL에서 ?now= 제거
-  const { data } = await apiRequest.get('/api/v1/users/acorns?now=', {
+  const { data } = await apiRequest.get('/api/v1/users/acorns', {
     params: { now },
   });

# 옵션 2: params 대신 URL에 직접 추가
-  const { data } = await apiRequest.get('/api/v1/users/acorns?now=', {
-    params: { now },
-  });
+  const { data } = await apiRequest.get(`/api/v1/users/acorns?now=${now}`);

🏁 Script executed:

#!/bin/bash
# API 엔드포인트 구조 확인 (백엔드 라우터/컨트롤러 파일 검색)
rg -n "users/acorns" --type=ts --type=js -A 3 -B 3

Length of output: 484


중복 'now' 쿼리 제거 — URL에서 '?now=' 삭제하거나 params 사용 일관화

현재 '/api/v1/users/acorns?now='와 params: { now }를 동시에 사용해 '?now=&now=TIMESTAMP' 형태로 중복 쿼리가 생깁니다.
위치: apps/client/src/shared/apis/axios.ts (lines 18–19)

# 옵션 1: URL에서 ?now= 제거
-  const { data } = await apiRequest.get('/api/v1/users/acorns?now=', {
+  const { data } = await apiRequest.get('/api/v1/users/acorns', {
     params: { now },
   });
# 옵션 2: params 대신 URL에 직접 추가
-  const { data } = await apiRequest.get('/api/v1/users/acorns?now=', {
-    params: { now },
-  });
+  const { data } = await apiRequest.get(`/api/v1/users/acorns?now=${now}`);
📝 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 { data } = await apiRequest.get('/api/v1/users/acorns?now=', {
params: { now },
const { data } = await apiRequest.get('/api/v1/users/acorns', {
params: { now },
});
Suggested change
const { data } = await apiRequest.get('/api/v1/users/acorns?now=', {
params: { now },
const { data } = await apiRequest.get(`/api/v1/users/acorns?now=${now}`);
🤖 Prompt for AI Agents
In apps/client/src/shared/apis/axios.ts around lines 18–19, the request URL
currently includes a hardcoded '?now=' and also passes params: { now }, causing
duplicate now query params; remove the '?now=' fragment from the URL and rely
solely on the params object (or alternatively remove the params and inline the
timestamp into the URL) so only one now query parameter is sent, and ensure no
trailing '?' remains in the URL.

Comment on lines 70 to 72
if (isPending) return console.log('로딩중...');
if (isError) return console.log('에러...');
const acornCount = data.acornCount;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

로딩 및 에러 상태 처리를 개선해주세요.

Level 컴포넌트와 동일한 문제로, console.log 대신 사용자에게 적절한 피드백을 제공해야 합니다.

다음과 같이 개선하세요:

-  if (isPending) return console.log('로딩중...');
-  if (isError) return console.log('에러...');
+  if (isPending) return <div>사이드바 정보를 불러오는 중...</div>;
+  if (isError) return <div>사이드바 정보를 불러오는데 실패했습니다.</div>;
📝 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 (isPending) return console.log('로딩중...');
if (isError) return console.log('에러...');
const acornCount = data.acornCount;
if (isPending) return <div>사이드바 정보를 불러오는 중...</div>;
if (isError) return <div>사이드바 정보를 불러오는데 실패했습니다.</div>;
const acornCount = data.acornCount;

Copy link
Member

@constantly-dev constantly-dev left a comment

Choose a reason for hiding this comment

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

잘 구현해주셨네요!! isPending잘 써주신 것 같아요~~~ 👍

Comment on lines 70 to 71
if (isPending) return console.log('로딩중...');
if (isError) return console.log('에러...');
Copy link
Member

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

api api 연결

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Api] level 페이지 사이드바 도토리 연결

2 participants