-
Notifications
You must be signed in to change notification settings - Fork 1
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
너소서 폼 작성 부분 #87
Merged
Merged
너소서 폼 작성 부분 #87
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
685fd64
✨feat: 목 API 로직 작성, 첫 페이지 구현
SeojinSeojin 64c9ed9
Merge branch 'dev' into feat/#48
SeojinSeojin b036fbc
✨feat: 기획 제대로 이해 못한 부분 수정, 작성 첫페이지와 연결
SeojinSeojin 81a4812
✨feat: 폼 데이터에 유저이름이 들어가게 변경
SeojinSeojin 87d6b75
✨feat: 너소서 폼 두번째 페이지 만들기
SeojinSeojin 2e71f76
✨feat: 너소서 폼에서 키워드 연결하기
SeojinSeojin d14af5a
✨feat: 너소서 폼 작성 완료
SeojinSeojin b957cb0
✨feat: 너소서 폼 작성 - 서버 제대로 목킹하기
SeojinSeojin 104a78d
✨feat: 너소서 폼 마지막 화면 만들기
SeojinSeojin d667a47
:nail_care:style: 너소서 폼 헤더를 컴포넌트로 분리
SeojinSeojin 3405a76
✨feat: 오른쪽 이미지를 동그랗게 변경
SeojinSeojin 63e3675
✨feat: 너가소개서 작성 시 인풋이 모두 채워지지 않았을 경우 버튼 색 바꾸기
SeojinSeojin bb1a0ff
✨feat: 관계의 타입 중에 id 추가하기
SeojinSeojin 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
✨feat: 너소서 폼 작성 - 서버 제대로 목킹하기
- Loading branch information
commit b957cb08ecb7118c12b02f99e3c9f4c9410aa99e
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { NeososeoAnswerData, NeososeoFormData } from './types/neososeo-form'; | ||
|
||
export interface NeososeoFormService { | ||
getFormInfo(userID: number, formID: number): Promise<NeososeoFormData>; | ||
getFormInfo(userID: string, formID: string): Promise<NeososeoFormData>; | ||
postFormAnswer(body: NeososeoAnswerData): Promise<{ isSuccess: boolean }>; | ||
} |
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 |
---|---|---|
|
@@ -2,23 +2,29 @@ import { api } from '@api/index'; | |
import { Keyword } from '@api/types/user'; | ||
import CommonInput from '@components/common/CommonInput'; | ||
import ImmutableKeywordList from '@components/common/Keyword/ImmutableList'; | ||
import { neoseosoAnswerState, neososeoFormState } from '@stores/neososeo-form'; | ||
import { neososeoAnswerState, neososeoFormState } from '@stores/neososeo-form'; | ||
import { useEffect, useState } from 'react'; | ||
import { Link, Outlet, useNavigate } from 'react-router-dom'; | ||
import { useRecoilState, useRecoilValue } from 'recoil'; | ||
import { StButton, StNeososeoFormLayout, StNeososeoTitle, StSubTitle } from '../style'; | ||
import { StTextarea, StKeywordListWrapper } from './style'; | ||
|
||
function NeososeoFormAnswer() { | ||
const neososeoFormData = useRecoilValue(neososeoFormState); | ||
const [neososeoAnswerState, setNeososeoAnswerState] = useRecoilState(neoseosoAnswerState); | ||
const [keywordList, setKeywordList] = useState<Keyword[]>([]); | ||
const [neososeoAnswer, setNeososeoAnswer] = useRecoilState(neososeoAnswerState); | ||
const navigate = useNavigate(); | ||
|
||
const postNeososeoForm = async () => { | ||
const response = await api.neososeoFormService.postFormAnswer(neososeoAnswerState); | ||
const response = await api.neososeoFormService.postFormAnswer(neososeoAnswer); | ||
if (response.isSuccess) navigate('../finish'); | ||
}; | ||
|
||
const setAnswer = (answer: string) => setNeososeoAnswerState((prev) => ({ ...prev, answer })); | ||
const setAnswer = (answer: string) => setNeososeoAnswer((prev) => ({ ...prev, answer })); | ||
|
||
useEffect(() => { | ||
setNeososeoAnswer((prev) => ({ ...prev, keyword: keywordList.map((k) => k.id) })); | ||
}, [keywordList]); | ||
|
||
if (!neososeoFormData) return <></>; | ||
|
||
|
@@ -41,29 +47,24 @@ function NeososeoFormAnswer() { | |
/> | ||
</Link> | ||
<StKeywordListWrapper> | ||
<ImmutableKeywordList | ||
keywordList={neososeoAnswerState.keyword} | ||
onItemClick={() => null} | ||
/> | ||
<ImmutableKeywordList keywordList={keywordList} onItemClick={() => null} /> | ||
</StKeywordListWrapper> | ||
</div> | ||
<StButton onClick={postNeososeoForm}>답변 작성하기</StButton> | ||
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. 필수값이 빈값이면 버튼 disalbed하는거 넣어주는건 어떨까!! |
||
</StNeososeoFormLayout> | ||
<Outlet | ||
context={{ | ||
keywordList: neososeoAnswerState.keyword, | ||
keywordList: keywordList, | ||
addKeyword: (keyword: Keyword) => | ||
setNeososeoAnswerState((prev) => ({ | ||
...prev, | ||
keyword: prev.keyword.map((k) => k.content).includes(keyword.content) | ||
? prev.keyword | ||
: [...prev.keyword, keyword], | ||
})), | ||
setKeywordList((prev) => | ||
prev.map((prev) => prev.content).includes(keyword.content) | ||
? prev | ||
: [...prev, keyword], | ||
), | ||
removeKeyword: (targetKeyword: Keyword) => | ||
setNeososeoAnswerState((prev) => ({ | ||
...prev, | ||
keyword: prev.keyword.filter((keyword) => keyword.content !== targetKeyword.content), | ||
})), | ||
setKeywordList((prev) => | ||
prev.filter((keyword) => keyword.content !== targetKeyword.content), | ||
), | ||
targetUser: neososeoFormData.userID, | ||
}} | ||
/> | ||
|
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
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.
요건 무슨 코드이징?.? (진짜몰라서 물어보는거..)
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.
너소서 폼데이터를 API로 받아올 때 없으면 아무것도 안 렌더링되게 일단 해둔 것!!!