Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d15ab4e
chore: 콤포넌트 외의 파일들은 소문자로 수정
y5037 Dec 4, 2024
fd53c0b
refactor(mentor): 새로 생성한 utils 디렉토리로 이메일 유효성 검사 파일을 옮기고 파일명 소문자로 수정
y5037 Dec 4, 2024
d6cadc1
refactor(mentor): 테스트와 유지보수의 어려움을 최소화 하기 위해 유틸 함수로 추출
y5037 Dec 4, 2024
eacf748
chore: 개연성 없는 import 순서 및 직관적이지 않은 변수 또는 콤포넌트명 변경
y5037 Dec 4, 2024
eaf7637
chore: refactor(mentor): 콤포넌트 분리 및 연관성 높은 파일명으로 수정
y5037 Dec 4, 2024
3def5b2
chore: 중고마켓의 미디어쿼리 utils로 분리
y5037 Dec 4, 2024
b442aff
refactor(mentor): 상품등록 페이지를 상품리스트 페이지와 묶어 Route 처리
y5037 Dec 4, 2024
355d4d2
refactor(mentor): GET API 쿼리 스트링 params로 받아 URLSearchParams 사용으로 변경
y5037 Dec 5, 2024
1319769
refactor(mentor): return 조건들을 더욱 명시적으로 수정
y5037 Dec 5, 2024
a993b6d
refactor(mentor): 코드의 의미를 명확히 전달하기 위해 의도를 명시하는 이름으로 변경
y5037 Dec 5, 2024
975819f
refactor(mentor): 페이지 번호 생성 로직의 가독성을 높이기 위해 헬퍼 함수로 분리
y5037 Dec 5, 2024
eeb62ec
refactor(mentor): number 데이터 타입에서 바로 콤마 처리
y5037 Dec 5, 2024
67f70c0
refactor(mentor): 사용되지 않는 prop 제거
y5037 Dec 5, 2024
a9c496f
refactor(mentor): 코드를 직관적으로 볼 수 있도록 컴포넌트로 분리
y5037 Dec 5, 2024
df03083
feat: 제품 상세페이지에서 상품 상세부분 API 구현
y5037 Dec 5, 2024
645380e
chore: 상품 디테일 페이지 옵션 메뉴 추가, 기능 구현X
y5037 Dec 6, 2024
2915b45
chore: CSS 디렉토리 및 파일명 컴포넌트가 아니므로 소문자로 변경
y5037 Dec 6, 2024
490ab08
chore: 직관적인 파일명으로 변경
y5037 Dec 6, 2024
085d86d
chore: 전체 상품 리스트에 상품 디테일 페이지 링크 추가
y5037 Dec 6, 2024
6713da0
feat: 상품 이미지 src 에러 발생 시 기본 이미지 출력
y5037 Dec 6, 2024
4204b23
feat: 상품 디테일 페이지 코멘트 부분 API 출력
y5037 Dec 6, 2024
a93e213
feat: 상품 디테일 페이지 코멘트 없을 시 UI 추가
y5037 Dec 6, 2024
96b9194
test: API POST 접근 권한 없음 에러 발생(로그인 구현X)으로 상품 디테일 페이지 코멘트 등록하기 기능 구현 보류
y5037 Dec 6, 2024
e02e998
feat: 코멘트 수정하기 UI 추가
y5037 Dec 7, 2024
cf7c64c
chore: 코멘트 섹션 CSS 누락건 추가
y5037 Dec 7, 2024
e0e49be
chore: 렌더링 시 보이는 border가 UI적으로 미관상 좋지 않아 CSS 수정
y5037 Dec 7, 2024
12f60a1
chore: 상품 디테일 썸네일 CSS 수정
y5037 Dec 7, 2024
05b878e
chore: 코멘트 API POST 구현 보류에 대한 주석 추가
y5037 Dec 8, 2024
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
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# timeago warning 해결
GENERATE_SOURCEMAP=false
19 changes: 18 additions & 1 deletion 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 @@ -16,6 +16,7 @@
"react-responsive": "^10.0.0",
"react-router-dom": "^6.28.0",
"react-scripts": "5.0.1",
"react-timeago": "^7.2.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

오 기능 구현에 필요한 라이브러리 탐색하는거 좋습니다

"styled-components": "^6.1.13",
"web-vitals": "^2.1.4"
},
Expand Down
9 changes: 6 additions & 3 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
<meta property="og:type" content="website" />
<meta property="og:title" content="판다 마켓" />
<meta property="og:description" content="일상의 모든 물건을 거래해보세요" />
<meta property="og:image" content="img/meta/thumbnail.png" />
<meta property="og:image:type" content="img/meta/thumbnail.png" />
<meta property="og:image" content="./assets/images/meta/thumbnail.png" />
<meta
property="og:image:type"
content="./assets/images/meta/thumbnail.png"
/>
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<!-- -->
<link
rel="shortcut icon"
href="./Assets/images/meta/favicon.ico"
href="./assets/images/meta/favicon.ico"
type="image/x-icon"
/>
<title>판다마켓</title>
Expand Down
64 changes: 59 additions & 5 deletions src/Api/api.js
Copy link
Collaborator

Choose a reason for hiding this comment

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

api 디렉토리의 경우, 콤포넌트를 위한 디렉토리가 아닌것으로 생각되어요.
따라서 소문자로 경로 이름을 두면 어떨까요?

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
async function getProductData({ orderBy, pageSize, search, page }) {
const query = `page=${page}&orderBy=${orderBy}&pageSize=${pageSize}&keyword=${search}`;
const response = await fetch(
`https://panda-market-api.vercel.app/products?${query}`
);
const BASE_URL = "https://panda-market-api.vercel.app";
Copy link
Collaborator

Choose a reason for hiding this comment

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

상수로 관리하는거 너무 좋습니당


// 베스트/전체 상품 리스트
async function getProductData(params = {}) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

default 값 주신거 너무 좋습니다 👍🏻

const query = new URLSearchParams(params).toString();
const response = await fetch(`${BASE_URL}/products?${query}`);

if (!response.ok) {
throw new Error("상품을 불러오는 데 실패했습니다.");
Expand All @@ -11,4 +12,57 @@ async function getProductData({ orderBy, pageSize, search, page }) {
return body;
}

// 디테일 상품 정보
export async function getProductId(productId, setProductData) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

오, 우리 api 함수들의 역할을 다시 한번만 생각해볼까요?

우선 API에 둔 함수의 역할은 다음과 같이 생각되는데요

  • 전달받은 인자값 또는 데이터를 서버에 전송하기 좋게 가공하기
  • 서버에 네트워크 통신 전송하기
  • 결과에 따라 오류를 던져주거나 전달받은 데이터를 반환해주기

이 상황에서 api함수들은 딱 위 작업만 진행을 하고, 화면에 보여질 데이터를 업데이트 해주는 setState액션은 콤포넌트와 가장 가까운 곳에서 작업을 진행해주어야 할 것 같아요!

const response = await fetch(`${BASE_URL}/products/${productId}`);

try {
const body = await response.json();
setProductData(body);
} catch (error) {
console.log(error);
}

if (!response.ok) {
throw new Error("정보를 불러오는 데 실패했습니다.");
}
}

// 디테일 댓글
export async function getComments(productId, setCommentsData) {
const response = await fetch(
`${BASE_URL}/products/${productId}/comments?limit=10`
);
Comment on lines +32 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.

여기서도 limit 정보는 getComments의 인자로 전달받아보면 어떨까요?

try {
const body = await response.json();
setCommentsData(body);
} catch (error) {
console.log(error);
}

if (!response.ok) {
throw new Error("정보를 불러오는 데 실패했습니다.");
}
}

// 디테일 댓글 등록
// 로그인 기능 구현 전이므로 코멘트 API POST 구현 보류 (24.12.08)
// export async function createComment(productId, comment) {
// const surveyData = {
// content: comment,
// };
// const response = await fetch(`${BASE_URL}/products/${productId}/comments`, {
// method: "POST",
// // 자바스크립트 객체를 JSON 문자열로 변환하여 post 보내기
// headers: {
// "Content-Type": "application/json",
// accept: "application/json",
// Authorization:
// "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NTE3LCJzY29wZSI6ImFjY2VzcyIsImlhdCI6MTczMzU2MzU1NCwiZXhwIjoxNzMzNTY1MzU0LCJpc3MiOiJzcC1wYW5kYS1tYXJrZXQifQ.Wpof71osRiwDAxNq34xcc4JGYqkEb_KaXYUKVc3Pz3M",
// },
// body: JSON.stringify(surveyData),
// });
// const data = await response.json();
// }

export default getProductData;
4 changes: 4 additions & 0 deletions src/Assets/images/app/button/btn_back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions src/Assets/images/productDetail/default_profile.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