-
Notifications
You must be signed in to change notification settings - Fork 2
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
[FE] 회고 페이지 구현 #828
Open
dle234
wants to merge
9
commits into
FE/dev
Choose a base branch
from
FE/feature/#806
base: FE/dev
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
[FE] 회고 페이지 구현 #828
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
49706f2
✨ Retrospect 페이지 생성 및 경로 추가
dle234 f49aa08
✨ 회고 답변 추가 api 요청 구현
dle234 c02c778
✨ Retrospect 공통 Content 구현
dle234 c3906ea
✨ 회고 질문 UI 컴포넌트 구현
dle234 ffc8d33
✨ 회고 헤더 구현
dle234 0df426d
✨ RetrospectView 컴포넌트 구현 및 회고 답변 get api 요청 구현
dle234 3ea627a
✨ RetrospectForm 구현
dle234 56e511f
♻️ 주석 삭제
dle234 96e08e7
♻️ RetrospectContent 에 UI 만 전달할 수 있도록 수정
dle234 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,37 @@ | ||
import fetcher from '@/apis/fetcher'; | ||
|
||
import { ERROR_MESSAGES } from '@/constants/message'; | ||
const API_URL = process.env.REACT_APP_API_URL; | ||
|
||
interface AddRetrospectRequest { | ||
pairRoomAccessCode: string; | ||
answers: string[]; | ||
} | ||
|
||
export const addRetrospect = async ({ pairRoomAccessCode, answers }: AddRetrospectRequest) => { | ||
const response = await fetcher.post({ | ||
url: `${API_URL}/retrospect`, | ||
body: JSON.stringify({ pairRoomAccessCode, answers }), | ||
errorMessage: ERROR_MESSAGES.ADD_RETROSPECT, | ||
}); | ||
|
||
return await response.json(); | ||
}; | ||
|
||
interface GetRetrospectRequest { | ||
retrospectId: string; | ||
} | ||
|
||
interface GetRetrospectResponse { | ||
pairRoomAccessCode: string; | ||
answer: string[]; | ||
} | ||
|
||
export const getRetrospectAnswer = async ({ retrospectId }: GetRetrospectRequest): Promise<GetRetrospectResponse> => { | ||
const response = await fetcher.get({ | ||
url: `${API_URL}/retrospect/${retrospectId}`, | ||
errorMessage: ERROR_MESSAGES.GET_RETROSPECT, | ||
}); | ||
|
||
return await response.json(); | ||
}; |
12 changes: 12 additions & 0 deletions
12
frontend/src/components/Retrospect/RetrospectContent/Question/Question.styles.ts
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 styled from 'styled-components'; | ||
|
||
export const Container = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 2.5rem; | ||
`; | ||
|
||
export const Label = styled.label` | ||
color: ${({ theme }) => theme.color.primary[700]}; | ||
font-size: ${({ theme }) => theme.fontSize.lg}; | ||
`; |
18 changes: 18 additions & 0 deletions
18
frontend/src/components/Retrospect/RetrospectContent/Question/Question.tsx
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,18 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
import * as S from './Question.styles'; | ||
|
||
interface QuestionProps { | ||
id: string; | ||
question: string; | ||
children: ReactNode; | ||
} | ||
|
||
const Question = ({ id, question, children }: QuestionProps) => ( | ||
<S.Container> | ||
<S.Label htmlFor={id}>{question}</S.Label> | ||
{children} | ||
</S.Container> | ||
); | ||
|
||
export default Question; |
20 changes: 20 additions & 0 deletions
20
frontend/src/components/Retrospect/RetrospectContent/RetrospectContent.tsx
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,20 @@ | ||
import { RetrospectQuestion } from '@/components/Retrospect/retrospect.type'; | ||
import Question from '@/components/Retrospect/RetrospectContent/Question/Question'; | ||
|
||
interface RetrospectContentProps { | ||
questions: RetrospectQuestion[]; | ||
renderAnswer: (index: number, id: string) => React.ReactNode; | ||
} | ||
const RetrospectContent = ({ questions, renderAnswer }: RetrospectContentProps) => { | ||
return ( | ||
<> | ||
{questions.map((question, index) => ( | ||
<Question key={question.id} id={question.id} question={question.value}> | ||
{renderAnswer(index, question.id)} | ||
</Question> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
export default RetrospectContent; |
64 changes: 64 additions & 0 deletions
64
frontend/src/components/Retrospect/RetrospectForm/RetrospectForm.styles.ts
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,64 @@ | ||
import styled, { css } from 'styled-components'; | ||
|
||
export const LayoutForm = styled.form` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 4rem; | ||
|
||
width: 100%; | ||
`; | ||
|
||
const positionFixed = css` | ||
position: fixed; | ||
bottom: 0; | ||
left: 50%; | ||
|
||
transform: translate(-50%); | ||
`; | ||
|
||
export const SubmitButton = css` | ||
${positionFixed} | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
width: 60%; | ||
min-width: 76.8rem; | ||
height: 6rem; | ||
border-radius: 0; | ||
|
||
&:active { | ||
${positionFixed} | ||
} | ||
|
||
&:hover { | ||
${positionFixed} | ||
} | ||
|
||
@media (max-width: ${({ theme }) => theme.deviceWidth.mobile}) { | ||
width: 100%; | ||
} | ||
`; | ||
|
||
export const Textarea = styled.textarea` | ||
width: 100%; | ||
min-height: 20rem; | ||
max-height: 35rem; | ||
padding: 2rem; | ||
border: 1px solid #d9d9d9; | ||
border-radius: 1rem; | ||
|
||
background-color: #fdfdfd; | ||
font-size: ${({ theme }) => theme.fontSize.md}; | ||
resize: vertical; | ||
|
||
&:focus { | ||
border: 1.5px solid ${({ theme }) => theme.color.primary[600]}; | ||
|
||
background-color: ${({ theme }) => theme.color.primary[100]}; | ||
} | ||
|
||
&::placeholder { | ||
color: ${({ theme }) => theme.color.black[50]}; | ||
} | ||
`; |
41 changes: 41 additions & 0 deletions
41
frontend/src/components/Retrospect/RetrospectForm/RetrospectForm.tsx
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,41 @@ | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
import Button from '@/components/common/Button/Button'; | ||
import RetrospectContent from '@/components/Retrospect/RetrospectContent/RetrospectContent'; | ||
import RetrospectHeader from '@/components/Retrospect/RetrospectHeader/RetrospectHeader'; | ||
|
||
import useInputAnswer from '@/hooks/Retrospect/const useInputAnswer'; | ||
|
||
import { RETROSPECT_QUESTIONS } from '@/constants/retrospect'; | ||
|
||
import * as S from './RetrospectForm.styles'; | ||
|
||
const RetrospectForm = () => { | ||
const location = useLocation(); | ||
const pairRoomAccessCode = location.state.accessCode; | ||
|
||
const { answers, handleChange, hasEmptyField, handleSubmit } = useInputAnswer(pairRoomAccessCode); | ||
|
||
const renderAnswer = (index: number, id: string) => ( | ||
<S.Textarea | ||
placeholder="질문에 대한 답변을 작성해주세요." | ||
id={id} | ||
value={answers[index]} | ||
onChange={(event) => handleChange(index, event.target.value)} | ||
/> | ||
); | ||
Comment on lines
+19
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 컴포넌트로 분리해주세요 🥲 |
||
|
||
return ( | ||
<> | ||
<RetrospectHeader readOnly={false} accessCode={pairRoomAccessCode} /> | ||
<S.LayoutForm onSubmit={handleSubmit}> | ||
<RetrospectContent questions={RETROSPECT_QUESTIONS} renderAnswer={renderAnswer} /> | ||
<Button disabled={hasEmptyField()} type="submit" css={S.SubmitButton}> | ||
작성 완료 | ||
</Button> | ||
</S.LayoutForm> | ||
</> | ||
); | ||
}; | ||
|
||
export default RetrospectForm; |
23 changes: 23 additions & 0 deletions
23
frontend/src/components/Retrospect/RetrospectHeader/Header/Header.styles.ts
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,23 @@ | ||
import styled, { css } from 'styled-components'; | ||
|
||
export const Layout = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
`; | ||
export const Title = styled.p` | ||
color: ${({ theme }) => theme.color.primary[800]}; | ||
font-size: ${({ theme }) => theme.fontSize.h6}; | ||
`; | ||
|
||
export const ButtonStyle = css` | ||
width: 10rem; | ||
border-color: ${({ theme }) => theme.color.primary[700]}; | ||
|
||
color: ${({ theme }) => theme.color.primary[700]}; | ||
|
||
&:hover { | ||
border-color: ${({ theme }) => theme.color.primary[800]}; | ||
|
||
color: ${({ theme }) => theme.color.primary[800]}; | ||
} | ||
`; |
22 changes: 22 additions & 0 deletions
22
frontend/src/components/Retrospect/RetrospectHeader/Header/Header.tsx
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,22 @@ | ||
import Button from '@/components/common/Button/Button'; | ||
|
||
import * as S from './Header.styles'; | ||
|
||
interface HeaderProps { | ||
title: string; | ||
buttonText: string; | ||
onButtonClick: () => void; | ||
} | ||
|
||
const Header = ({ title, buttonText, onButtonClick }: HeaderProps) => { | ||
return ( | ||
<S.Layout> | ||
<S.Title>{title}</S.Title> | ||
<Button onClick={onButtonClick} filled={false} rounded={true} size="sm" color="primary" css={S.ButtonStyle}> | ||
{buttonText} | ||
</Button> | ||
</S.Layout> | ||
); | ||
}; | ||
|
||
export default Header; |
35 changes: 35 additions & 0 deletions
35
frontend/src/components/Retrospect/RetrospectHeader/RetrospectHeader.tsx
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,35 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import Header from '@/components/Retrospect/RetrospectHeader/Header/Header'; | ||
|
||
interface RetrospectHeaderProps { | ||
readOnly: boolean; | ||
accessCode: string; | ||
} | ||
|
||
const RetrospectHeader = ({ readOnly, accessCode }: RetrospectHeaderProps) => { | ||
const navigate = useNavigate(); | ||
const getHeaderProps = (isReadOnly: boolean) => { | ||
if (isReadOnly) | ||
return { | ||
title: '"방제목" 에서의 회고입니다!', | ||
buttonText: '페어룸으로 이동', | ||
onButtonClick: () => { | ||
navigate(`/room/${accessCode}`); | ||
}, | ||
}; | ||
else | ||
return { | ||
title: '회고 작성하기', | ||
buttonText: '나중에 작성하기', | ||
onButtonClick: () => { | ||
alert('나중에 작성하시겠습니까?'); | ||
Comment on lines
+19
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alert 대신 간단한 모달은 어떤가요? |
||
navigate(`/room/${accessCode}`); | ||
}, | ||
}; | ||
}; | ||
|
||
return <Header {...getHeaderProps(readOnly)} />; | ||
}; | ||
|
||
export default RetrospectHeader; |
16 changes: 16 additions & 0 deletions
16
frontend/src/components/Retrospect/RetrospectView/RetrospectView.styles.ts
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,16 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Text = styled.pre` | ||
overflow-y: auto; | ||
|
||
width: 100%; | ||
min-height: 10rem; | ||
max-height: 35rem; | ||
margin: 0; | ||
|
||
font-size: ${({ theme }) => theme.fontSize.md}; | ||
font-weight: 300; | ||
white-space: pre-wrap; | ||
font-family: 'Pretendard Variable', sans-serif !important; | ||
word-wrap: break-word; | ||
`; |
27 changes: 27 additions & 0 deletions
27
frontend/src/components/Retrospect/RetrospectView/RetrospectView.tsx
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,27 @@ | ||
import { useParams } from 'react-router-dom'; | ||
|
||
import RetrospectContent from '@/components/Retrospect/RetrospectContent/RetrospectContent'; | ||
import RetrospectHeader from '@/components/Retrospect/RetrospectHeader/RetrospectHeader'; | ||
|
||
import { useGetRetrospectAnswer } from '@/queries/Retrospect/useGetRetrospectAnswer'; | ||
|
||
import { RETROSPECT_QUESTIONS } from '@/constants/retrospect'; | ||
|
||
import * as S from './RetrospectView.styles'; | ||
|
||
const RetrospectView = () => { | ||
const params = useParams(); | ||
const retrospectId = params.retrospectId || ''; | ||
const { pairRoomAccessCode, answer } = useGetRetrospectAnswer(retrospectId); | ||
|
||
const renderAnswer = (index: number) => <S.Text>{answer[index]}</S.Text>; | ||
|
||
return ( | ||
<> | ||
<RetrospectHeader readOnly={true} accessCode={pairRoomAccessCode} /> | ||
<RetrospectContent questions={RETROSPECT_QUESTIONS} renderAnswer={renderAnswer} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default RetrospectView; |
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,4 @@ | ||
export interface RetrospectQuestion { | ||
value: string; | ||
id: string; | ||
} |
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,7 @@ | ||
export const RETROSPECT_QUESTIONS = [ | ||
{ value: '1.이번 페어프로그래밍을 통해 어쩌구', id: '1' }, | ||
{ value: '2.이번 페어프로그래밍을 통해 어쩌구', id: '2' }, | ||
{ value: '3.이번 페어프로그래밍을 통해 어쩌구', id: '3' }, | ||
{ value: '4.이번 페어프로그래밍을 통해 어쩌구', id: '4' }, | ||
{ value: '5.이번 페어프로그래밍을 통해 어쩌구', id: '5' }, | ||
]; |
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.
저희 회고 한번 하면 수정 못하나요...?