-
Notifications
You must be signed in to change notification settings - Fork 2
[Feature] 메인 화면 API 연결 #96
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
Changes from all commits
6e983be
ec6d06a
ed6ad3f
9e61971
a7dc908
9df3483
3b98c27
3f9d4ab
914dbdf
4315e1a
c1b8da1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import type { TDateCourseSavedCountResponse } from '@/types/home/dateCourse'; | ||
|
|
||
| import { axiosInstance } from '@/api/axiosInstance'; | ||
|
|
||
| export const getDateCourseSavedCount = async (): Promise<TDateCourseSavedCountResponse> => { | ||
| const { data } = await axiosInstance.get('/api/v1/logs/datecourses/saved-count'); | ||
| return data; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import type { TGetDateTimeStates, TMonthlyDatePlaceResponse } from '../../types/home/datePlace'; | ||
|
|
||
| import { axiosInstance } from '@/api/axiosInstance'; | ||
|
|
||
| // 월별 데이트 장소 수 조회 API | ||
| export const getMonthlyDatePlaceStates = async (): Promise<TMonthlyDatePlaceResponse> => { | ||
| const { data } = await axiosInstance.get('/api/v1/logs/dateplaces/monthly'); | ||
| return data; | ||
| }; | ||
|
|
||
| export const getDateTimeStates = async (): Promise<TGetDateTimeStates> => { | ||
| const { data } = await axiosInstance.get('/api/v1/logs/datecourses/average'); | ||
| return data; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import type { TWeeklyKeywordResponse } from '@/types/home/keyword'; | ||
|
|
||
| import { axiosInstance } from '@/api/axiosInstance'; | ||
|
|
||
| // 이번 주 인기 키워드 조회 API | ||
| export const getWeeklyKeywords = async (): Promise<TWeeklyKeywordResponse> => { | ||
| const { data } = await axiosInstance.get('/api/v1/logs/keyword/weekly'); | ||
| return data; | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||||||
| import type { TUserGradeResponse } from '@/types/home/level'; | ||||||||||
|
|
||||||||||
| import { axiosInstance } from '@/api/axiosInstance'; | ||||||||||
|
|
||||||||||
| // 사용자 등급 조회 API | ||||||||||
| export const getUserGrade = async (): Promise<TUserGradeResponse> => { | ||||||||||
| const { data } = await axiosInstance.get('/api/v1/members/grade'); | ||||||||||
| return data; | ||||||||||
|
Comment on lines
+7
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Axios 제네릭으로 응답 타입 안전성 강화 응답 타입을 제네릭으로 명시하면 data의 타입 안정성이 올라갑니다. 아래처럼 변경을 권장합니다. - const { data } = await axiosInstance.get('/api/v1/members/grade');
+ const { data } = await axiosInstance.get<TUserGradeResponse>('/api/v1/members/grade');📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| }; | ||||||||||
yeonjin719 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,13 @@ | ||||||||||||||||||
| import type { TGetUserRegionResponse, TPatchUserRegionRequest, TPatchUserRegionResponse } from '@/types/home/region'; | ||||||||||||||||||
|
|
||||||||||||||||||
| import { axiosInstance } from '@/api/axiosInstance'; | ||||||||||||||||||
|
|
||||||||||||||||||
| export const patchUserRegion = async ({ regionId }: TPatchUserRegionRequest): Promise<TPatchUserRegionResponse> => { | ||||||||||||||||||
| const { data } = await axiosInstance.patch('/api/v1/regions/users', { regionId }); | ||||||||||||||||||
| return data; | ||||||||||||||||||
yeonjin719 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
| }; | ||||||||||||||||||
|
Comment on lines
+5
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Axios 제네릭으로 응답 타입 명시 응답 타입을 명확히 지정해 런타임 이슈를 컴파일 타임에 방지하는 것을 권장합니다. export const patchUserRegion = async ({ regionId }: TPatchUserRegionRequest): Promise<TPatchUserRegionResponse> => {
- const { data } = await axiosInstance.patch('/api/v1/regions/users', { regionId });
+ const { data } = await axiosInstance.patch<TPatchUserRegionResponse>('/api/v1/regions/users', { regionId });
return data;
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| export const getUserRegion = async (): Promise<TGetUserRegionResponse> => { | ||||||||||||||||||
| const { data } = await axiosInstance.get('/api/v1/regions/users/current'); | ||||||||||||||||||
| return data; | ||||||||||||||||||
| }; | ||||||||||||||||||
yeonjin719 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import type { | ||
| TGetPrecipitationRequest, | ||
| TGetPrecipitationResponse, | ||
| TGetWeeklyWeatherRecommendationRequest, | ||
| TGetWeeklyWeatherRecommendationResponse, | ||
| } from '@/types/home/weather'; | ||
|
|
||
| import { axiosInstance } from '@/api/axiosInstance'; | ||
|
|
||
| // 주간 날씨 추천 조회 API | ||
| export const getWeeklyWeatherRecommendation = async ({ | ||
| regionId, | ||
| startDate, | ||
| }: TGetWeeklyWeatherRecommendationRequest): Promise<TGetWeeklyWeatherRecommendationResponse> => { | ||
| const { data } = await axiosInstance.get(`/api/v1/weather/${regionId}/weekly`, { params: { startDate } }); | ||
| return data; | ||
| }; | ||
|
|
||
| export const getPrecipitation = async ({ regionId, startDate }: TGetPrecipitationRequest): Promise<TGetPrecipitationResponse> => { | ||
| const { data } = await axiosInstance.get(`/api/v1/weather/${regionId}/precipitation`, { params: { startDate } }); | ||
| return data; | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,8 @@ import DateCourseSearchFilterModal from '@/components/modal/dateCourseSearchFilt | |||||||
| import ErrorModal from '@/components/modal/errorModal'; | ||||||||
| import SettingsModal from '@/components/modal/SettingModal'; | ||||||||
|
|
||||||||
| import RegionModal from '../modal/regionModal'; | ||||||||
|
|
||||||||
|
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) 경로 alias 일관성 유지 제안 다른 모달들은 절대 경로 alias('@/components/...')를 사용하고 있는데, RegionModal만 상대 경로를 사용합니다. 팀 규칙에 맞춰 alias로 통일하면 가독성과 유지보수성이 좋아집니다. 적용 예시: -import RegionModal from '../modal/regionModal';
+import RegionModal from '@/components/modal/regionModal';📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| import useModalStore from '@/store/useModalStore'; | ||||||||
|
|
||||||||
| // 모달 타입 정의 -> 만약 다른 모달을 추가하고 싶다면 여기에 타입을 추가하고, MODAL_COMPONENTS에 컴포넌트를 추가하면 됩니다. | ||||||||
|
|
@@ -15,13 +17,15 @@ export const MODAL_TYPES = { | |||||||
| DateCourseSearchFilterModal: 'DateCourseSearchFilterModal', | ||||||||
| SettingsModal: 'SettingsModal', //설정 모달 추가 | ||||||||
| AlarmModal: 'AlarmModal', | ||||||||
| RegionModal: 'RegionModal', | ||||||||
| }; | ||||||||
|
|
||||||||
| export const MODAL_COMPONENTS = { | ||||||||
| [MODAL_TYPES.ErrorModal]: ErrorModal, | ||||||||
| [MODAL_TYPES.DateCourseSearchFilterModal]: DateCourseSearchFilterModal, | ||||||||
| [MODAL_TYPES.SettingsModal]: SettingsModal, | ||||||||
| [MODAL_TYPES.AlarmModal]: AlarmModal, | ||||||||
| [MODAL_TYPES.RegionModal]: RegionModal, | ||||||||
| }; | ||||||||
|
Comment on lines
23
to
29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) MODAL_COMPONENTS에 명시적 타입 지정 권장 현재 예시(제안 코드): import type { ComponentType } from 'react';
type ModalBaseProps = { onClose: () => void } & Record<string, any>;
export const MODAL_COMPONENTS: Record<ModalType, ComponentType<ModalBaseProps>> = {
[MODAL_TYPES.ErrorModal]: ErrorModal,
[MODAL_TYPES.DateCourseSearchFilterModal]: DateCourseSearchFilterModal,
[MODAL_TYPES.SettingsModal]: SettingsModal,
[MODAL_TYPES.AlarmModal]: AlarmModal,
[MODAL_TYPES.RegionModal]: RegionModal,
};🤖 Prompt for AI Agents |
||||||||
|
|
||||||||
| export default function ModalProvider() { | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,8 +1,16 @@ | ||||||||||||||||||||||||||||||
| import { Navigate } from 'react-router-dom'; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| import { useDateCourseSavedCount } from '@/hooks/home/useDateCourseStates'; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| import MainCard from './mainCard'; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| import ArchiveBlank from '@/assets/icons/Archive_Blank.svg?react'; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| function DateCourseStore() { | ||||||||||||||||||||||||||||||
| const { data, isLoading, error } = useDateCourseSavedCount(); | ||||||||||||||||||||||||||||||
| if (error) { | ||||||||||||||||||||||||||||||
| return <Navigate to="/error" replace />; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||
| <MainCard> | ||||||||||||||||||||||||||||||
| <div className="flex flex-col px-4 sm:px-8 lg:px-[20px] py-8 lg:py-[28px] h-full justify-center"> | ||||||||||||||||||||||||||||||
|
|
@@ -11,11 +19,16 @@ function DateCourseStore() { | |||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| <div className="flex text-sm sm:text-base lg:text-m bold-medium text-[#616161] mb-1">내 데이트 코스를</div> | ||||||||||||||||||||||||||||||
| <div className="flex gap-1 items-center"> | ||||||||||||||||||||||||||||||
| <div className="text-lg sm:text-xl font-bold text-primary-700 whitespace-nowrap">2,345명</div> | ||||||||||||||||||||||||||||||
| {isLoading ? ( | ||||||||||||||||||||||||||||||
| <div className="text-lg sm:text-xl font-bold text-primary-700 whitespace-nowrap">로딩...</div> | ||||||||||||||||||||||||||||||
| ) : ( | ||||||||||||||||||||||||||||||
| <div className="text-lg sm:text-xl font-bold text-primary-700 whitespace-nowrap">{data?.result.count}명</div> | ||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||
yeonjin719 marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+22
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) 데이터 미도착 시 'undefined명' 노출 가능성 및 숫자 포매팅 개선 데이터가 일시적으로 없을 때 적용 예시(diff): - <div className="text-lg sm:text-xl font-bold text-primary-700 whitespace-nowrap">{data?.result.count}명</div>
+ <div className="text-lg sm:text-xl font-bold text-primary-700 whitespace-nowrap">
+ {(data?.result.count ?? 0).toLocaleString()}명
+ </div>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| <div className="text-sm sm:text-base lg:text-m bold-medium text-[#616161] whitespace-nowrap">이 저장했어요.</div> | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| </MainCard> | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| export default DateCourseStore; | ||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.