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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ dist-ssr
*.njsproj
*.sln
*.sw?

# Environment variables
.env
Comment on lines +26 to +27
Copy link
Collaborator

Choose a reason for hiding this comment

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

굿굿 ! 환경 변수를 추가하고 gitignore에 추가하셨군요 ! 👍

116 changes: 101 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
},
"dependencies": {
"@tailwindcss/vite": "^4.0.6",
"axios": "^1.8.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router": "^7.1.3",
"react-router-dom": "^7.1.3",
"tailwindcss": "^4.0.6"
},
Expand Down
19 changes: 11 additions & 8 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ import AddItem from "@/pages/AddItem.jsx";
import Boards from "@/pages/Boards";
import Policy from "@/pages/Policy.jsx";
import Faq from "@/pages/Faq.jsx";
import Layout from "./components/MainLayout";

function App() {
return (
<StrictMode>
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />}></Route>
<Route path="/login" element={<Login />}></Route>
<Route path="/signup" element={<Signup />}></Route>
<Route path="/items" element={<Items />}></Route>
<Route path="/additem" element={<AddItem />}></Route>
<Route path="/privacy" element={<Policy />}></Route>
<Route path="/faq" element={<Faq />}></Route>
<Route path="/boards" element={<Boards />}></Route>
<Route element={<Layout />}>
<Route path="/" element={<Home />} />
<Route path="/items" element={<Items />} />
<Route path="/additem" element={<AddItem />} />
<Route path="/boards" element={<Boards />} />
</Route>
<Route path="/login" element={<Login />} />
<Route path="/signup" element={<Signup />} />
<Route path="/privacy" element={<Policy />} />
<Route path="/faq" element={<Faq />} />
Comment on lines +19 to +28
Copy link
Collaborator

@kiJu2 kiJu2 Mar 13, 2025

Choose a reason for hiding this comment

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

우와.. 활용도가 너무 좋으신데요?

라이브러리를 정말 잘 사용하시는군요 ! 👍👍👍

</Routes>
</BrowserRouter>
</StrictMode>
Expand Down
34 changes: 25 additions & 9 deletions src/api/api.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
import instance from "@/api/axiosInstance";

const PRODUCT_ENDPOINT = `/products`;
const IMAGE_ENDPOINT = `/images/upload`;

export const getItems = async (
page,
pageSize,
orderBy = "recent",
keyword = null,
) => {
const baseURL = "https://panda-market-api.vercel.app/products/";
const params = new URLSearchParams({
const params = {
page: page,
pageSize: pageSize,
orderBy: orderBy,
});
};

if (keyword) {
params.append("keyword", keyword);
params[keyword] = keyword;
}

const requrl = `${baseURL}?${params.toString()}`;

const response = await fetch(requrl, {
method: "GET",
const response = await instance.get(PRODUCT_ENDPOINT, {
params: params,
});
const data = await response.json();

const data = response.data;
return data;
};

export const postItem = async (item) => {
const response = await instance.post(PRODUCT_ENDPOINT, item);
const data = response.data;
return data;
};
Comment on lines +30 to +34
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
export const postItem = async (item) => {
const response = await instance.post(PRODUCT_ENDPOINT, item);
const data = response.data;
return data;
};
export const postItem = async (item) => {
const { data } = await instance.post(PRODUCT_ENDPOINT, item);
return data;
};

위와 같이 구조 분해 할당으로 간략히 작성할 수 있습니다 ! 😊

구조 분해 할당 구문은 배열이나 객체의 속성을 해체하여 그 값을 개별 변수에 담을 수 있게 하는 JavaScript 표현식입니다.


export const uploadImage = async (image) => {
const response = await instance.post(IMAGE_ENDPOINT, { image });
const data = response.data;

return data;
};
12 changes: 12 additions & 0 deletions src/api/axiosInstance.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import axios from "axios";

const API_BASE_URL = import.meta.env.VITE_API_BASE_URL;

const axiosInstance = axios.create({
baseURL: API_BASE_URL,
headers: {
"Content-Type": "application/json",
},
});

export default axiosInstance;
5 changes: 5 additions & 0 deletions src/assets/ic_close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading