-
Notifications
You must be signed in to change notification settings - Fork 5
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
디스커션 제출 페이지 구현 (issue #432) #475
Conversation
bb7d78a
to
11b9fca
Compare
- Hash 네이밍 제거 - 외부에서 tags 타입 주입받도록 변경 - 다중 선택 가능한 TagMultipleList 추가
- variant 추가 - TagMultipleList 경로를 components/common 으로 이동
- string 타입에서 객체 타입으로 변경 - TagList 컴포넌트의 클릭이벤트 수정 - 디스커션 제출 페이지 태그 디자인 수정
11b9fca
to
c46cbec
Compare
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.
전반적으로 잘 짜주신 것 같아 몇가지 사소한 코멘트만 남겨보았습니다 ㅎㅎ 반영하실 부분만 선택적으로 반영하고 다시 요청주시면 머지해드릴게요!
frontend/src/apis/discussionAPI.ts
Outdated
import { PATH } from './paths'; | ||
|
||
export const getDiscussions = async (mission = 'all', hashTag = 'all'): Promise<Discussion[]> => { | ||
const { data } = await develupAPIClient.get<{ data: Discussion[] }>(`${PATH.discussions}`, { |
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.
const { data } = await develupAPIClient.get<{ data: Discussion[] }>(`${PATH.discussions}`, { | |
const { data } = await develupAPIClient.get<{ data: Discussion[] }>(PATH.discussions, { |
frontend/src/apis/discussionAPI.ts
Outdated
hashTagIds: number[]; | ||
}): Promise<Discussion> => { | ||
const { data } = await develupAPIClient.post<{ data: Discussion }>( | ||
`${PATH.submitDiscussion}`, |
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.
`${PATH.submitDiscussion}`, | |
PATH.submitDiscussion, |
width="xlarge" | ||
danger={danger} | ||
dangerMessage={ERROR_MESSAGE.invalid_title} | ||
placeholder={'글 제목을 입력해주세요'} |
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.
placeholder={'글 제목을 입력해주세요'} | |
placeholder='글 제목을 입력해주세요' |
const { data: allHashTags } = useHashTags(); | ||
const { data: allMissions } = useMissions(); | ||
const [selectedHashTags, setSelectedHashTags] = useState<HashTag[]>([]); | ||
const [selectedMissions, setSelectedMissions] = useState({ id: 0, title: '' }); |
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.
초기값으로 { id: 0, title: ''}을 넣어주신 의도가 궁금합니다~!
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.
이름에 s가 붙어있는데 복수 형태가 아닌 것 같습니다! 혹시 다른 의도가 있으실까요?
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.
오 확인해주셔서 감사해요!! 초깃값으로 id: 0을 넣은 이유는 미션 번호가 1부터 시작되어 0이라는 값이 없기도 하고, id값이 1 이상인 경우만 optional하게 post api의 payload로 서버에 전송할 수 있도록 하기 위함입니다!
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.
라이언이 구두로 말씀해주셨던 것처럼 선택된 값이 없을 때 null
로 할당되는 것이 더 적합할 것 같아 커밋에 추가했습니다~!
queryFn: postDiscussionSubmit, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: ['all'] }); // TODO: all, 필터링까지 캐시 무효화 잘 되는지 확인 필요 @프룬 | ||
navigate(`${ROUTES.discussions}`); |
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.
navigate(`${ROUTES.discussions}`); | |
navigate(ROUTES.discussions); |
frontend/src/index.tsx
Outdated
@@ -189,6 +190,16 @@ const routes = [ | |||
</App> | |||
), | |||
}, | |||
{ | |||
path: `${ROUTES.submitDiscussion}`, |
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.
path: `${ROUTES.submitDiscussion}`, | |
path: ROUTES.submitDiscussion, |
key={tag.id} | ||
isSelected={isSelected} | ||
onClick={() => | ||
setSelectedTag(isSelected ? ({ id: 0, [keyName]: HASHTAGS.all } as T) : tag) |
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.
{ id: 0, [keyName]: HASHTAGS.all }
<--요 객체가 어떤 의미인지 여기 코드만 보고는 이해가 잘 되지 않을 수 있을 것 같아요! 전체 선택하는 방법을 { id: 0, [keyName]: HASHTAGS.all }
로 설정하는 방식이 아닌 다른 방식(ex. 비어있을 때는 전체 선택으로 간주)으로 바꿔도 좋을 것 같아요! 혹은 props로 setSelectedTag 대신 toggleSelectedTag와 같은 함수를 받아도 좋을 것 같아요 ㅎㅎ
1안
setSelectedTag(isSelected ? ({ id: 0, [keyName]: HASHTAGS.all } as T) : tag) | |
setSelectedTag(isSelected ? null : tag) |
2안
setSelectedTag(isSelected ? ({ id: 0, [keyName]: HASHTAGS.all } as T) : tag) | |
toggleSelectedTag(); |
frontend/src/types/index.ts
Outdated
title: string; | ||
mission: string; | ||
hashTags: HashTag[]; | ||
member: Omit<UserInfo, 'description'>; |
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.
역시 프룬 디테일하시군요 ㅎㅎ 짱입니다 👍🏻👍🏻
$variant: TagButtonVariant; | ||
} | ||
|
||
const getColorStyles = (variant: TagButtonVariant, isSelected: boolean, theme: DefaultTheme) => { |
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.
와 ~ 복잡한 로직인데 너무 깔끔하게 잘 짜주셨네요 👍🏻
구현 요약
디스커션 제출 페이지를 구현했습니다.
hashTagButton
에variant
를 추가했습니다. 기본값은primary
, 기타 타입은danger
가 있어요.HashTagList
컴포넌트가 자주 쓰이는 것 같아 공통 컴포넌트로 분리했습니다. 이 공통 컴포넌트는 미션과 해시태그를 선택하는 데 사용하게 되는데,HashTag
라는 네이밍은 범용적이지 않아Tag
로 바꾸었습니다.TagList (HashTagList)
컴포넌트를 사용하고 있는데, 공통 컴포넌트로 분리하는 과정에서selectedHashTag
의 타입 변화가 있었습니다.selectedHashTag
가 원래는string
이었지만,id
와name
을 키값으로 갖는 객체로 바꾸었습니다.id
를 갖는 객체로 바꾼 이유는,TagList
컴포넌트 내부에서isSelected
를 판별할 때 name이 아닌 id값으로isSelected
를 판별하기 위함입니다.string
비교보다는id
비교가 좀 더 정확할 것 같아요!연관 이슈
참고
코드 리뷰에
RCA 룰
을 적용할 시 참고해주세요.