-
Notifications
You must be signed in to change notification settings - Fork 21
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
[이수지] sprint11 #132
Merged
GANGYIKIM
merged 6 commits into
codeit-bootcamp-frontend:Next-이수지
from
mulddang2:Next-이수지-sprint11
Nov 11, 2024
The head ref may contain hidden characters: "Next-\uC774\uC218\uC9C0-sprint11"
Merged
[이수지] sprint11 #132
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ea5a524
fix: hasImage prop 오류로 인한 라이브러리 설지 및 수정
bef196b
fix: react, react dom 라이브러리 버전 변경(18 -> 18.2.0)
6c10308
refactor: 이미지 업로드 관련 함수들 커스텀훅으로 분리
49b6cf2
fix: svg를 컴포넌트화해서 사용하는 부분에 오류가 있어, Image 컴포넌트로 수정
4b717df
feat: 로그인 기능 구현
190cfd6
feat: 토큰 유무에 따라 프로필 이미지 렌더링 처리
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,78 @@ | ||
import { ProductListFetcherParams } from '@/types/productTypes'; | ||
|
||
export async function getProducts({ | ||
orderBy, | ||
pageSize, | ||
page = 1, | ||
}: ProductListFetcherParams) { | ||
const params = new URLSearchParams({ | ||
orderBy, | ||
pageSize: String(pageSize), | ||
page: String(page), | ||
}); | ||
|
||
try { | ||
const response = await fetch( | ||
`http://panda-market-api.vercel.app/products?${params}` | ||
); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error: ${response.status}`); | ||
} | ||
|
||
const body = await response.json(); | ||
return body; | ||
} catch (error) { | ||
console.error('Failed to fetch products:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
export async function getProductDetail(productId: number) { | ||
if (!productId) { | ||
throw new Error('상품 아이디가 유효가지 않습니다'); | ||
} | ||
|
||
try { | ||
const response = await fetch( | ||
`https://panda-market-api.vercel.app/products/${productId}` | ||
); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error: ${response.status}`); | ||
} | ||
|
||
const body = await response.json(); | ||
return body; | ||
} catch (error) { | ||
console.error('Failed to fetch product detail:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
export async function getProductComments({ | ||
productId, | ||
limit = 10, | ||
}: { | ||
productId: number; | ||
limit?: number; | ||
}) { | ||
const params = new URLSearchParams({ | ||
limit: String(limit), | ||
productId: String(productId), | ||
}); | ||
|
||
try { | ||
const query = new URLSearchParams(params).toString(); | ||
const response = await fetch( | ||
`https://panda-market-api.vercel.app/products/${productId}/comments?${query}` | ||
); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error: ${response.status}`); | ||
} | ||
|
||
const body = await response.json(); | ||
return body; | ||
} catch (error) { | ||
console.error('Failed to fetch product comments:', error); | ||
throw error; | ||
} | ||
} |
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
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
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.
P3:
사용하지 않을 코드는 지워주세요~