-
Notifications
You must be signed in to change notification settings - Fork 79
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
[배현지] Sprint7 #594
Merged
airman5573
merged 16 commits into
codeit-bootcamp-frontend:React-배현지
from
baehyunji:React-배현지-sprint7
Jun 16, 2024
The head ref may contain hidden characters: "React-\uBC30\uD604\uC9C0-sprint7"
Merged
[배현지] Sprint7 #594
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b2e37bd
reset
hanseulhee 6f8bbb0
Merge branch 'codeit-bootcamp-frontend:main' into main
hanseulhee e11e25f
fix: 머지 후 브랜치 삭제 github action 수정
hanseulhee 212e864
env: workflows 폴더로 이동
hanseulhee 4dc5dd0
Merge pull request #237 from hanseulhee/fix-github-actions
withyj-codeit a099fbe
Merge branch 'React-배현지' of https://github.com/codeit-bootcamp-fronte…
baehyunji 375bc8f
Merge branch 'React-배현지' of https://github.com/codeit-bootcamp-fronte…
baehyunji 1cf0925
fix:피드백 반영
baehyunji cdbff5d
feat: 스프린트 미션6
baehyunji 5857033
Merge branch 'React-배현지' of https://github.com/codeit-bootcamp-fronte…
baehyunji 3ba3528
refactor: 코드 리팩토링
baehyunji f3c1d46
feat: 이미지 파일 추가
baehyunji 6c9a3d2
feat:상세 페이지 컴포넌트 구현
baehyunji 178c6b8
feat: api.js 파일 추가
baehyunji 711b5ff
fix: 간단 수정
baehyunji 51db926
Merge branch 'React-배현지' of https://github.com/baehyunji/6-Sprint-Mis…
baehyunji 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 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 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 @@ | ||
import ProductDetails from "../ui/ProductDetails"; | ||
import { useParams } from "react-router-dom"; | ||
import { useEffect, useState } from "react"; | ||
import { getProduct, getComment } from "../../api"; | ||
import CommentDetails from "../ui/CommentDetails"; | ||
|
||
function ProductDetailsContainer() { | ||
const { productId } = useParams(); | ||
const [product, setProduct] = useState(null); | ||
const [comments, setComments] = useState([]); | ||
|
||
useEffect(() => { | ||
const detailedProduct = async () => { | ||
try { | ||
const productData = await getProduct(productId); | ||
setProduct(productData); | ||
} catch (e) { | ||
if (e.response) { | ||
console.log(e.response.status); | ||
console.log(e.response.data); | ||
} else { | ||
console.log("리퀘스트가 실패했습니다."); | ||
} | ||
} | ||
}; | ||
|
||
const detailedComment = async () => { | ||
const params = { limit: 3 }; | ||
try { | ||
const commentData = await getComment({ productId, params }); | ||
setComments(commentData.list); | ||
} catch (e) { | ||
if (e.response) { | ||
console.log(e.response.status); | ||
console.log(e.response.data); | ||
} else { | ||
console.log("리퀘스트가 실패했습니다."); | ||
} | ||
} | ||
}; | ||
detailedComment(); | ||
detailedProduct(); | ||
}, [productId]); | ||
|
||
if (!product) { | ||
return <div>로딩중</div>; | ||
} | ||
|
||
return ( | ||
<> | ||
<ProductDetails product={product} /> | ||
<CommentDetails comments={comments} /> | ||
</> | ||
); | ||
} | ||
|
||
export default ProductDetailsContainer; |
This file contains 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,50 @@ | ||
import styles from "../ui/CommentDetails.module.css"; | ||
import backIcon from "../../assets/back-icon.png"; | ||
import { Link } from "react-router-dom"; | ||
import { elapsedTime } from "../../utils"; | ||
|
||
function CommentDetails({ comments }) { | ||
return ( | ||
<div className={styles.commentWrapper}> | ||
<div> | ||
<h2>문의하기</h2> | ||
<form> | ||
<input | ||
name="question" | ||
type="text" | ||
placeholder="개인정보를 공유 및 요청하거나, 명예 훼손, 무단 광고,불법 정보 유포시 모니터링 후 삭제될 수 있으며, 이에 대한 민형사상 책임은 게시자에게 있습니다." | ||
required | ||
autoComplete="off" | ||
/> | ||
<div className={styles.buttonWrapper}> | ||
<button className={styles.disabledButton} type="submit"> | ||
등록 | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
<div> | ||
{comments.map((comment) => ( | ||
<div key={comment.id} className={styles.comment}> | ||
<p className={styles.content}>{comment.content}</p> | ||
<div className={styles.contentWrapper}> | ||
<img src={comment.writer.image} alt="작성자 이미지" /> | ||
<div className={styles.commentContent}> | ||
<p className={styles.nickname}>{comment.writer.nickname}</p> | ||
<p className={styles.updatedAt}> | ||
{elapsedTime(comment.updatedAt)} | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
<Link to="/items" className={styles.goBackButton}> | ||
<span>목록으로 돌아가기</span> | ||
<img className={styles.backIcon} src={backIcon} alt="돌아가기 아이콘" /> | ||
</Link> | ||
</div> | ||
); | ||
} | ||
|
||
export default CommentDetails; |
This file contains 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,109 @@ | ||
.commentWrapper { | ||
border-top: 1px solid #e5e7eb; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
.commentWrapper h2 { | ||
font-weight: 600; | ||
line-height: 19.09px; | ||
margin-top: 24px; | ||
margin-bottom: 16px; | ||
} | ||
|
||
.commentWrapper input { | ||
border: none; | ||
outline: none; | ||
border-radius: 12px; | ||
padding: 16px 24px 16px 24px; | ||
width: 100%; | ||
min-height: 104px; | ||
background-color: #f3f4f6; | ||
} | ||
|
||
.buttonWrapper { | ||
text-align: right; | ||
margin-top: 16px; | ||
margin-bottom: 24px; | ||
} | ||
|
||
.disabledButton { | ||
background-color: #9ca3af; | ||
color: #ffffff; | ||
cursor: default; | ||
padding: 12px 20px 12px 20px; | ||
height: 42px; | ||
width: 88px; | ||
border-radius: 8px; | ||
font-weight: 600; | ||
line-height: 19.09px; | ||
} | ||
|
||
form:valid .disabledButton { | ||
background-color: #3692ff; | ||
cursor: pointer; | ||
} | ||
|
||
.content { | ||
line-height: 22.4px; | ||
margin-top: 24px; | ||
margin-bottom: 24px; | ||
} | ||
|
||
.contentWrapper { | ||
display: flex; | ||
border-bottom: 1px solid #e5e7eb; | ||
margin-bottom: 40px; | ||
} | ||
|
||
.comment img { | ||
width: 40px; | ||
height: 40px; | ||
} | ||
|
||
.commentContent { | ||
margin-left: 8px; | ||
margin-bottom: 5px; | ||
} | ||
|
||
.nickname { | ||
margin: 0; | ||
margin-bottom: 4px; | ||
font-size: 14px; | ||
line-height: 16.71px; | ||
color: #4b5563; | ||
} | ||
|
||
.updatedAt { | ||
font-size: 12px; | ||
line-height: 14.32px; | ||
margin: 0; | ||
margin-bottom: 29px; | ||
color: #9ca3af; | ||
} | ||
|
||
.goBackButton { | ||
width: 240px; | ||
height: 48px; | ||
border-radius: 40px; | ||
padding: 0; | ||
background-color: #3692ff; | ||
border: none; | ||
cursor: pointer; | ||
padding: 12px 71px 12px 71px; | ||
margin: 0 auto 250px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
text-wrap: nowrap; | ||
} | ||
|
||
.goBackButton span { | ||
color: #ffffff; | ||
font-weight: 600; | ||
font-size: 18px; | ||
line-height: 24px; | ||
} | ||
|
||
.backIcon { | ||
margin-left: 10px; | ||
} |
This file contains 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,28 @@ | ||
import styles from "../ui/ProductDetails.module.css"; | ||
import heartIcon from "../../assets/heart.png"; | ||
|
||
function ProductDetails({ product }) { | ||
return ( | ||
<div className={styles.productWrapper}> | ||
<img | ||
className={styles.productImg} | ||
src={product.images[0]} | ||
alt={product.name} | ||
/> | ||
<div className={styles.productContent}> | ||
<h2>{product.name}</h2> | ||
<h1>{product.price}원</h1> | ||
<p>상품 소개</p> | ||
<h3>{product.description}</h3> | ||
<p>상품 태그</p> | ||
<h3>#{product.tags}</h3> | ||
<button className={styles.favoriteTag}> | ||
<img src={heartIcon} alt="하트 아이콘" /> | ||
{product.favoriteCount} | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default ProductDetails; |
This file contains 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,127 @@ | ||
.productImg { | ||
width: 486px; | ||
height: 486px; | ||
margin-right: 24px; | ||
border-radius: 20px; | ||
} | ||
|
||
.productWrapper { | ||
max-width: 996px; | ||
display: flex; | ||
justify-content: space-between; | ||
padding-top: 24px; | ||
padding-bottom: 32px; | ||
margin: 0 auto; | ||
} | ||
|
||
.productContent { | ||
width: 486px; | ||
height: 486px; | ||
} | ||
|
||
.productContent h2 { | ||
font-weight: 600; | ||
font-size: 24px; | ||
line-height: 28.64px; | ||
color: #1f2937; | ||
margin: 0; | ||
} | ||
|
||
.productContent h1 { | ||
font-weight: 600; | ||
font-size: 40px; | ||
line-height: 47.73px; | ||
color: #1f2937; | ||
margin: 0; | ||
margin-top: 16px; | ||
padding-bottom: 16px; | ||
} | ||
|
||
.productContent p { | ||
font-weight: 500; | ||
font-size: 14px; | ||
line-height: 16.71px; | ||
color: #4b5563; | ||
margin-top: 16px; | ||
margin-bottom: 8px; | ||
} | ||
|
||
.productContent h3 { | ||
line-height: 22.4px; | ||
color: #1f2937; | ||
margin: 0; | ||
} | ||
|
||
.productContent h3 { | ||
margin-bottom: 24px; | ||
} | ||
|
||
.favoriteTag { | ||
width: 87px; | ||
height: 40px; | ||
border: 1px solid #e5e7eb; | ||
border-radius: 35px; | ||
padding: 4px 12px 4px 12px; | ||
margin-top: 124px; | ||
gap: 10px; | ||
display: flex; | ||
align-items: center; | ||
color: #6b7280; | ||
font-weight: 500; | ||
line-height: 19.09px; | ||
} | ||
|
||
/* Tablet size*/ | ||
@media screen and (max-width: 1199px) { | ||
.productContent h2 { | ||
font-size: 20px; | ||
line-height: 23.87px; | ||
} | ||
|
||
.productContent h1 { | ||
font-size: 32px; | ||
line-height: 38.19px; | ||
} | ||
|
||
.productContent p { | ||
line-height: 19.6px; | ||
} | ||
|
||
.productImg { | ||
width: 340px; | ||
height: 340px; | ||
} | ||
|
||
.favoriteTag { | ||
margin-top: 25px; | ||
} | ||
} | ||
/*Mobile size*/ | ||
@media screen and (max-width: 767px) { | ||
.productContent h2 { | ||
font-size: 16px; | ||
line-height: 19.09px; | ||
} | ||
|
||
.productContent h1 { | ||
font-size: 24px; | ||
line-height: 28.64px; | ||
} | ||
|
||
.productContent p { | ||
line-height: 16.71px; | ||
} | ||
|
||
.favoriteTag img { | ||
width: 24px; | ||
} | ||
|
||
.productImg { | ||
width: 343px; | ||
height: 343px; | ||
} | ||
|
||
.favoriteTag { | ||
margin-top: 25px; | ||
} | ||
} |
This file contains 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,7 @@ | ||
import ProductDetailsContainer from "../components/container/ProductDeatilsContainer"; | ||
|
||
function ProductDetailedPage() { | ||
return <ProductDetailsContainer />; | ||
} | ||
|
||
export default ProductDetailedPage; |
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.
[수정해주세요]
함수명은 동사를 사용해주세요!