-
Notifications
You must be signed in to change notification settings - Fork 21
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
[NEXTLEVEL 클린코드 리액트 호준] 장바구니 미션 Step1 #7
Open
ganeodolu
wants to merge
20
commits into
nextlevel-2022:ganeodolu
Choose a base branch
from
ganeodolu:ganeodolu
base: ganeodolu
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
2d00bb6
build: 환경설정
ganeodolu 0d31c6f
fix: 파일명 수정
ganeodolu 57f112b
style: css 추가
ganeodolu f71e105
feat: 리액트 쿼리 추가
ganeodolu c6608c5
feat: 상품관련 api 추가
ganeodolu 955bbc7
feat: 라우터 설정
ganeodolu 3fc75b4
style: global style 추가
ganeodolu 6f70fbf
build: 웹팩 async, svg 설정 추가
ganeodolu 35931a6
feat: 상품목록 페이지 추가
ganeodolu bbca140
feat: 장바구니 페이지 추가
ganeodolu f9965d5
feat: 주문목록 페이지 추가
ganeodolu 411aec7
style: 기존 스타일 파일 삭제
ganeodolu c027b53
feat: 리덕스 설정 및 카트수량 모듈 추가
ganeodolu 7891113
feat: 리덕스 연결, 카트 - 화살표로 수량 변경
ganeodolu be4ad0f
feat: 장바구니 수량 범위 제한
ganeodolu 50e6815
feat: 장바구니 결제예상금액 반영
ganeodolu 00a5b7d
feat: 장바구니 모두선택 토글기능 추가
ganeodolu 26ec755
feat: nodemon 추가
ganeodolu 021b1ba
feat: 장바구니 삭제 기능 추가
ganeodolu 2aa2977
feat: 장바구니 선택삭제 기능 추가
ganeodolu 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,109 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
import CartSvg from '../../assets/svgs/cart.svg'; | ||
|
||
const ProductListBlock = styled.div` | ||
.product-container { | ||
display: flex; | ||
justify-content: center; | ||
|
||
flex-wrap: wrap; | ||
gap: 20px; | ||
padding: 50px 240px; | ||
|
||
display: grid; | ||
gap: 20px 20px; | ||
grid-template-columns: repeat(4, 1fr); | ||
} | ||
|
||
@media screen and (max-width: 768px) { | ||
.product-container { | ||
grid-template-columns: repeat(3, 1fr); | ||
} | ||
} | ||
|
||
@media screen and (max-width: 480px) { | ||
.product-container { | ||
grid-template-columns: repeat(2, 1fr); | ||
} | ||
} | ||
|
||
.product-info { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.product-info__name { | ||
font-size: 12px; | ||
} | ||
|
||
.product-info__price { | ||
} | ||
|
||
.product-detail-container { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
|
||
margin-top: 50px; | ||
} | ||
|
||
.product-detail-info { | ||
width: 100%; | ||
} | ||
|
||
.product-detail-info__name { | ||
font-size: 24px; | ||
} | ||
|
||
.product-detail-info__price { | ||
font-size: 24px; | ||
} | ||
|
||
.product-detail-button { | ||
width: 100%; | ||
padding: 24px; | ||
background: #73675c; | ||
font-size: 24px; | ||
color: white; | ||
} | ||
`; | ||
|
||
const ProductItem = ({ product: { id, name, price, imageUrl } }) => { | ||
return ( | ||
<div data-id={id}> | ||
<img src={imageUrl} alt={name} /> | ||
<div className="flex justify-between p-5"> | ||
<div className="product-info"> | ||
<span className="product-info__name">{name}</span> | ||
<span className="product-info__price">{price.toLocaleString()}원</span> | ||
</div> | ||
<img src={CartSvg} alt="장바구니" /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
const ProductList = ({ isError, isLoading, data, error }) => { | ||
if (isLoading) { | ||
return <span>Loading...</span>; | ||
} | ||
|
||
if (isError) { | ||
return <span>Error: {error.message}</span>; | ||
} | ||
|
||
return ( | ||
<ProductListBlock> | ||
<div> | ||
<section className="product-container"> | ||
{data.map((product, idx) => { | ||
return <ProductItem key={idx} product={product} />; | ||
})} | ||
</section> | ||
</div> | ||
</ProductListBlock> | ||
); | ||
}; | ||
|
||
export default ProductList; |
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,15 @@ | ||
import React from 'react' | ||
import ProductList from '../../components/product/ProductList'; | ||
import apiHandler from '../../lib/api/main'; | ||
import { useQuery } from 'react-query'; | ||
|
||
const ProductListContainer = () => { | ||
const { isLoading, isError, data, error } = useQuery(["products"], () => apiHandler.getProducts()); | ||
return ( | ||
<div> | ||
<ProductList isLoading={isLoading} isError={isError} data={data} error={error} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default ProductListContainer |
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
4 changes: 2 additions & 2 deletions
4
client/src/pages/Cart.jsx → client/src/pages/CartListPage.jsx
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import React from 'react' | ||
|
||
const Cart = () => { | ||
const CartListPage = () => { | ||
return ( | ||
<div> | ||
|
||
</div> | ||
) | ||
} | ||
|
||
export default Cart | ||
export default CartListPage |
4 changes: 2 additions & 2 deletions
4
client/src/pages/OrderList.jsx → client/src/pages/OrderListPage.jsx
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import React from 'react' | ||
|
||
const OrderList = () => { | ||
const OrderListPage = () => { | ||
return ( | ||
<div> | ||
|
||
</div> | ||
) | ||
} | ||
|
||
export default OrderList | ||
export default OrderListPage |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react' | ||
import ProductListContainer from '../containers/product/ProductListContainer'; | ||
|
||
const ProductListPage = () => { | ||
return ( | ||
<div> | ||
<ProductListContainer /> | ||
</div> | ||
); | ||
} | ||
|
||
export default ProductListPage |
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
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.
반응형을 grid로 구현하셨네요. 저도 grid로 구현했는데,
처음에 배민상회 페이지에서 개발자도구로 봤을 때
상품을 4개씩 끊어서 받아와서 구현했더라고요. 그래서 저도 처음엔 그렇게 받아오는 방법을 고민했었는데, 너무 복잡하고
grid가 훨씬 간편해서 grid로 그냥 구현하긴 했는데,
다른 방식 생각해보신 것 있으신가요?
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.
말씀하신 것처럼 열, 행으로 구현은 grid가 제일 편한 것 같습니다. 다른 방식이라면 flex-wrap으로도 구현이 되지 않을까 생각해봅니당. 그리고 조사하신 배민방식은 페이지처럼 한페이지에 4개씩 백엔드에서 제공하는 것일까요??
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.
배민페이지 방식에 확실히는 모르겠습니다. 6개씩 한 줄로 나오는 방식이긴 한데 반응형은 아니였습니다.
그래서 그냥 프론트에서도 받은 전체 상품을 6개씩 나눠도 할 수는 있을 것 같다고 생각했습니다.