Skip to content

Commit 802d3b7

Browse files
authored
Merge pull request #333 from Sookyeong02/Next-장수경-sprint11
[장수경] sprint11
2 parents 2a28fdf + 9565ceb commit 802d3b7

22 files changed

+216
-93
lines changed

api/api.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export async function getProducts({
2121
}
2222
}
2323

24-
export async function getDetailComments(productId: string) {
24+
export async function getDetailComments(productId: number) {
2525
if (!productId) {
2626
throw new Error("Invalid product ID");
2727
}
@@ -52,10 +52,15 @@ export async function getProductComments({
5252
throw new Error("Invalid product ID");
5353
}
5454

55+
const params = {
56+
limit: String(limit),
57+
};
58+
5559
try {
5660
// 올바르게 URLSearchParams 생성
5761
// const query = new URLSearchParams().toString(); // 빈 쿼리 문자열을 생성
58-
const query = `limit=${limit}`;
62+
// const query = `limit=${limit}`;
63+
const query = new URLSearchParams(params).toString();
5964
const response = await fetch(
6065
`https://panda-market-api.vercel.app/products/${productId}/comments?${query}`
6166
); // api 호출

components/board/AllArticle.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
44
import ArticleItem from "./ArticleItem";
55
import Search from "@/components/ui/Search";
66
import Dropdown from "@/components/ui/Dropdown";
7+
import Link from "next/link";
78

89
interface AllArticlesProps {
910
initialArticles: Article[];
@@ -52,7 +53,7 @@ const AllArticle = ({ initialArticles }: AllArticlesProps) => {
5253
<div>
5354
<div>
5455
<h2>게시글</h2>
55-
<button>글쓰기</button>
56+
<Link href="/addboard">글쓰기</Link>
5657
</div>
5758

5859
<div>

components/board/ArticleContent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Article } from "@/types/Types";
22
import Kebob from "@/public/images/ic_kebab.svg";
33
import ArticleInfo from "./ArticleInfo";
4+
import Image from "next/image";
45

56
interface ArticleContentProps {
67
article: Article;
@@ -13,7 +14,7 @@ const ArticleContent = ({ article }: ArticleContentProps) => {
1314
<h3>{article.title}</h3>
1415

1516
<button>
16-
<Kebob />
17+
<Image src={Kebob} alt="kebob" width={24} height={24} />
1718
</button>
1819

1920
<div>

components/board/ArticleInfo.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Profile from "@/public/images/profile.svg";
22
import { Article } from "@/types/Types";
33
import { formatDate } from "date-fns";
4+
import Image from "next/image";
45

56
interface ArticleInfoProps {
67
article: Article;
@@ -11,7 +12,7 @@ const ArticleInfo = ({ article }: ArticleInfoProps) => {
1112

1213
return (
1314
<div>
14-
<Profile width={24} heigt={24} />
15+
<Image src={Profile} alt="프로필" width={24} height={24} />
1516
{article.writer.nickname} {formetDate}
1617
</div>
1718
);

components/board/ArticleItem.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ const ArticleItem = ({ article }: ArticleItemProps) => {
1717
<div>
1818
<div>
1919
<Image
20-
fill
2120
src={article.image}
2221
alt={`${article.id}번 게시글 이미지`}
2322
style={{ objectFit: "contain" }}
23+
layout="responsive"
24+
width={1} // 비율 유지 (가로 1)
25+
height={1} // 비율 유지 (세로 1)
2426
/>
2527
</div>
2628
</div>

components/board/BestArticle.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const BestArticleCard = ({ article }: { article: Article }) => {
1212
<>
1313
<Link href={`/board/${article.id}`}>
1414
<div>
15-
<MedalIcon alt="베스트 게시글" />
15+
<Image src={MedalIcon} alt="베스트 게시글" width={24} height={24} />
1616
Best
1717
</div>
1818

@@ -22,10 +22,11 @@ const BestArticleCard = ({ article }: { article: Article }) => {
2222
{article.image && (
2323
<div>
2424
<Image
25-
fill
2625
src={article.image}
2726
alt={`${article.id}번 게시글 이미지`}
28-
style={{ objectFit: "contain" }}
27+
// style={{ objectFit: "contain" }}
28+
width="24"
29+
height="24"
2930
/>
3031
</div>
3132
)}

components/market/AllProduct.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import Link from "next/link";
44
import SearchIcon from "@/public/images/ic_search.svg";
55
// import Image from "next/image";
66
import Dropdown from "@/components/ui/Dropdown";
7-
import "@/styles/AllProduct.module.css";
7+
// import styles from "@/styles/AllProduct.module.css";
88
import { useEffect, useState } from "react";
99
import ItemCard from "@/components/market/ItemCard";
1010
import { getProducts } from "@/api/api";
1111
import Pagination from "@/components/ui/Pagination";
1212
import { Product, ProductListResponse, ProductSortOption } from "@/types/Types";
1313
import { useRouter } from "next/router";
14+
import Image from "next/image";
1415

1516
// 화면 사이즈
1617
const getPageSize = (width: number) => {
@@ -152,7 +153,7 @@ const AllProduct = () => {
152153
width={24}
153154
height={24}
154155
/> */}
155-
<SearchIcon alt="Search Icon" />
156+
<Image src={SearchIcon} alt="Search Icon" width={24} height={24} />
156157
<input
157158
className="searchInput"
158159
// onSearch={handleSearch}

components/market/ItemCard.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ const ItemCard = ({ item }: ItemCardProps) => {
1515
src={item.images[0]}
1616
alt={`${item.name} 상품 썸네일`}
1717
className="itemCardImg"
18+
layout="responsive"
19+
width={1} // 비율 유지 (가로 1)
20+
height={1} // 비율 유지 (세로 1)
1821
/>
1922
<div>
2023
<h2 className="itemName">{item.name}</h2>
2124
<p className="itemPrice">{item.price.toLocaleString()}</p>
2225
<div className="favoriteCount">
23-
<HeartIcon />
26+
<Image src={HeartIcon} alt="좋아요" width={24} height={24} />
2427
{/* <Image
2528
src="/images/ic_heart.svg"
2629
alt="Heart Icon"

components/productdetail/DetailComment.tsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,7 @@ import { getProductComments } from "@/api/api";
44
import InquiryEmpty from "../../../public/images/inquiry_empty.svg";
55
import ProfileImg from "../../../images/profile.png";
66
import Kebab from "../../../public/images/ic_kebab.svg";
7-
8-
// 댓글 데이터 타입 정의
9-
interface Comment {
10-
id: string;
11-
content: string;
12-
updatedAt: Date;
13-
createdAt: Date;
14-
writer: {
15-
image: string | null;
16-
nickname: string;
17-
id: string;
18-
};
19-
}
7+
import { Comment } from "@/types/Types";
208

219
// CommentItem 컴포넌트
2210
type CommentItemProps = {
@@ -106,7 +94,7 @@ const EmptyState = () => {
10694

10795
// DetailComment 컴포넌트
10896
type DetailCommentProps = {
109-
productId: string;
97+
productId: number;
11098
};
11199

112100
interface ProductCommentList {
@@ -126,9 +114,9 @@ function DetailComment({ productId }: DetailCommentProps) {
126114
setIsLoading(true);
127115

128116
try {
129-
const response: ProductCommentList = await getProductComments(
130-
productId
131-
);
117+
const response: ProductCommentList = await getProductComments({
118+
productId,
119+
});
132120
setComments(response.list);
133121
setError(null);
134122
} catch (error) {

components/productdetail/DetailInput.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import React, { useState } from "react";
1+
import React, { ChangeEvent, useState } from "react";
22
import DetailComment from "./DetailComment";
33

4-
function DetailInput({ productId }) {
4+
interface DetailInputProps {
5+
productId: number;
6+
}
7+
8+
function DetailInput({ productId }: DetailInputProps) {
59
const [inputValue, setInputValue] = useState("");
610

7-
const handleInputChange = (e) => {
11+
const handleInputChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
812
setInputValue(e.target.value);
913
};
1014

0 commit comments

Comments
 (0)