-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactor/detail/add review #14
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
826ce07
feat: set dummy data and type of Review
seohyun319 bc53580
feat: make reviewList - ReviewSort
seohyun319 87ef2a4
feat: make ReviewInput
seohyun319 669e6de
feat: change radio button and design
seohyun319 10cbcf7
feat: set rate view (index, ReviewInput)
seohyun319 a39e6ea
feat: change reviewList to reviewContainer
seohyun319 8787501
Merge branch 'refactor/detail/add-review' of github.com-seohyun319:co…
seohyun319 daa1fe6
feat: set ReviewList
seohyun319 cd87c83
feat: set rate precision, change design
seohyun319 bac4c43
build: set compiler on next.config.js
seohyun319 c96ce8b
Merge branch 'main' into refactor/detail/add-review
seohyun319 4ba228b
chore: set key on list
seohyun319 40dfc7d
refactor: set type on state
seohyun319 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import styled from '@emotion/styled' | ||
import { useState } from 'react' | ||
import { reviewAverageCount } from '../../data' | ||
import Text from '../common/Text' | ||
import ReviewInput from './ReviewInput' | ||
import ReviewList from './ReviewList' | ||
|
||
// TODO: set location id | ||
const ReviewContainer = () => { | ||
const [sort, setSort] = useState('recommended') | ||
|
||
return ( | ||
<> | ||
<ReviewContainerHeader> | ||
<Text size={1.2} bold> | ||
{reviewAverageCount.count} 개의 리뷰 | ||
</Text> | ||
<ReviewSortContainer> | ||
<SelectSort | ||
sort={sort} | ||
name={'recommended'} | ||
onClick={() => setSort('recommended')} | ||
> | ||
추천순 | ||
</SelectSort> | ||
<SelectSort | ||
sort={sort} | ||
name={'createdAt'} | ||
onClick={() => setSort('createdAt')} | ||
> | ||
최신순 | ||
</SelectSort> | ||
</ReviewSortContainer> | ||
</ReviewContainerHeader> | ||
<ReviewInput /> | ||
<ReviewList /> | ||
</> | ||
) | ||
} | ||
|
||
const ReviewContainerHeader = styled.header` | ||
display: flex; | ||
justify-content: space-around; | ||
align-items: flex-end; | ||
flex-direction: row; | ||
` | ||
const SelectSort = styled.div<{ sort: string; name: string }>` | ||
font-weight: ${({ sort, name }) => (sort === name ? 'bold' : 'normal')}; | ||
padding: 0 0.5rem; | ||
cursor: pointer; | ||
` | ||
const ReviewSortContainer = styled.div` | ||
display: flex; | ||
${SelectSort}:first-of-type { | ||
border-right: 1px solid black; | ||
} | ||
` | ||
|
||
export default ReviewContainer |
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,112 @@ | ||
import styled from '@emotion/styled' | ||
import React, { useState, useEffect } from 'react' | ||
import Text, { StyledText } from '../common/Text' | ||
|
||
import Radio from '@mui/material/Radio' | ||
import RadioGroup from '@mui/material/RadioGroup' | ||
import FormControlLabel from '@mui/material/FormControlLabel' | ||
import FormControl from '@mui/material/FormControl' | ||
import Rating from '@mui/material/Rating' | ||
|
||
const ReviewInput = () => { | ||
const [userType, setUserType] = useState('anonymous') | ||
const [inputValue, setInputValue] = useState('') | ||
const [rate, setRate] = useState<number | null>(0) | ||
|
||
return ( | ||
<ReviewInputContainer> | ||
<ReviewInputHeader> | ||
<UserInfo> | ||
<Text>평점</Text> | ||
<Rating | ||
value={rate} | ||
precision={0.5} | ||
onChange={(_, newRate) => { | ||
setRate(newRate) | ||
}} | ||
/> | ||
</UserInfo> | ||
<FormControl> | ||
<RadioGroup | ||
row | ||
value={userType} | ||
onChange={(e) => setUserType(e.target.value)} | ||
> | ||
<FormControlLabel | ||
value="disabled" | ||
control={<Radio size="small" />} | ||
label="장애인" | ||
/> | ||
<FormControlLabel | ||
value="able" | ||
control={<Radio size="small" />} | ||
label="비장애인" | ||
/> | ||
<FormControlLabel | ||
value="anonymous" | ||
control={<Radio size="small" />} | ||
label="익명" | ||
/> | ||
</RadioGroup> | ||
</FormControl> | ||
</ReviewInputHeader> | ||
|
||
<ReviewInputArea | ||
onChange={(e) => setInputValue(e.target.value)} | ||
placeholder="리뷰는 익명으로 등록됩니다." | ||
value={inputValue} | ||
/> | ||
<ReviewInputButton | ||
onClick={() => { | ||
// postReview(userType, locationId, inputValue, rating) | ||
setInputValue('') | ||
setRate(0) | ||
}} | ||
> | ||
등록 | ||
</ReviewInputButton> | ||
</ReviewInputContainer> | ||
) | ||
} | ||
|
||
const ReviewInputContainer = styled.section` | ||
display: flex; | ||
flex-direction: column; | ||
margin-top: 1rem; | ||
` | ||
const ReviewInputHeader = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-around; | ||
align-items: center; | ||
` | ||
const UserInfo = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
${StyledText} { | ||
margin-right: 0.2rem; | ||
} | ||
` | ||
const ReviewInputArea = styled.textarea` | ||
border: 2px solid #9d9d9d; | ||
border-radius: 10px; | ||
font-size: 1rem; | ||
min-height: 5rem; | ||
padding: 0.3rem; | ||
margin-top: 0.4rem; | ||
resize: none; | ||
` | ||
const ReviewInputButton = styled.button` | ||
display: flex; | ||
background-color: #e599b3; | ||
color: white; | ||
font-size: 0.9rem; | ||
margin-top: 0.6rem; | ||
padding: 0.4rem; | ||
justify-content: center; | ||
align-items: center; | ||
border-radius: 5px; | ||
` | ||
|
||
export default ReviewInput |
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,112 @@ | ||
import styled from '@emotion/styled' | ||
import Image from 'next/image' | ||
import { reviews } from '../../data' | ||
import Text, { StyledText } from '../common/Text' | ||
|
||
import Rating from '@mui/material/Rating' | ||
|
||
const ReviewList = () => { | ||
return ( | ||
<ReviewListContainer> | ||
{reviews?.data?.map((review) => ( | ||
<ReviewContainer key={review._id}> | ||
<ReviewInfoWrapper> | ||
<ReviewStarUserTypeWrapper> | ||
<Rating | ||
value={review.star} | ||
precision={0.5} | ||
size="small" | ||
readOnly | ||
/> | ||
<Text color="#f0a044" size={0.9}> | ||
{review.userType} | ||
</Text> | ||
</ReviewStarUserTypeWrapper> | ||
<Text color="#9d9d9d" size={0.7}> | ||
{review.createdAt.substring(0, 10)} | ||
</Text> | ||
</ReviewInfoWrapper> | ||
<ReviewText>{review.detail}</ReviewText> | ||
<HelpButtonWrapper> | ||
<HelpButton | ||
// onClick={() => { | ||
// postReviewRecommend(review._id) | ||
// }} | ||
> | ||
<Image | ||
src={'/images/thumbs_up.svg'} | ||
width={15} | ||
height={15} | ||
></Image> | ||
<ButtonDescriptionText>도움이 돼요</ButtonDescriptionText> | ||
<Text color="#cb3267" size={1} bold> | ||
{review.good} | ||
</Text> | ||
</HelpButton> | ||
<HelpButton | ||
// onClick={() => postReviewDiscourage(review._id)} | ||
> | ||
<Image | ||
src={'/images/thumbs_down.svg'} | ||
width={15} | ||
height={15} | ||
></Image> | ||
<ButtonDescriptionText>도움이 안 돼요</ButtonDescriptionText> | ||
<Text color="#cb3267" size={1} bold> | ||
{review.bad} | ||
</Text> | ||
</HelpButton> | ||
</HelpButtonWrapper> | ||
</ReviewContainer> | ||
))} | ||
</ReviewListContainer> | ||
) | ||
} | ||
|
||
const ReviewListContainer = styled.section`` | ||
const ReviewContainer = styled.div` | ||
margin-top: 1rem; | ||
padding-bottom: 1rem; | ||
border-bottom: #9d9d9d; | ||
border-bottom-width: 0.08rem; | ||
border-bottom-style: solid; | ||
` | ||
const ReviewInfoWrapper = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
` | ||
const ReviewStarUserTypeWrapper = styled.div` | ||
display: flex; | ||
align-items: center; | ||
${StyledText} { | ||
margin-left: 0.4rem; | ||
} | ||
` | ||
const ReviewText = styled.p` | ||
font-size: 1rem; | ||
align-items: center; | ||
margin-left: 0.5rem; | ||
margin-top: 0.5rem; | ||
` | ||
const HelpButtonWrapper = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
` | ||
const HelpButton = styled.button` | ||
display: flex; | ||
font-weight: bold; | ||
font-size: 0.8rem; | ||
height: 1.7rem; | ||
align-items: center; | ||
border: 1px solid #f0a044; | ||
border-radius: 10px; | ||
background-color: #ffffff; | ||
padding-left: 1rem; | ||
padding-right: 1rem; | ||
` | ||
const ButtonDescriptionText = styled.p` | ||
margin: 0 0.5rem 0 0.2rem; | ||
` | ||
|
||
export default ReviewList |
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
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.
state들 다 타입 지정(inputValue - string 등)하는게 좋을거같고 userType이나 Sort는 enum으로 타입 처리 하면 좋을거같아요!