-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #213 from Injaeeee/React-정인재-Sprint7
[정인재] Sprint7
- Loading branch information
Showing
27 changed files
with
481 additions
and
79 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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 was deleted.
Oops, something went wrong.
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,52 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { getProducts } from '../../api'; | ||
import { Link, useNavigate } from 'react-router-dom'; | ||
import './BestProductList.css'; | ||
|
||
function BestProductListItem({ item }) { | ||
const navigate = useNavigate(); | ||
const handleAddItemClick = () => { | ||
navigate(`/items/${item.id}`); | ||
} | ||
|
||
return ( | ||
<button onClick={handleAddItemClick} className='BestProductListItem'> | ||
<img className="BestProductListItem-img" src={item.images} alt={item.name}></img> | ||
<p> {item.name}</p> | ||
<h3>{item.price}원</h3> | ||
<p>{item.favoriteCount}</p> | ||
</button> | ||
); | ||
|
||
} | ||
|
||
function BestProductList() { | ||
|
||
|
||
const [items, setItems] = useState([]); | ||
|
||
const handleLoad = async () => { | ||
const { list } = await getProducts({ order: 'favorite', page: 1, pageSize: 10 }); | ||
setItems(list); | ||
} | ||
|
||
|
||
useEffect(() => { | ||
handleLoad(); | ||
}, []); | ||
|
||
const displayedItems = items.slice(0, 4); | ||
return ( | ||
|
||
<div className='BestProductList'> | ||
{displayedItems.map((item) => { | ||
return ( | ||
<BestProductListItem key={item.id} item={item} /> | ||
|
||
); | ||
})} | ||
</div> | ||
) | ||
} | ||
|
||
export default BestProductList; |
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
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,43 @@ | ||
.commentWrapper { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 15px; | ||
border-bottom: 1px solid #e5e7eb; | ||
margin: 20px 0; | ||
} | ||
|
||
.commentImg { | ||
width: 40px; | ||
height: 40px; | ||
} | ||
|
||
.writerWrapper { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 8px; | ||
margin: 20px 0; | ||
} | ||
.writer { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 4px; | ||
} | ||
|
||
.commenContent { | ||
font-size: 16px; | ||
font-weight: 400; | ||
color: #1f2937; | ||
} | ||
|
||
.emptyComment { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
.emptyCommentText { | ||
font-size: 16px; | ||
font-weight: 400; | ||
line-height: 24px; | ||
color: #9ca3af; | ||
} |
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 { useEffect, useState } from 'react'; | ||
import { getComment } from '../../api'; | ||
import emptyComment from '../../img/Img_inquiry_empty.png' | ||
import './CommentList.css'; | ||
|
||
function CommentListItem({ item }) { | ||
|
||
|
||
return ( | ||
<div className='commentWrapper'> | ||
<span className='commentContent'> {item.content}</span> | ||
|
||
<div className='writerWraaper'> | ||
<img src={item.writer.image} className='commentImg'></img> | ||
<div className='writer'> | ||
<span className='writerNickname'>{item.writer.nickname}</span> | ||
<span className='updatedAt'>{item.updatedAt}</span> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
); | ||
|
||
} | ||
|
||
function CommentList({ productSlug }) { | ||
|
||
|
||
const [items, setItems] = useState([]); | ||
|
||
|
||
const handleLoad = async () => { | ||
const { list } = await getComment(productSlug); | ||
setItems(list); | ||
} | ||
|
||
useEffect(() => { | ||
handleLoad(); | ||
}, []); | ||
|
||
return ( | ||
|
||
<div> | ||
{items.length > 0 ? (items.map((item) => { | ||
return ( | ||
|
||
<CommentListItem key={item.id} item={item} /> | ||
); | ||
})) : (<div className='emptyComment'> | ||
<img src={emptyComment}></img> | ||
<span className='emptyCommentText'>아직 문의가 없습니다.</span> | ||
</div>)} | ||
</div> | ||
) | ||
} | ||
|
||
export default CommentList; |
File renamed without changes.
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
14 changes: 11 additions & 3 deletions
14
src/components/ProductList.js → src/components/ProductList/ProductList.js
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
File renamed without changes.
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,12 @@ | ||
.pageButton { | ||
width: 40px; | ||
height: 40px; | ||
border-radius: 40px; | ||
background-color: #ffffff; | ||
border: #e5e7eb 1px solid; | ||
} | ||
|
||
.active { | ||
background-color: #3692ff; | ||
color: #ffffff; | ||
} |
Oops, something went wrong.