Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import Header from "./components/layout/Header";
import BestProducts from "./components/BestProducts/BestProducts";
import AllProducts from "./components/AllProducts/AllProducts";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import AddItem from "./pages/AddItem";
import AddItem from "./pages/additem";
import "./styles/global.css";
import ItemPage from "./pages/ItemPage/ItemPage";

function MainContent() {
return (
Expand All @@ -21,8 +22,11 @@ function App() {
<div className="App">
<Header />
<Routes>
<Route path="/items">
<Route index element={<MainContent />} />
<Route path=":productSlug" element={<ItemPage />} />
</Route>
<Route path="/" element={<MainContent />} />
<Route path="/items" element={<MainContent />} />
<Route path="pages/additem" element={<AddItem />} />
</Routes>
</div>
Expand Down
38 changes: 37 additions & 1 deletion src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,42 @@ export async function getData({
const response = await fetch(
`https://panda-market-api.vercel.app/products?page=${page}&pageSize=${pageSize}&orderBy=${orderBy}`
);
const body = response.json();
const body = await response.json();
return body;
}

export async function getDataById(productId) {
const response = await fetch(
`https://panda-market-api.vercel.app/products/${productId}`
);
const body = await response.json();
return body;
}

export async function getUserData({ productId, limit }) {
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 }) {
const token =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

토큰의 경우 github 에 올리시기보다 환경변수로 로컬에서 관리해주셔야해요!
https://velog.io/@milkboy2564/Next.js-env%ED%99%98%EA%B2%BD-%EB%B3%80%EC%88%98-%EC%A0%95%EB%A6%AC

"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;
}
Binary file added src/assets/images/ickebab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/nocomment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/return.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/components/AllProducts/AllProducts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import SearchForm from "../SearchForm/SearchForm";
import Pagination from "../Pagination/Pagination";
import "./AllProducts.css";
import useDevice from "../../hooks/useDevice";
import { Link } from "react-router-dom";

function AllProducts() {
const [allItemList, setAllItemList] = useState([]);
Expand Down Expand Up @@ -58,6 +59,7 @@ function AllProducts() {
{allItemList.map((item) => (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서 구조분해 할당해서 가져와도 좋겠네요!

Suggested change
{allItemList.map((item) => (
{allItemList.map(({id, images, name, price}) => (

<li key={item.id}>
<ProductItem
id={item.id}
imageUrl={item.images[0]}
name={item.name}
price={item.price}
Expand Down
2 changes: 2 additions & 0 deletions src/components/BestProducts/BestProducts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getData } from "../../api";
import ProductItem from "../common/product";
import "./BestProducts.css";
import useDevice from "../../hooks/useDevice";
import { Link } from "react-router-dom";

function BestProducts() {
const [itemList, setItemList] = useState([]);
Expand Down Expand Up @@ -45,6 +46,7 @@ function BestProducts() {
<li key={item.id}>
{" "}
<ProductItem
id={item.id}
imageUrl={item.images[0]}
name={item.name}
price={item.price}
Expand Down
266 changes: 266 additions & 0 deletions src/components/common/SpecificProduct.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
.specific-product-item {
max-width: 1200px;
margin: 0 auto;
}

.specific-product-container {
display: flex;
max-width: 1200px;
margin: 0 auto;
margin-top: 24px;
border-bottom: 1px solid #e5e7eb;
height: 536px;
}

.specific-product-info {
padding-left: 24px;
}

.specific-product-name {
font-weight: 600;
font-size: 24px;
line-height: 32px;
color: #1f2937;
}

.specific-product-price {
font-weight: 600;
font-size: 40px;
line-height: 47.73px;
color: #1f2937;
}

.specific-product-introduce-title {
font-weight: 600;
font-size: 16px;
line-height: 26px;
color: #4b5563;
}

.specific-product-introduce-description {
font-weight: 400;
font-size: 16px;
line-height: 26px;
color: #4b5563;
}

.specific-product-tag-title {
font-weight: 600;
font-size: 16px;
line-height: 26px;
color: #4b5563;
}

.owner-section {
display: flex;
align-items: center;
gap: 16px;

padding-top: 67px;
}

.user-image-container {
background-color: #9ca3af;
width: 40px;
height: 40px;
border-radius: 50%;
}

.user-information-section {
display: flex;
flex-direction: column;
gap: 4px;
}

.user-ownernickname {
font-weight: 500;
font-size: 14px;
line-height: 24px;
color: #4b5563;
margin: 0;
}
.user-createdat {
font-weight: 400;
font-size: 14px;
line-height: 24px;
color: #9ca3af;
margin: 0;
}

.specific-heart-section {
margin-left: auto;
display: flex;
align-items: center;
gap: 4px;
border: 1px solid #e5e7eb;
border-radius: 35px;
padding: 4px 12px;
}

.ask-input {
width: 1200px;
height: 104px;
border-radius: 12px;
padding: 16px 24px;
gap: 10px;
background-color: #f3f4f6;
}

.register-button-container {
display: flex;
justify-content: flex-end;
margin-top: 24px;
}

.register-button {
margin-left: auto;
width: 74px;
height: 42px;
border-radius: 8px;
padding: 12px 23px;
gap: 10px;
background-color: #9ca3af;
color: white;
}

.register-button-active {
background-color: #3692ff;
}

.comment-section {
margin-top: 24px;
}

.comment-container {
border-bottom: 1px solid #e5e7eb;
padding-bottom: 20px;
}

.comment-kebab-container {
display: flex;
justify-content: space-between;
align-items: center;
}

.comment-user-container {
display: flex;
gap: 8px;
}

.comment-user-content {
margin: 24px 0px;
font-weight: 400;
font-size: 14px;
line-height: 24px;
}

.comment-image-container {
background-color: #9ca3af;
width: 32px;
height: 32px;
border-radius: 50%;
}

.comment-user-information {
gap: 4px;
}

.comment-user-nickname {
font-weight: 400px;
font-size: 12px;
line-height: 18px;
color: #4b5563;
}

.comment-user-when {
font-weight: 400;
font-size: 12px;
line-height: 18px;
columns: #9ca3af;
}

.search-button-container {
display: flex;
justify-content: center;
align-items: center;
gap: 8px;
margin: 64px 0;
}

.search-button {
width: 240px;
height: 48px;
border-radius: 40px;
padding: 6px 32px;
font-weight: 600;
font-size: 18px;
line-height: 26px;
color: #f3f4f6;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
}

.return-icon {
width: 24px;
height: 24px;
}

.edit-comment-container {
width: 100%;
}

.edit-comment-input {
width: 100%;
padding: 16px 24px;
background-color: #f3f4f6;
border-radius: 12px;
height: 80px;
gap: 10px;
}

.edit-buttons-container {
display: flex;
justify-content: flex-end;
gap: 8px;
}

.cancel-button {
padding: 4px 12px;
background-color: #e2e2e2;
border-radius: 4px;
border: none;
cursor: pointer;
font-size: 16px;
font-weight: 600;
line-height: 28px;
color: #737373;
margin-top: 16px;
}

.save-button {
padding: 12px 23px;
background-color: #3692ff;
color: white;
border-radius: 8px;
border: none;
cursor: pointer;
gap: 10px;

margin-top: 16px;
}

.cancel-button:hover {
background-color: #d2d2d2;
}

.save-button:hover {
background-color: #0056b3;
}

.no-comment-container {
display: flex;
justify-content: center;
align-items: center;
}
Loading
Loading