Skip to content

Commit d9fb42d

Browse files
authored
Merge pull request #69 from hyeonjiroh/React-노현지-sprint7
[노현지] Sprint7
2 parents 76c4b00 + 62ab22c commit d9fb42d

49 files changed

Lines changed: 2398 additions & 300 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

React/panda-market/src/App.jsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ import "./styles/App.color.css";
88
function App() {
99
const location = useLocation();
1010

11+
const isAuthPage = ["/login", "/signup"].includes(location.pathname);
12+
const isHomePage = location.pathname === "/";
13+
1114
return (
1215
<>
13-
{!["/signin", "/signup"].includes(location.pathname) && (
14-
<Header className={styles.nav} />
15-
)}
16+
{!isAuthPage && <Header className={styles.nav} />}
1617
<div className={styles.body}>
1718
<Outlet />
1819
</div>
19-
{["/"].includes(location.pathname) && (
20-
<Footer className={styles.footer} />
21-
)}
20+
{isHomePage && <Footer className={styles.footer} />}
2221
</>
2322
);
2423
}

React/panda-market/src/Main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { BrowserRouter, Routes, Route } from "react-router-dom";
22
import App from "./App";
33
import HomePage from "./pages/HomePage/HomePage";
44
import LoginPage from "./pages/LoginPage/LoginPage";
5+
import SignupPage from "./pages/SignupPage/SignupPage";
56
import CommunityPage from "./pages/CommunityPage/CommunityPage";
67
import MarketPage from "./pages/MarketPage/MarketPage";
78
import ItemPage from "./pages/ItemPage/ItemPage";
@@ -13,7 +14,8 @@ function Main() {
1314
<Routes>
1415
<Route path="/" element={<App />}>
1516
<Route index element={<HomePage />} />
16-
<Route path="signin" element={<LoginPage />} />
17+
<Route path="login" element={<LoginPage />} />
18+
<Route path="signup" element={<SignupPage />} />
1719
<Route path="community" element={<CommunityPage />} />
1820
<Route path="items">
1921
<Route index element={<MarketPage />} />

React/panda-market/src/apis/itemApi.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const instance = axios.create({
44
baseURL: "https://panda-market-api.vercel.app",
55
});
66

7+
const COMMENTS_LIMIT = 3;
8+
79
export async function getItems({ page = "", pageSize = "", order = "" }) {
810
const query = `page=${page}&pageSize=${pageSize}&orderBy=${order}`;
911
try {
@@ -14,3 +16,24 @@ export async function getItems({ page = "", pageSize = "", order = "" }) {
1416
throw error;
1517
}
1618
}
19+
20+
export async function getItemById(productId = "") {
21+
try {
22+
const res = await instance.get(`/products/${productId}`);
23+
return res.data;
24+
} catch (error) {
25+
console.error(error);
26+
throw error;
27+
}
28+
}
29+
30+
export async function getItemComments(productId = "", { cursor = 0 }) {
31+
const query = `limit=${COMMENTS_LIMIT}&cursor=${cursor}`;
32+
try {
33+
const res = await instance.get(`/products/${productId}/comments?${query}`);
34+
return res.data;
35+
} catch (error) {
36+
console.error(error);
37+
throw error;
38+
}
39+
}
Lines changed: 3 additions & 2 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
478 Bytes
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)