Skip to content
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

Merged
merged 16 commits into from
Sep 19, 2024
Merged

Conversation

chosim-dvlpr
Copy link
Contributor

구현 요약

디스커션 제출 페이지를 구현했습니다.

  • hashTagButtonvariant를 추가했습니다. 기본값은 primary, 기타 타입은 danger가 있어요.
  • HashTagList 컴포넌트가 자주 쓰이는 것 같아 공통 컴포넌트로 분리했습니다. 이 공통 컴포넌트는 미션과 해시태그를 선택하는 데 사용하게 되는데, HashTag라는 네이밍은 범용적이지 않아 Tag로 바꾸었습니다.
  • 미션 리스트와 풀이 리스트에서 TagList (HashTagList) 컴포넌트를 사용하고 있는데, 공통 컴포넌트로 분리하는 과정에서 selectedHashTag의 타입 변화가 있었습니다.
    • selectedHashTag가 원래는 string이었지만, idname을 키값으로 갖는 객체로 바꾸었습니다.
    • id를 갖는 객체로 바꾼 이유는, TagList 컴포넌트 내부에서 isSelected를 판별할 때 name이 아닌 id값으로 isSelected를 판별하기 위함입니다. string 비교보다는 id 비교가 좀 더 정확할 것 같아요!

image

연관 이슈

참고

코드 리뷰에 RCA 룰을 적용할 시 참고해주세요.

헤더 설명
R (Request Changes) 적극적으로 반영을 고려해주세요
C (Comment) 웬만하면 반영해주세요
A (Approve) 반영해도 좋고, 넘어가도 좋습니다. 사소한 의견입니다.

@chosim-dvlpr chosim-dvlpr added 🎨 프론트엔드 프론트엔드 관련 이슈 ⚒️ 기능 작업해야하는 기능 labels Sep 15, 2024
@chosim-dvlpr chosim-dvlpr self-assigned this Sep 15, 2024
- Hash 네이밍 제거
- 외부에서 tags 타입 주입받도록 변경
- 다중 선택 가능한 TagMultipleList 추가
- variant 추가
- TagMultipleList 경로를 components/common 으로 이동
- string 타입에서 객체 타입으로 변경
- TagList 컴포넌트의 클릭이벤트 수정
- 디스커션 제출 페이지 태그 디자인 수정
Copy link
Contributor

@Parkhanyoung Parkhanyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전반적으로 잘 짜주신 것 같아 몇가지 사소한 코멘트만 남겨보았습니다 ㅎㅎ 반영하실 부분만 선택적으로 반영하고 다시 요청주시면 머지해드릴게요!

import { PATH } from './paths';

export const getDiscussions = async (mission = 'all', hashTag = 'all'): Promise<Discussion[]> => {
const { data } = await develupAPIClient.get<{ data: Discussion[] }>(`${PATH.discussions}`, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { data } = await develupAPIClient.get<{ data: Discussion[] }>(`${PATH.discussions}`, {
const { data } = await develupAPIClient.get<{ data: Discussion[] }>(PATH.discussions, {

hashTagIds: number[];
}): Promise<Discussion> => {
const { data } = await develupAPIClient.post<{ data: Discussion }>(
`${PATH.submitDiscussion}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`${PATH.submitDiscussion}`,
PATH.submitDiscussion,

width="xlarge"
danger={danger}
dangerMessage={ERROR_MESSAGE.invalid_title}
placeholder={'글 제목을 입력해주세요'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
placeholder={'글 제목을 입력해주세요'}
placeholder='글 제목을 입력해주세요'

const { data: allHashTags } = useHashTags();
const { data: allMissions } = useMissions();
const [selectedHashTags, setSelectedHashTags] = useState<HashTag[]>([]);
const [selectedMissions, setSelectedMissions] = useState({ id: 0, title: '' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

초기값으로 { id: 0, title: ''}을 넣어주신 의도가 궁금합니다~!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이름에 s가 붙어있는데 복수 형태가 아닌 것 같습니다! 혹시 다른 의도가 있으실까요?

Copy link
Contributor Author

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로 서버에 전송할 수 있도록 하기 위함입니다!

Copy link
Contributor Author

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}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
navigate(`${ROUTES.discussions}`);
navigate(ROUTES.discussions);

@@ -189,6 +190,16 @@ const routes = [
</App>
),
},
{
path: `${ROUTES.submitDiscussion}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
path: `${ROUTES.submitDiscussion}`,
path: ROUTES.submitDiscussion,

key={tag.id}
isSelected={isSelected}
onClick={() =>
setSelectedTag(isSelected ? ({ id: 0, [keyName]: HASHTAGS.all } as T) : tag)
Copy link
Contributor

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안

Suggested change
setSelectedTag(isSelected ? ({ id: 0, [keyName]: HASHTAGS.all } as T) : tag)
setSelectedTag(isSelected ? null : tag)

2안

Suggested change
setSelectedTag(isSelected ? ({ id: 0, [keyName]: HASHTAGS.all } as T) : tag)
toggleSelectedTag();

title: string;
mission: string;
hashTags: HashTag[];
member: Omit<UserInfo, 'description'>;
Copy link
Contributor

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) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

와 ~ 복잡한 로직인데 너무 깔끔하게 잘 짜주셨네요 👍🏻

@chosim-dvlpr chosim-dvlpr merged commit 2106dab into dev Sep 19, 2024
6 checks passed
@chosim-dvlpr chosim-dvlpr deleted the feat/#432 branch September 19, 2024 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚒️ 기능 작업해야하는 기능 🎨 프론트엔드 프론트엔드 관련 이슈
Projects
Status: 😎 DONE
Development

Successfully merging this pull request may close these issues.

디스커션 작성 페이지 구현
2 participants