-
Notifications
You must be signed in to change notification settings - Fork 26
[박신천] Sprint 8 #125
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
The head ref may contain hidden characters: "React-\uBC15\uC2E0\uCC9C-sprint8A"
[박신천] Sprint 8 #125
Changes from all commits
2368dda
b88c5f5
265a32b
ae98bac
d1d744b
ea5219a
a5f0cae
61b2102
5c92005
ee76819
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||||||||||||||||||||||||||||||||||||||
| import instance from "./axiosInstance"; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| export interface Items { | ||||||||||||||||||||||||||||||||||||||||||
| id: number; | ||||||||||||||||||||||||||||||||||||||||||
| name: string; | ||||||||||||||||||||||||||||||||||||||||||
| price: number; | ||||||||||||||||||||||||||||||||||||||||||
| tags: string[]; | ||||||||||||||||||||||||||||||||||||||||||
| images: string[]; | ||||||||||||||||||||||||||||||||||||||||||
| favoriteCount: number; | ||||||||||||||||||||||||||||||||||||||||||
| createdAt: string; | ||||||||||||||||||||||||||||||||||||||||||
| updatedAt: string; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| export type OrderBy = "recent" | "favorite"; | ||||||||||||||||||||||||||||||||||||||||||
|
Collaborator
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 interface GetListsParams { | ||||||||||||||||||||||||||||||||||||||||||
| page: number; | ||||||||||||||||||||||||||||||||||||||||||
| pageSize: number; | ||||||||||||||||||||||||||||||||||||||||||
| orderBy: OrderBy; | ||||||||||||||||||||||||||||||||||||||||||
| keyword?: string; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| export interface GetListsResponse { | ||||||||||||||||||||||||||||||||||||||||||
| list: Items[]; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| export async function getLists({ | ||||||||||||||||||||||||||||||||||||||||||
| page = 1, | ||||||||||||||||||||||||||||||||||||||||||
| pageSize = 10, | ||||||||||||||||||||||||||||||||||||||||||
| orderBy = "recent", | ||||||||||||||||||||||||||||||||||||||||||
| keyword = "", | ||||||||||||||||||||||||||||||||||||||||||
| }: GetListsParams): Promise<GetListsResponse> { | ||||||||||||||||||||||||||||||||||||||||||
| const query = `page=${page}&pageSize=${pageSize}&orderBy=${orderBy}&keyword=${keyword}`; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||
| const { data } = await instance.get(`/products?${query}`); | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+25
to
+34
Collaborator
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. 문자열로 직접 쿼리를 붙이면 휴먼 에러(오타, & 누락, URL 인코딩 누락 등)가 발생하기 보다 쉬울 수 있을 것 같아요. 😊
Suggested change
지금처럼 문자열로 직접 쿼리를 붙이면 휴먼 에러(오타, & 누락, URL 인코딩 누락 등)가 발생하기 쉬워요. 특히 keyword 같은 파라미터에 공백이나 특수 문자가 들어오면 문자열 연결 방식에서는 의도치 않은 동작이 발생할 수 있어요 ! axios는 params 옵션을 제공하기 때문에 이를 활용하는 것이 더 안전하고 가독성도 좋아질 수 있습니다 ! |
||||||||||||||||||||||||||||||||||||||||||
| return data; | ||||||||||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||||||||||
| throw new Error("상품 목록을 가져오는데 실패했습니다."); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import axios from "axios"; | ||
|
|
||
| const instance = axios.create({ | ||
| baseURL: "https://panda-market-api.vercel.app", | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| }, | ||
| }); | ||
|
Comment on lines
+3
to
+8
Collaborator
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 default instance; | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,11 +1,15 @@ | ||||||
| import "./ListItem.css"; | ||||||
| import { Items } from "../api/api"; | ||||||
| interface Props { | ||||||
| item: Items; | ||||||
| } | ||||||
|
|
||||||
| function ListItem({ item }) { | ||||||
| function ListItem({ item }: Props) { | ||||||
| return ( | ||||||
| <div> | ||||||
| <div className="list-item"> | ||||||
| <div className="item-images"> | ||||||
| <img src={item.images} /> | ||||||
| <img src={item.images?.[0]} /> | ||||||
|
Collaborator
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. ListItem.tsx 파일에서 질문 주신 부분이 여기인 것으로 보여요 😉
Suggested change
여기서 |
||||||
| </div> | ||||||
| <div className="item-text"> | ||||||
| <p>{item.name}</p> | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| declare module "*.svg" { | ||
| const value: any; | ||
| export default value; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "esnext", | ||
| "module": "esnext", | ||
| "outDir": "dist", | ||
| "strict": true, | ||
| "moduleDetection": "force", | ||
| "jsx": "react-jsx", | ||
| "moduleResolution": "bundler", | ||
| "traceResolution": true | ||
| }, | ||
| "include": ["src"] | ||
| } |
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.
해당 타입은 복수형으로 보이지는 않는군요 !
배열 타입인 경우
Items와 같이 표현해볼 수 있겠으나 현재는 객체에 대한 타입이므로 단수형이 더 낫지 않을까 제안드려봅니다 ㅎㅎ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.
(제안)
ProductItem으로 바꿔볼 수도 있겠네요 !또한,
Item은 의미가 넓으므로ProductItem과 같이 특정 자원에 대한 타입임을 이름에 나타내는 방법도 있겠어요 !