-
Notifications
You must be signed in to change notification settings - Fork 15
스프린트 미션 9제출 - Next 박창기 #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
devbini
merged 10 commits into
codeit-sprint-fullstack:next-박창기
from
p-changki:next-박창기
Dec 16, 2025
The head ref may contain hidden characters: "next-\uBC15\uCC3D\uAE30"
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
330614d
:sparkles: feat : 코드잇 api로 교체이후 fetchClient 생성후 회원가입, 로그인 구현완료
p-changki dfa3d03
:sparkles: feat : authProvider 생성후 articles page 로그인후 로컬스토리지 저장완료
p-changki 32a1e5a
:sparkles: feat :RoutGuard Providers create
p-changki f538b39
:sparkles: feat :items page create
p-changki 63ed669
✨ feat : ProductsBest 컴포넌트에 여백 추가 및 AuthProvider에서 토큰 기반 유저 초기화 로직 추가…
p-changki 5444fa4
feat : 상품 디테일 page 작성
p-changki e0746a1
feat : 프런트에서 커멘트 작성 완료 ( 다음미션에서 백엔드연결 예정)
p-changki 4587389
feat : comments 수정
p-changki a9d371f
feat : comments 엔터키 추가!
p-changki 5053786
feat : 모달 추가!
p-changki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,22 @@ | ||
| /** @type {import('next').NextConfig} */ | ||
| const nextConfig = { | ||
| /* config options here */ | ||
| reactCompiler: true, | ||
| images: { | ||
| domains: [ | ||
| "example.com", | ||
| "sprint-fe-project.s3.ap-northeast-2.amazonaws.com", | ||
| "st.depositphotos.com", | ||
| "i.pinimg.com", | ||
| "upload.wikimedia.org", | ||
| "cdn.wccftech.com", | ||
| "encrypted-tbn0.gstatic.com", | ||
| "image.hanatour.com", | ||
| "cdn.choicenews.co.kr", | ||
| "health.chosun.com", | ||
| "via.placeholder.com", | ||
| "i.imgur.com", | ||
| "images.samsung.com", | ||
| ], | ||
| }, | ||
| }; | ||
|
|
||
| export default nextConfig; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| "use client"; | ||
| import { IoIosArrowBack } from "react-icons/io"; | ||
| import { IoIosArrowForward } from "react-icons/io"; | ||
|
|
||
| export default function Pagination({ page, totalPages, onChange }) { | ||
| const pages = Array.from({ length: totalPages }, (_, i) => i + 1); | ||
|
|
||
| return ( | ||
| <div className="flex justify-center items-center gap-1 mt-[43px] mb-[140px]"> | ||
| <button | ||
| onClick={() => onChange(Math.max(page - 1, 1))} | ||
| disabled={page === 1} | ||
| className="w-10 h-10 shrink-0 border-2 border-gray-200 rounded-full flex items-center justify-center " | ||
| > | ||
| <IoIosArrowBack className="w-4 h-4" /> | ||
| </button> | ||
|
|
||
| {pages.map((num) => ( | ||
| <button | ||
| key={num} | ||
| onClick={() => onChange(num)} | ||
| className={`w-10 h-10 border border-gray-200 rounded-full flex items-center justify-center ${ | ||
| page === num ? "bg-[#2F80ED] text-white" : "bg-[#ffffff] " | ||
| }`} | ||
| > | ||
| {num} | ||
| </button> | ||
| ))} | ||
|
|
||
| <button | ||
| onClick={() => onChange(Math.min(page + 1, totalPages))} | ||
| disabled={page >= totalPages} | ||
| className="w-10 h-10 shrink-0 border-2 border-gray-200 rounded-full flex items-center justify-center " | ||
| > | ||
| <IoIosArrowForward /> | ||
| </button> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect, useState } from "react"; | ||
| import { getProducts } from "@/lib/services/products"; | ||
| import ProductsCard from "./ProductsCard"; | ||
|
|
||
| export default function ProductsBest() { | ||
| const [bestProducts, setBestProducts] = useState([]); | ||
| const [loading, setLoading] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| async function fetchBest() { | ||
| try { | ||
| setLoading(true); | ||
| const data = await getProducts({ | ||
| orderBy: "favorite", | ||
| page: 1, | ||
| pageSize: 4, | ||
| }); | ||
| setBestProducts(data.list); | ||
| } catch (error) { | ||
| console.error("베스트 상품 불러오기 실패:", error); | ||
| } finally { | ||
| setLoading(false); | ||
| } | ||
| } | ||
| fetchBest(); | ||
| }, []); | ||
|
|
||
| return ( | ||
| <section className="flex flex-col gap-6 mt-6 "> | ||
| <h2 className="text-[20px] font-bold text-[#111827] leading-8"> | ||
| 베스트 상품 | ||
| </h2> | ||
|
|
||
| {loading ? ( | ||
| <p className="text-gray-500 text-center">로딩 중...</p> | ||
| ) : ( | ||
| <ul className="grid grid-cols-4 gap-6"> | ||
| {bestProducts.map((item) => ( | ||
| <ProductsCard key={item.id} {...item} /> | ||
| ))} | ||
| </ul> | ||
| )} | ||
| </section> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| "use client"; | ||
| import Image from "next/image"; | ||
| import React, { useState } from "react"; | ||
| import heart from "@/public/images/ic_heart.png"; | ||
| import defaultImg from "@/public/images/eximg.png"; | ||
| import Link from "next/link"; | ||
|
|
||
| export default function ProductsCard({ | ||
| id, | ||
| name, | ||
| description, | ||
| images, | ||
| favoriteCount, | ||
| price, | ||
| }) { | ||
| console.log("상품 ID:", id, "이미지 데이터:", images); | ||
| const [currentImg, setCurrentImg] = useState(images?.[0] || defaultImg); | ||
|
|
||
| return ( | ||
| <li> | ||
| <Link href={`/items/${id}`}> | ||
| <div className="mt-4"> | ||
| <Image | ||
| src={currentImg || defaultImg} | ||
| alt={name} | ||
| width={220} | ||
| height={220} | ||
| priority | ||
| className="mb-4 rounded-lg object-cover object-center w-[220px] h-[220px]" | ||
| onError={() => setCurrentImg(defaultImg)} | ||
| // unoptimized Image 도메인 최적화 제한 해제 ! | ||
| /> | ||
| <div className="flex flex-col gap-1.5"> | ||
| <p className="text-[14px] font-medium text-[#1F2937] leading-6 "> | ||
| {description} | ||
| </p> | ||
| <p className="text-[16px] font-bold leading-[26px] text-[#1F2937] "> | ||
| {price ? Number(price).toLocaleString() : 0}원 | ||
| </p> | ||
| <div className="flex items-center gap-1"> | ||
| <Image | ||
| src={heart} | ||
| width={16} | ||
| height={16} | ||
| alt="하트이모티콘" | ||
| className="w-4 h-4 border-gray-600" | ||
| /> | ||
| <p className="text-[12px] text-[#4B5563] leading-[18px] font-medium"> | ||
| {favoriteCount} | ||
| </p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </Link> | ||
| </li> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☕ Thinking...
이 경우... 페이지네이션을 통해 상품 목록이 싹 바뀌었을 때 컴포넌트를 새로 불러오는 게 아니라면, 이미지가 변하지 않을 수 있어요.
이런 경우엔 조금 번거롭더라도, useEffect()로
images의 변경여부를 검사하고 set 해 주는 로직을 추가 해 두는 것도 안전하지 않을까 생각이 드네요.