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
9 changes: 7 additions & 2 deletions api/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function getProducts({
}
}

export async function getDetailComments(productId: string) {
export async function getDetailComments(productId: number) {
if (!productId) {
throw new Error("Invalid product ID");
}
Expand Down Expand Up @@ -52,10 +52,15 @@ export async function getProductComments({
throw new Error("Invalid product ID");
}

const params = {
limit: String(limit),
};

try {
// 올바르게 URLSearchParams 생성
// const query = new URLSearchParams().toString(); // 빈 쿼리 문자열을 생성
const query = `limit=${limit}`;
// const query = `limit=${limit}`;
const query = new URLSearchParams(params).toString();
Copy link
Collaborator

Choose a reason for hiding this comment

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

URLSearchParams 를 잘 활용해주셨습니다! 👍

const response = await fetch(
`https://panda-market-api.vercel.app/products/${productId}/comments?${query}`
); // api 호출
Expand Down
3 changes: 2 additions & 1 deletion components/board/AllArticle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
import ArticleItem from "./ArticleItem";
import Search from "@/components/ui/Search";
import Dropdown from "@/components/ui/Dropdown";
import Link from "next/link";

interface AllArticlesProps {
initialArticles: Article[];
Expand Down Expand Up @@ -52,7 +53,7 @@ const AllArticle = ({ initialArticles }: AllArticlesProps) => {
<div>
<div>
<h2>게시글</h2>
<button>글쓰기</button>
<Link href="/addboard">글쓰기</Link>
</div>

<div>
Expand Down
3 changes: 2 additions & 1 deletion components/board/ArticleContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Article } from "@/types/Types";
import Kebob from "@/public/images/ic_kebab.svg";
import ArticleInfo from "./ArticleInfo";
import Image from "next/image";

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

<button>
<Kebob />
<Image src={Kebob} alt="kebob" width={24} height={24} />
</button>

<div>
Expand Down
3 changes: 2 additions & 1 deletion components/board/ArticleInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Profile from "@/public/images/profile.svg";
import { Article } from "@/types/Types";
import { formatDate } from "date-fns";
import Image from "next/image";

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

return (
<div>
<Profile width={24} heigt={24} />
<Image src={Profile} alt="프로필" width={24} height={24} />
{article.writer.nickname} {formetDate}
</div>
);
Expand Down
4 changes: 3 additions & 1 deletion components/board/ArticleItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ const ArticleItem = ({ article }: ArticleItemProps) => {
<div>
<div>
<Image
fill
src={article.image}
alt={`${article.id}번 게시글 이미지`}
style={{ objectFit: "contain" }}
layout="responsive"
width={1} // 비율 유지 (가로 1)
height={1} // 비율 유지 (세로 1)
/>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions components/board/BestArticle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const BestArticleCard = ({ article }: { article: Article }) => {
<>
<Link href={`/board/${article.id}`}>
<div>
<MedalIcon alt="베스트 게시글" />
<Image src={MedalIcon} alt="베스트 게시글" width={24} height={24} />
Best
</div>

Expand All @@ -22,10 +22,11 @@ const BestArticleCard = ({ article }: { article: Article }) => {
{article.image && (
<div>
<Image
fill
src={article.image}
alt={`${article.id}번 게시글 이미지`}
style={{ objectFit: "contain" }}
// style={{ objectFit: "contain" }}
width="24"
height="24"
/>
</div>
)}
Expand Down
5 changes: 3 additions & 2 deletions components/market/AllProduct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import Link from "next/link";
import SearchIcon from "@/public/images/ic_search.svg";
// import Image from "next/image";
import Dropdown from "@/components/ui/Dropdown";
import "@/styles/AllProduct.module.css";
// import styles from "@/styles/AllProduct.module.css";
import { useEffect, useState } from "react";
import ItemCard from "@/components/market/ItemCard";
import { getProducts } from "@/api/api";
import Pagination from "@/components/ui/Pagination";
import { Product, ProductListResponse, ProductSortOption } from "@/types/Types";
import { useRouter } from "next/router";
import Image from "next/image";

// 화면 사이즈
const getPageSize = (width: number) => {
Expand Down Expand Up @@ -152,7 +153,7 @@ const AllProduct = () => {
width={24}
height={24}
/> */}
<SearchIcon alt="Search Icon" />
<Image src={SearchIcon} alt="Search Icon" width={24} height={24} />
<input
className="searchInput"
// onSearch={handleSearch}
Expand Down
5 changes: 4 additions & 1 deletion components/market/ItemCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ const ItemCard = ({ item }: ItemCardProps) => {
src={item.images[0]}
alt={`${item.name} 상품 썸네일`}
className="itemCardImg"
layout="responsive"
width={1} // 비율 유지 (가로 1)
height={1} // 비율 유지 (세로 1)
/>
<div>
<h2 className="itemName">{item.name}</h2>
<p className="itemPrice">{item.price.toLocaleString()}원</p>
<div className="favoriteCount">
<HeartIcon />
<Image src={HeartIcon} alt="좋아요" width={24} height={24} />
{/* <Image
src="/images/ic_heart.svg"
alt="Heart Icon"
Expand Down
22 changes: 5 additions & 17 deletions components/productdetail/DetailComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,7 @@ import { getProductComments } from "@/api/api";
import InquiryEmpty from "../../../public/images/inquiry_empty.svg";
import ProfileImg from "../../../images/profile.png";
import Kebab from "../../../public/images/ic_kebab.svg";

// 댓글 데이터 타입 정의
interface Comment {
id: string;
content: string;
updatedAt: Date;
createdAt: Date;
writer: {
image: string | null;
nickname: string;
id: string;
};
}
import { Comment } from "@/types/Types";

// CommentItem 컴포넌트
type CommentItemProps = {
Expand Down Expand Up @@ -106,7 +94,7 @@ const EmptyState = () => {

// DetailComment 컴포넌트
type DetailCommentProps = {
productId: string;
productId: number;
};

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

try {
const response: ProductCommentList = await getProductComments(
productId
);
const response: ProductCommentList = await getProductComments({
productId,
});
setComments(response.list);
setError(null);
} catch (error) {
Expand Down
10 changes: 7 additions & 3 deletions components/productdetail/DetailInput.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import React, { useState } from "react";
import React, { ChangeEvent, useState } from "react";
import DetailComment from "./DetailComment";

function DetailInput({ productId }) {
interface DetailInputProps {
productId: number;
}

function DetailInput({ productId }: DetailInputProps) {
const [inputValue, setInputValue] = useState("");

const handleInputChange = (e) => {
const handleInputChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
setInputValue(e.target.value);
};

Expand Down
23 changes: 10 additions & 13 deletions components/productdetail/ItemContent.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import React from "react";
import TagList from "./TagList";
import LikeButton from "./LikeButton";
import { ReactComponent as Kebab } from "../../../images/ic_kebab.svg";

interface Product {
id: string;
name: string;
description: string;
price: number;
tags: string[];
images: string[];
isFavorite: boolean;
favoriteCount: number;
}
import Kebab from "@/public/images/ic_kebab.svg";
import { Product } from "@/types/Types";
import Image from "next/image";

interface ItemContentProps {
product: Product;
Expand All @@ -30,7 +21,13 @@ function ItemContent({ product }: ItemContentProps) {
<div className="mainDetail">
{/* 더보기 버튼 */}
<button className="kebabButton">
<Kebab className="kebobIcon" />
<Image
src={Kebab}
alt="kebab"
width={24}
height={24}
className="kebobIcon"
/>
</button>

<div>
Expand Down
4 changes: 2 additions & 2 deletions components/productdetail/LikeButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState } from "react";
import { ReactComponent as Heart } from "../../../image/ic_heart.svg";
import Heart from "@/public/images/ic_heart.svg";

interface LikeButtonProps {
productId: string;
productId: number;
isFavorite: boolean;
favoriteCount: number;
}
Expand Down
5 changes: 3 additions & 2 deletions components/ui/DeleteButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import CloseIcon from "../public/images/ic_close.svg";
import CloseIcon from "@/public/images/ic_close.svg";
import Image from "next/image";

interface DeleteButtonProps {
onClick: () => void;
Expand All @@ -9,7 +10,7 @@ interface DeleteButtonProps {
function DeleteButton({ onClick, label }: DeleteButtonProps) {
return (
<button aria-label={`${label} 삭제`} onClick={onClick}>
<CloseIcon />
<Image src={CloseIcon} alt="close" width={24} height={24} />
</button>
);
}
Expand Down
9 changes: 2 additions & 7 deletions components/ui/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from "react";
// import "./Dropdown.css";
// import SortIcon from "../../public/images/ic_sort.svg";
import SortIcon from "../../public/images/ic_sort.svg";
import Image from "next/image";

interface DropdownProps {
Expand All @@ -18,12 +18,7 @@ function Dropdown({ onSortSelection, sortOptions }: DropdownProps) {
return (
<div>
<button onClick={toggleDropdown}>
<Image
src="/images/ic_sort.svg"
alt="Sort Icon"
width={24}
height={24}
/>
<Image src={SortIcon} alt="Sort Icon" width={24} height={24} />
</button>

{isDropdownView && (
Expand Down
4 changes: 2 additions & 2 deletions components/ui/ImageUpload.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useRef, useState } from "react";
// import { useEffect } from "react";
import PlusIcon from "../public/images/ic_plus.svg";
import PlusIcon from "@/public/images/ic_plus.svg";
import DeleteButton from "./DeleteButton";
import Image from "next/image";

Expand Down Expand Up @@ -60,7 +60,7 @@ const ImageUpload = ({ title }: ImageUploadProps) => {
>
<div className="uploadBoxContent">
<p className="textArea">
<PlusIcon />
<Image src={PlusIcon} alt="Plus" width={24} height={24} />
<br /> 이미지 등록
</p>
</div>
Expand Down
6 changes: 3 additions & 3 deletions components/ui/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import Left from "@/public/images/left.svg";
import Right from "@/public/images/right.svg";
import "../../styles/Pagination.module.css";
// import Image from "next/image";
import Image from "next/image";

interface PaginationProps {
totalPageNum: number;
Expand Down Expand Up @@ -37,7 +37,7 @@ export default function Pagination({
disabled={activePageNum === 1}
onClick={() => onPageChange(activePageNum - 1)}
>
<Left />
<Image src={Left} alt="Previous" width={40} height={40} />
{/* <Image src="/images/left.svg" alt="Previous" width={40} height={40} /> */}
</button>
{pages.map((page) => (
Expand All @@ -56,7 +56,7 @@ export default function Pagination({
disabled={activePageNum === totalPageNum}
onClick={() => onPageChange(activePageNum + 1)}
>
<Right />
<Image src={Right} alt="Next" width={40} height={40} />
{/* <Image src="/images/right.svg" alt="Next" width={40} height={40} /> */}
</button>
</div>
Expand Down
3 changes: 2 additions & 1 deletion components/ui/Search.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import SearchIcon from "@/public/images/ic_search.svg";
import { useEffect, useState } from "react";
import { useRouter } from "next/router";
import Image from "next/image";

interface SearchProps {
onSearch: (keyword: string) => void;
Expand Down Expand Up @@ -31,7 +32,7 @@ const Search = ({

return (
<div>
<SearchIcon alt="검색" />
<Image src={SearchIcon} alt="검색 아이콘" width={24} height={24} />
<input
value={keyword}
onChange={handleInputChange}
Expand Down
9 changes: 9 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
domains: [
Copy link
Collaborator

Choose a reason for hiding this comment

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

외부에서 이미지를 가져올 일이 있었나요..?

"sprint-fe-project.s3.ap-northeast-2.amazonaws.com",
"example.com",
"image.hanatour.com",
"youtube.com",
"cafe24.poxo.com",
],
},
};

module.exports = nextConfig;
Loading
Loading