Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
58b0981
[Refactor] HomePage 스타일 분리
Feb 13, 2025
fe73546
[Chore] create Product.jsx
Feb 13, 2025
c089e18
[Feat] getComments, getProductInfo api created
Feb 14, 2025
ff9c75d
[Chore] productpage 전체 ui 구성
Feb 14, 2025
f85bdfd
[Feat] comment.jsx 구조 구성
Feb 14, 2025
91fb7c5
[Feat]get comment
Feb 14, 2025
e931d2c
[Chore] create common compoenet BtnHeart
Feb 14, 2025
0f56568
[Chore] Btn Heart border
Feb 14, 2025
38081d0
[Feat] create kebab component
Feb 14, 2025
2a9d87d
[Refactor] edit tag component 태그에 배열을 넘기면 tag 컴포넌트 안에서 자동을 뿌려줌
Feb 15, 2025
ec72e73
[Feat] create useFormatPrice
Feb 15, 2025
b1efb18
[Style] border-bottom edit
Feb 15, 2025
9ca3d66
[Refactor] edit input style and commentInput onchange handler
Feb 15, 2025
683ab87
[Feat] kebab select
Feb 15, 2025
22a1e07
[Feat] useNavigate로 목록으로 돌아가기 버튼
Feb 15, 2025
74144e9
[Chore] prop 넘길시 tag의 delete 버튼 안보이게 수정
Feb 15, 2025
af11121
[Style] edit style
Feb 15, 2025
a29ce2b
[Style]반응형
Feb 16, 2025
d6fba06
[Chore] theme.font 적용
Feb 16, 2025
a1ef393
[Feat] 수정하기 버튼시 입력 폼에 이전내용
Feb 16, 2025
e589fe6
[Feat] 타임 스탬프로 부터 몇시간이 지났는지 알려주는 커스텀 훅 적용
Feb 16, 2025
f4be2c5
[Feat] review 수정시 수정 반영됨
Feb 16, 2025
f0036d4
[Feat] 수정버튼 클릭시 kebab 사라짐
Feb 16, 2025
d6c5f1a
[Refactor] edit input props
Feb 16, 2025
31176dd
[Refactor] imgInput props edited
Feb 16, 2025
2d1a980
[Refactor] create constant required_input
Feb 16, 2025
5c0d686
[Chore] delete console.log
Feb 16, 2025
bda17f4
[Feat] add useNavigate itemList to items/{product.id}
Feb 18, 2025
d86c63d
[Refactor]문의 코멘트에 프로필 이미지 있을경우 사이즈
Feb 18, 2025
12d3a0a
[Refactor] edit ProductInfo style
Feb 18, 2025
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
29 changes: 29 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.7.9",
"firebase": "^11.1.0",
"lodash.throttle": "^4.1.1",
"react": "^18.2.0",
Expand Down
21 changes: 21 additions & 0 deletions src/Hooks/useAutoClose.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useState, useEffect, useRef } from "react";

export function useAutoClose(initialState) {
const [isOpen, setIsOpen] = useState(initialState);
const ref = useRef(null);

const handleOutsideClick = (e) => {
if (ref.current && !ref.current.contains(e?.target)) {
setIsOpen(false);
}
};

useEffect(() => {
document.addEventListener("click", handleOutsideClick, true);
return () => {
document.removeEventListener("click", handleOutsideClick, true);
};
}, []);

return { ref, isOpen, setIsOpen };
}
33 changes: 33 additions & 0 deletions src/Hooks/useFormatting.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export function useFormatDate(data) {
const date = new Date(data);
const formattedDate = `${date.getFullYear()}.${String(
date.getMonth() + 1
).padStart(2, "0")}.${String(date.getDate()).padStart(2, "0")}`;
return formattedDate;
}

export const useFormatPrice = (data, currency = "KRW") => {
if (typeof data !== "number") return "가격 정보 없음";
return data.toLocaleString("ko-KR", {
style: "decimal",
currency: currency,
});
};

export const useFormatUpDate = (timestamp) => {
const now = new Date();
const past = new Date(timestamp);
const diff = (now - past) / 1000;

if (diff < 60) {
return "1분전";
} else if (diff < 3600) {
return `${Math.floor(diff / 60)}분 전`; // 1시간 미만
} else if (diff < 86400) {
return `${Math.floor(diff / 3600)}시간 전`; // 24시간 미만
} else if (diff < 30 * 86400) {
return `${Math.floor(diff / 86400)}일 전`; // 30일 미만
} else {
return past.toISOString().split("T")[0]; // YYYY-MM-DD 형식 (한 달 이상 지난 경우)
}
};
70 changes: 70 additions & 0 deletions src/Main.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { Route, BrowserRouter, Routes } from "react-router-dom";
import { createGlobalStyle } from "styled-components";
//
import LandingPage from "./pages/LandingPage/LandingPage.jsx";
import App from "./App.js";
import HomePage from "./pages/HomePage/HomePage.jsx";
import AddItem from "./pages/AddItem/AddItem.jsx";
import Product from "./pages/ProductPage/Product.jsx";
import Test from "./components/TestPage.jsx";
//
//
const GlobalStyle = createGlobalStyle`
* {
box-sizing: border-box;
}
body {
font-family: 'Pretendard', sans-serif;
font-display: swap;
margin: 0;
padding: 0;
}
html {
margin: 0;
padding: 0;
}
a {
text-decoration: none;
color: #ffffff;
}
p{
margin: 0px;
}
@font-face {
font-family: 'Pretendard';
src: url('https://fastly.jsdelivr.net/gh/Project-Noonnu/noonfonts_2107@1.1/Pretendard-Regular.woff2') format('woff2');
src: url('https://fastly.jsdelivr.net/gh/Project-Noonnu/noonfonts_2107@1.1/Pretendard-Regular.woff') format('woff');
font-display: swap;
font-weight: 400;
font-style: normal;
}

@font-face {
font-family: "Pretendard";
src: url('https://fastly.jsdelivr.net/gh/Project-Noonnu/noonfonts_2107@1.1/Pretendard-Bold.woff2') format('woff2');
src: url('https://fastly.jsdelivr.net/gh/Project-Noonnu/noonfonts_2107@1.1/Pretendard-Bold.woff') format('woff');
font-display: swap;
font-weight: 600;
font-style: normal;
}
`;
//
function Main() {
return (
<>
<GlobalStyle />
<BrowserRouter>
<Routes>
<Route path="/" element={<LandingPage />} />
<Route element={<App />}>
<Route path="/test" element={<Test />} />
<Route path="/items" element={<HomePage />} />
<Route path="/items/:productId" element={<Product />} />
<Route path="/additem" element={<AddItem />} />
</Route>
</Routes>
</BrowserRouter>
</>
);
}
export default Main;
17 changes: 17 additions & 0 deletions src/api/comment.api.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import axios from "axios";
const BASE_URL = "https://panda-market-api.vercel.app";

export async function getProductComments(productId, limit = 3) {
try {
const res = await axios.get(
`${BASE_URL}/products/${productId}/comments?limit=${limit}`
);
if (!res) {
throw new Error("리뷰 불러오기 실패");
}
return res.data;
} catch (error) {
console.error(error);
return null;
}
}
12 changes: 12 additions & 0 deletions src/api.js → src/api/product.api.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import axios from "axios";
const BASE_URL = "https://panda-market-api.vercel.app";

export async function getProducts({
Expand Down Expand Up @@ -28,3 +29,14 @@ export async function bestProducts({ device }) {
const body = await response.json();
return body;
}

export async function getProductInfo(productId) {
try {
const response = await axios.get(`${BASE_URL}/products/${productId}`);
if (!response) throw new Error("제품정보 get api 실패");
return response.data;
} catch (error) {
console.error(error, "제품정보 api 실패");
return null;
}
}
8 changes: 0 additions & 8 deletions src/assets/btn_sort.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/assets/favoriteLogo.svg

This file was deleted.

3 changes: 3 additions & 0 deletions src/assets/icons/active.heart.icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/inactive.heart.icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/icons/kebab.icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/icons/return.icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/select.icon.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