Skip to content

Commit 3bf24cf

Browse files
authored
[김가희] sprint6 (#113)
* 리액트 초기 세팅 * nav 바 완성 * 베스트 상품 컴포넌트 만드는 중... * 베스트 상품 블럭 마무리 필요 * 베스트상품 영역 완성! * 전체 상품 완성! * 검색창 및 드롭박스 기능 구현 * 페이지네이션 기능만 구현 * 스프린트 미션 6 진행 중
1 parent d452d13 commit 3bf24cf

21 files changed

+631
-46
lines changed

package-lock.json

Lines changed: 115 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"react-dom": "^18.2.0",
1111
"react-router-dom": "^6.26.1",
1212
"react-scripts": "5.0.1",
13+
"styled-components": "^6.1.13",
1314
"web-vitals": "^2.1.4"
1415
},
1516
"scripts": {

src/api.js

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,35 @@
77
* @returns
88
*/
99
export async function getItems(
10-
page = 1,
11-
pageSize = 10,
12-
orderBy = "recent",
13-
keyword
10+
11+
page = 1,
12+
pageSize = 10,
13+
orderBy = "recent",
14+
keyword
1415
) {
15-
const searchQuery = keyword ? `keyword=${keyword}` : "";
16-
const response = await fetch(
17-
`https://panda-market-api.vercel.app/products?page=${page}&pageSize=${pageSize}&orderBy=${orderBy}&${searchQuery}`
18-
);
19-
const body = await response.json();
20-
return body;
16+
const searchQuery = keyword ? `keyword=${keyword}` : "";
17+
const response = await fetch(
18+
`https://panda-market-api.vercel.app/products?page=${page}&pageSize=${pageSize}&orderBy=${orderBy}&${searchQuery}`
19+
);
20+
const body = await response.json();
21+
return body;
22+
}
23+
24+
25+
26+
export async function addItem(requestBody) {
27+
const response = await fetch("https://panda-market-api.vercel.app/products", {
28+
method: "POST",
29+
body: JSON.stringify({
30+
images: requestBody.images,
31+
tags: requestBody.tags,
32+
price: requestBody.price,
33+
description: requestBody.description,
34+
name: requestBody.name,
35+
}),
36+
});
37+
return response;
2138
}
2239

23-
// // 1페이지 10개 최신순 줘
24-
// const 1페이지10개 = getItems(1,10,"recent")
25-
// const 2페이지10개 = getItems(2,10,"recent")
26-
// const 3페이지10개 = getItems(3,10,"recent")
2740

28-
// // 최신순으로 1페이지 1개 줘
29-
// const 1페이지10개 = getItems(1,10,"favorite")
30-
// const 2페이지10개 = getItems(2,10,"favorite")
31-
// const 3페이지10개 = getItems(3,10,"favorite")
41+

src/components/App.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import Nav from "./Nav";
22

3+
34
function App({ children }) {
4-
return (
5-
<div>
6-
<Nav></Nav>
7-
<div>{children}</div>
8-
</div>
9-
);
5+
return (
6+
<div>
7+
<Nav></Nav>
8+
<div>{children}</div>
9+
</div>
10+
);
1011
}
1112

1213
export default App;

src/components/addItem/ItemInfo.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const ItemInfo = () => {
2+
return(
3+
<>
4+
<h1>상품 소개</h1>
5+
<textarea placeholder="상품 소개를 입력해주세요"></textarea>
6+
</>
7+
)
8+
};
9+
10+
export default ItemInfo;

src/components/addItem/ItemName.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const ItemName = () => {
2+
return(
3+
<>
4+
<h1>상품명</h1>
5+
<textarea placeholder="상품명을 입력해주세요"></textarea>
6+
</>
7+
)
8+
}
9+
10+
export default ItemName;

src/components/addItem/UploadImage.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const UploadImage = () => {
2+
return(
3+
<>
4+
<h2>상품 이미지</h2>
5+
<h2>이미지 박스(임의)</h2>
6+
</>
7+
)
8+
}
9+
10+
11+
export default UploadImage;

src/components/addItem/UploadItem.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import style from "styled-components";
2+
3+
4+
5+
const Upload = style.div`
6+
display: flex;
7+
justify-content: space-between;
8+
`;
9+
10+
const UploadText = style.div``
11+
12+
const Button = style.button`
13+
width: 74px;
14+
height: 42px;
15+
border: 1px solid #9CA3AF;
16+
border-radius: 8px;
17+
`;
18+
19+
const UploadItem = () => {
20+
return (
21+
<>
22+
<Upload>
23+
<UploadText>상품 등록하기</UploadText>
24+
<Button>등록</Button>
25+
</Upload>
26+
</>
27+
);
28+
};
29+
30+
export default UploadItem;

0 commit comments

Comments
 (0)