-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Feat/#144] 카드리스트 수정 및 관련 API 연결 #169
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
78eef6f
feat: useFetchDesignList 만들기!
chaeneey 47a63c9
feat: DesignList, DesignDetail API 연결하기
chaeneey bf90368
chore: develop 최신 상태 반영하기
chaeneey cf6fa47
feat: DesignListPage에서 쓰이는 CardList api 연결하기
chaeneey 774467f
feat: 카드리스트 타입 정리, 찜한 스토어 api 연결
chaeneey d7e450e
chore: develop 최신 상태 반영하기
chaeneey a0f8236
feat: likedStore api 연결, detail api 연결
chaeneey d61d83e
chore: type 위치 잘못된 부분 수정
chaeneey 6732b86
chore: develop 최신 상태 반영하기
chaeneey 0d0a991
chore: 자잘한 오류 수정
chaeneey f818e30
Merge branch 'develop' into feat/#144/design-list-page-api
thisishwarang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { instance } from '@apis/instance'; | ||
|
||
import { END_POINT, queryKey } from '@constants'; | ||
|
||
import { ApiResponseType } from '@types'; | ||
|
||
interface cakeType { | ||
cakeId: number; | ||
isLiked: boolean; | ||
imageUrl: string; | ||
} | ||
|
||
interface DesignDetailResponse { | ||
storeId: number; | ||
storeName: string; | ||
station: string; | ||
cake: cakeType[]; | ||
} | ||
|
||
const fetchDesignDetail = async ( | ||
cakeId: number, | ||
dayCategory: string, | ||
themeName: string | ||
): Promise<DesignDetailResponse> => { | ||
try { | ||
const response = await instance.get<ApiResponseType<DesignDetailResponse>>( | ||
END_POINT.FETCH_DESIGN_DETAIL(cakeId, dayCategory, themeName) | ||
); | ||
return response.data.data; | ||
} catch (error) { | ||
console.log(error); | ||
throw error; | ||
} | ||
}; | ||
|
||
export const useFetchDesignDetail = ( | ||
cakeId: number, | ||
dayCategory: string, | ||
themeName: string | ||
) => { | ||
return useQuery({ | ||
queryKey: [queryKey.DESIGN_DETAIL], | ||
queryFn: () => fetchDesignDetail(cakeId, dayCategory, themeName), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { instance } from '@apis/instance'; | ||
|
||
import { END_POINT, queryKey } from '@constants'; | ||
|
||
import { ApiResponseType, DesignListResponse, ErrorResponse } from '@types'; | ||
|
||
const fetchDesignList = async ( | ||
option: string, | ||
dayCategory: string, | ||
themeName: string | ||
): Promise<DesignListResponse> => { | ||
try { | ||
const response = await instance.get<ApiResponseType<DesignListResponse>>( | ||
END_POINT.FETCH_DESIGN_LIST(option, dayCategory, themeName) | ||
); | ||
return response.data.data; | ||
} catch (error) { | ||
const errorResponse = error as ErrorResponse; | ||
console.log(errorResponse.response.data.code); | ||
if (errorResponse.response.data.code === 40420) { | ||
return { | ||
nextCakeIdCursor: 0, | ||
nextCakeLikesCursor: 0, | ||
isLastData: false, | ||
cakeCount: 0, | ||
cakes: [], | ||
}; | ||
} | ||
throw error; | ||
} | ||
}; | ||
|
||
export const useFetchDesignList = ( | ||
option: string, | ||
dayCategory: string, | ||
themeName: string | ||
) => { | ||
return useQuery({ | ||
queryKey: [queryKey.DESIGN_LIST, option, dayCategory, themeName], | ||
queryFn: () => fetchDesignList(option, dayCategory, themeName), | ||
staleTime: 0, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ export const instance = axios.create({ | |
withCredentials: true, | ||
}); | ||
|
||
|
||
|
||
Comment on lines
+11
to
+12
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. ? |
||
export function get<T>(...args: Parameters<typeof instance.get>) { | ||
return instance.get<T>(...args); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { instance } from '@apis/instance'; | ||
|
||
import { END_POINT, queryKey } from '@constants'; | ||
|
||
import { ApiResponseType, ErrorResponse, LikedStoreListResponse } from '@types'; | ||
|
||
const fetchLikedStoreList = async ( | ||
option: string, | ||
pageParam?: string | ||
): Promise<LikedStoreListResponse> => { | ||
try { | ||
const endpoint = pageParam | ||
? END_POINT.FETCH_LIKED_STORE_LIST(option, pageParam) | ||
: END_POINT.FETCH_LIKED_STORE_LIST(option); | ||
|
||
const response = | ||
await instance.get<ApiResponseType<LikedStoreListResponse>>(endpoint); | ||
return response.data.data; | ||
} catch (error) { | ||
const errorResponse = error as ErrorResponse; | ||
console.log(errorResponse.response.data.code); | ||
if (errorResponse.response.data.code === 40420) { | ||
return { | ||
nextStoreIdCursor: -1, | ||
nextLikesCursor: undefined, | ||
storeCount: 0, | ||
stores: [], // 빈 배열 반환 | ||
}; | ||
} | ||
throw error; | ||
} | ||
}; | ||
|
||
export const useFetchLikedStoreList = ( | ||
option: string, | ||
|
||
pageParam?: string | ||
) => { | ||
return useQuery({ | ||
queryKey: [queryKey.LIKED_STORE_LIST, option, pageParam], | ||
queryFn: () => fetchLikedStoreList(option, pageParam || ''), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
types 폴더로 빼면 좋을 것 같습니다!