-
Notifications
You must be signed in to change notification settings - Fork 37
[송형진] sprint8 #318
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
Merged
devToram
merged 1 commit into
codeit-bootcamp-frontend:React-송형진
from
sori4606:React-송형진
Jan 27, 2025
The head ref may contain hidden characters: "React-\uC1A1\uD615\uC9C4"
Merged
[송형진] sprint8 #318
Changes from all commits
Commits
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 hidden or 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,4 @@ | ||
| declare module "*.png"; | ||
| declare module "*.jpg"; | ||
| declare module "*.jpeg"; | ||
| declare module "*.svg"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,114 @@ | ||
| export type OrderByType = "recent" | "favorite"; | ||
|
|
||
| export interface Product { | ||
| createdAt: string; | ||
| favoriteCount: number; | ||
| ownerNickname: string; | ||
| ownerId: number; | ||
| images: string[]; | ||
| tags: string[]; | ||
| price: number; | ||
| description: string; | ||
| name: string; | ||
| id: number; | ||
| } | ||
|
|
||
| interface ProductById extends Product { | ||
| updatedAt: string; | ||
| isFavorite: boolean; | ||
| } | ||
|
|
||
| interface GetDataParams { | ||
| page?: number; | ||
| pageSize?: number; | ||
| orderBy?: OrderByType; | ||
| } | ||
|
|
||
| export interface ProductResponse { | ||
| list: Product[]; | ||
| totalCount: number; | ||
| } | ||
|
|
||
| interface Writer { | ||
| id: number; | ||
| nickname: string; | ||
| image: string | null; | ||
| } | ||
|
|
||
| interface Comment { | ||
| id: number; | ||
| content: string; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| writer: Writer; | ||
| } | ||
|
|
||
| interface CommentListResponse { | ||
| list: Comment[]; | ||
| nextCursor?: number; | ||
| } | ||
|
|
||
| interface GetCommentDataParams { | ||
| productId?: string; | ||
| limit: number; | ||
| cursor?: number; | ||
| } | ||
|
|
||
| interface PostCommentDataParams { | ||
| productId?: string; | ||
| editContent: string; | ||
| } | ||
|
|
||
| export async function getData({ | ||
| page = 1, | ||
| pageSize = 4, | ||
| orderBy = "recent", | ||
| }: GetDataParams = {}): Promise<ProductResponse> { | ||
| const response = await fetch( | ||
| `https://panda-market-api.vercel.app/products?page=${page}&pageSize=${pageSize}&orderBy=${orderBy}` | ||
| ); | ||
| const body = await response.json(); | ||
| return body; | ||
| } | ||
|
|
||
| export async function getDataById(productId?: string): Promise<ProductById> { | ||
| const response = await fetch( | ||
| `https://panda-market-api.vercel.app/products/${productId}` | ||
| ); | ||
| const body = await response.json(); | ||
| return body; | ||
| } | ||
|
|
||
| export async function getCommentData({ | ||
| productId, | ||
| limit, | ||
| }: GetCommentDataParams): Promise<CommentListResponse> { | ||
| const response = await fetch( | ||
| `https://panda-market-api.vercel.app/products/${productId}/comments?limit=${limit}` | ||
| ); | ||
| const body = await response.json(); | ||
| return body; | ||
| } | ||
|
|
||
| export async function postCommentData({ | ||
| productId, | ||
| editContent, | ||
| }: PostCommentDataParams): Promise<Response> { | ||
| const token = | ||
| "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTksInNjb3BlIjoiYWNjZXNzIiwiaWF0IjoxNzM3Mjc3NTIzLCJleHAiOjE3MzcyNzkzMjMsImlzcyI6InNwLXBhbmRhLW1hcmtldCJ9.PE7HgmQtdB0J1kQoYk4VieZfBs0CZFwedo2ttRBAHWY"; | ||
|
|
||
| const response = await fetch( | ||
| `https://panda-market-api.vercel.app/products/${productId}/comments`, | ||
| { | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| Authorization: `Bearer ${token}`, | ||
| }, | ||
| body: JSON.stringify({ | ||
| content: editContent, | ||
| }), | ||
| } | ||
| ); | ||
| return response; | ||
| } | ||
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.
타입이 꽤 많아서 따로
type.ts에 정의해도 괜찮을 거 같아요!