Skip to content

Conversation

@GoDoyeon
Copy link
Contributor

설명

글 상세 페이지에 수정, 삭제 버튼 추가하였습니다.
추후 권한 처리 작업도 할 예정입니다.

작업 내용

  • 수정, 삭제 버튼 추가

스크린샷

스크린샷 2023-06-11 오후 7 40 12

참고

참고할 만한 링크가 있다면 적어주세요.

@GoDoyeon GoDoyeon added the enhancement New feature or request label Jun 11, 2023
@GoDoyeon GoDoyeon requested a review from ssabii June 11, 2023 10:42
@GoDoyeon GoDoyeon self-assigned this Jun 11, 2023
Copy link
Contributor

@ssabii ssabii left a comment

Choose a reason for hiding this comment

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

고생하셨습니다.

Comment on lines +176 to +198
<IconButton
aria-label="more"
id="long-button"
aria-controls={openDetailMenu ? 'fade-menu' : undefined}
aria-haspopup="true"
aria-expanded={openDetailMenu ? 'true' : undefined}
onClick={handleClick}
>
<MoreVertIcon />
</IconButton>
<Menu
id="fade-menu"
MenuListProps={{
'aria-labelledby': 'fade-button',
}}
anchorEl={anchorEl}
open={openDetailMenu}
onClose={handleClose}
TransitionComponent={Fade}
>
<MenuItem onClick={onClickEdit}>수정</MenuItem>
<MenuItem onClick={onClickDelete}>삭제</MenuItem>
</Menu>
Copy link
Contributor

Choose a reason for hiding this comment

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

mui menu 사용해서 수정/삭제 구현한거 너무 좋네요 😄
컴포넌트가 조금 비대해지는 것 같은데 이 부분은 나중에 역할과 용도에 따라 PostEditMenu 이런식으로 해서 컴포넌트로 분리해도 괜찮을것 같아요.
컴포넌트를 분리하면 나중에 내가 작성한 글이면 권한에 따라 보여질 지 안보여 질지 조건부 렌더링할때도 유용할 것 같아요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

그렇겠네요! 좋습니당

Comment on lines +31 to +32
const onClickDelete = () => {
};
Copy link
Contributor

Choose a reason for hiding this comment

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

eslint 설정으로 빈 함수는 오류가 나게 설정되어 있어서 빌드할 때는 아마 오류가 날 것 같아요.
아래처럼 일단 해주셔도 될 것 같고 삭제 api 연동은 추후에 제가 작업을 할게요!

// eslint-disable-next-line @typescript-eslint/no-empty-function
  const onClickDelete = () => {};

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 onClickDelete = () => {
};
const openDetailMenu = Boolean(anchorEl);
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
const onClickEdit = () => {
router.push(`/post/edit/${id}`)
};
const onClickDelete = () => {
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

아하! 넵 알겠습니다!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants