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
766 changes: 696 additions & 70 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^7.5.3",
"react-scripts": "5.0.1",
"resolve-url-loader": "^5.0.0",
"sass": "^1.87.0",
"scss": "^0.2.4",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
Binary file removed public/favicon.ico
Binary file not shown.
36 changes: 7 additions & 29 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,20 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
<link
rel="stylesheet"
as="style"
crossorigin
href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<meta name="description" content="panda market" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>판다마켓</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file removed public/logo192.png
Binary file not shown.
Binary file removed public/logo512.png
Binary file not shown.
25 changes: 0 additions & 25 deletions public/manifest.json

This file was deleted.

22 changes: 22 additions & 0 deletions src/API/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import axios from "axios";

export const api = axios.create({
baseURL: "https://panda-market-api.vercel.app",
headers: { "Content-Type": "application/json" },
timeout: 5000,
});

api.interceptors.response.use(
(res) => res,
(error) => {
const status = error.response?.status;
if (status === 404) {
alert("요청한 자원을 찾을 수 없습니다.");
} else if (status === 500) {
alert("서버에 문제가 발생했습니다.");
} else {
alert("문제가 발생했습니다.");
}
return Promise.reject(error);
}
Comment on lines +11 to +21
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
해당 API를 호출하는 내부에서 처리할 수 있게 alert로 에러메시지를 보여주시는 것보다 에러에 해당 상황을 반환하시는 것이 좋을 것 같아요.

api.interceptors.response.use(
  (res) => res,
  (error) => {
    const status = error.response?.status;

    return Promise.reject({ status, message: error.message });
  }
);

);
7 changes: 7 additions & 0 deletions src/API/getItems.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { api } from "./api";
export default async function getItems(page, pageSize, sort = "") {
const res = await api.get(
`/products?page=${page}&pageSize=${pageSize}&orderBy=${sort}`
);
return res.data;
}
38 changes: 0 additions & 38 deletions src/App.css

This file was deleted.

25 changes: 0 additions & 25 deletions src/App.js

This file was deleted.

19 changes: 19 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Route, Routes } from "react-router";
import AddItem from "./components/AddItem/AddItem";
import Nav from "./common/Nav/Nav";
import Items from "./components/Items/Items";
import Products from "./components/Products/Products";

export default function App() {
return (
<>
<Nav />
<Routes>
<Route path="/" element={<AddItem />} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

💬 여담
index 속성을 이용해 시작페이지라는 것을 더 명확하게 알 수 있게 하실수도 있습니다~

Suggested change
<Route path="/" element={<AddItem />} />
<Route index element={<AddItem />} />

<Route path="/items" element={<Items />} />
<Route path="/products" element={<Products />} />
<Route path="/additem" element={<AddItem />} />
</Routes>
</>
);
}
8 changes: 0 additions & 8 deletions src/App.test.js

This file was deleted.

46 changes: 46 additions & 0 deletions src/common/Nav/Nav.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import pandaMarket from "../../image/pandaMarket.svg";
import pandaFace from "../../image/pandaFace.svg";
import blankProfile from "../../image/blankProfile.svg";
import styles from "./Nav.module.scss";
import { useLocation, useNavigate } from "react-router";

export default function Nav() {
const navigate = useNavigate();
const locate = useLocation();
const location = locate.pathname;
return (
<nav>
<div className={styles["nav--left"]}>
<div className={styles.logo} onClick={() => navigate("/")}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
react router를 사용하시니 이런경우 Link 컴포넌트를 쓰세요~

<img
src={pandaFace}
className={styles.pandaface}
alt="panda face"
></img>
<img
src={pandaMarket}
className={styles.pandamarket}
alt="panda market"
></img>
</div>
<div className={styles.menu}>
<span>자유게시판</span>
<span
onClick={() => navigate("/items")}
style={
location === "/items" || "/additems" ? { color: "#3692FF" } : {}
}
>
중고마켓
</span>
Comment on lines +28 to +35
Copy link
Collaborator

Choose a reason for hiding this comment

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

❗️ 수정요청
사용하고 계신 라우팅 라이브러리에서는 네비게이션에서 사용되는 wrapping된 link 컴포넌트를 제공합니다~
이를 통해 해당 컴포넌트들에서 일반적인 요구사항을 더 쉽게 구현할 수 있고, 컴포넌트의 역할도 더 명확해지니
아래 문서를 읽고 수정해보시면 더 좋겠습니다.

https://reactrouter.com/api/components/NavLink

</div>
</div>

<img
className={styles.profile}
src={blankProfile}
alt="blank profile"
></img>
</nav>
);
}
56 changes: 56 additions & 0 deletions src/common/Nav/Nav.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
nav {
display: flex;
padding: 10px 200px;
justify-content: space-between;
border-bottom: 1px solid #dfdfdf;
}
.nav--left {
display: flex;
align-items: center;
gap: 47px;
}

.logo {
display: flex;
gap: 8.6px;
}
.menu {
display: flex;
gap: 30px;
font-size: 18px;
font-weight: 700;
line-height: 26px;
color: #4b5563; //Secondary/600
}

.logo,
.menu,
.profile {
cursor: pointer;
}
@media (max-width: 744px) {
nav {
padding: 10px 24px;
}
.nav--left {
gap: 20px;
}
}
@media (max-width: 376px) {
nav {
padding: 15px 16px;
}
.nav--left {
gap: 8px;
}
.pandaface {
display: none;
}
.pandamarket {
width: 81px;
}
.menu {
gap: 8px;
font-size: 16px;
}
}
3 changes: 3 additions & 0 deletions src/components/AddItem/AddItem.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function AddItem() {
return <div>addItem</div>;
}
Loading
Loading