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

Feature/role constansts로 빼기 #848 #852

Merged
merged 5 commits into from
Dec 11, 2023

Conversation

pipisebastian
Copy link
Member

@pipisebastian pipisebastian commented Dec 10, 2023

연관 이슈

작업 요약

  • �member role(회장, 부회장, 사서 등등) 상수로 빼줬습니다.

To 리뷰어... 💌

  • 예상 리뷰 소요 시간 5분
  • 코멘트 봐주시면 감사하겠습니다!

BACK_전산관리자: 'ROLE_BACK_전산관리자',
INFRA_전산관리자: 'ROLE_INFRA_전산관리자',
회원: 'ROLE_회원',
출제자: 'ROLE_출제자',
Copy link
Member Author

Choose a reason for hiding this comment

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

상수를 선언할 때, chairman 이 아닌 한글로 회장으로 선언해줬습니다! 영어로 하면 오히려 코드읽기가 어려울 것 같아서 입니다..! 그런데 한글의 경우, FRONT_전산관리자같은 경우 어떻게 선언해줘야할지(카멜케이스, _ 등등) 고민입니다..

Copy link
Contributor

Choose a reason for hiding this comment

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

한글 섞여있는 경우 _ 좋은 것 같아요!

Copy link
Collaborator

Choose a reason for hiding this comment

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

저도 영어랑 한글이 섞여있다면 언더바로 구분하는게 좋은 것 같습니다~!!

export const MEMBER_ROLE3 = {
회장: prefix('회장'),
부회장: prefix('부회장'),
} as const;
Copy link
Member Author

Choose a reason for hiding this comment

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

MEMBER_ROLE 상수를 선언하는 방식이 3가지인데, 어느게 좋을지 고민이 됩니다..

  1. ROLE_회장과 같이 바로 텍스트로 넣어주기 -> 해당 방식이 간단하지만, ROLE_ 부분이 중복되는데 이걸 바로 박아버리기 애매했습니다.
  2. prefix 변수 백틱안에 같이 넣어주기
  3. prefix 함수 만들어서 사용하기

Copy link
Contributor

Choose a reason for hiding this comment

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

2222

Copy link
Member Author

Choose a reason for hiding this comment

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

왜죠!!!!!

Copy link
Collaborator

Choose a reason for hiding this comment

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

저는 1번도 괜찮을 것 같긴 합니다!

  • 이유
  1. 에러 메시지를 상수로 바꾸는 과정에서는 (중복되더라도) 그냥 텍스트로 사용합니다.
  2. prefix() 가 어떤 형태인지 알고 있다면 이해할 수 있겠지만, 모른다면 해당 함수를 타고 들어가서 확인을 해야할 것 같습니다

근데 공통되는걸 묶으려면 백틱을 사용하는게 조금 더 전달력이 좋을 것 같습니당

Copy link
Contributor

@publdaze publdaze Dec 11, 2023

Choose a reason for hiding this comment

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

왜죠!!!!!

1. ROLE_이라는 prefix를 백엔드와 공통적으로 사용하고 있는데, 직책을 어떻게 표기할 지에 따라서 충분히 변경 가능한 부분으로 보입니다. 1번으로 가게되면 변경될 경우 수동으로 업데이트 해주어야 하는 게 번거로울 것 같아요!

3. 사실 이게 제일 깔끔해보이지는 한데, 단순한 텍스트에 함수 실행문이 들어가는 게 조금 과한 것 같다는 생각도 들더라구요!

그래서 최종적으로 prefix 변수를 사용하지만 템플릿 리터럴로 표현된 2번으로 선택하였습니다! 하지만 prefix로 사용되는 ROLE_이 크게 변동이 많을 것 같은 부분은 아니라서 1번도 괜찮을 것 같아요!

Copy link
Collaborator

Choose a reason for hiding this comment

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

저도 2번이 좋아보입니다.
Prefix는 공통이라 추후에 바뀔때 처리도 쉬울듯 하고,
실제 사용하는 입장에서는 1번과 2번 모두 똑같이 보여서
코드쪽 처리가 쉬운 2번이 좋을거 같습니다.
밑에는 참고 이미지 입니다!

1번
스크린샷 2023-12-11 오후 7 40 07

2번
스크린샷 2023-12-11 오후 7 40 15

Comment on lines -68 to +64
{jobName !== 'ROLE_전산관리자' ? (
{jobName !== MEMBER_ROLE.전산관리자 && (
Copy link
Contributor

Choose a reason for hiding this comment

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

굿!!

Copy link
Contributor

@publdaze publdaze left a comment

Choose a reason for hiding this comment

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

1,2,3 선택된 걸로 반영되면 approve 하겠습니다!

@pipisebastian pipisebastian self-assigned this Dec 10, 2023
@pipisebastian pipisebastian added the Refactor 리팩토링 label Dec 10, 2023
…nt-R2 into feature/Role-constansts로-빼기-#848

# Conflicts:
#	src/components/Layout/Sidebar/Sidebar.tsx
Copy link
Collaborator

@jasper200207 jasper200207 left a comment

Choose a reason for hiding this comment

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

👍

export const MEMBER_ROLE3 = {
회장: prefix('회장'),
부회장: prefix('부회장'),
} as const;
Copy link
Collaborator

Choose a reason for hiding this comment

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

저도 2번이 좋아보입니다.
Prefix는 공통이라 추후에 바뀔때 처리도 쉬울듯 하고,
실제 사용하는 입장에서는 1번과 2번 모두 똑같이 보여서
코드쪽 처리가 쉬운 2번이 좋을거 같습니다.
밑에는 참고 이미지 입니다!

1번
스크린샷 2023-12-11 오후 7 40 07

2번
스크린샷 2023-12-11 오후 7 40 15

Copy link
Collaborator

@mun-kyeong mun-kyeong left a comment

Choose a reason for hiding this comment

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

좋습니다~!! 질문에 답해주셔서 감사해용 ㅎㅎ 수고하셨습니다!!

}

const badgeImage = roles.find((role) => role.name === jobName)?.img;
// NOTE jobName으로는 "ROLE_전산관리자" 내려오지만, roles에는 존재하지 않습니다! 세부적인 전산관리자(프론트, 백, 인프라)만 존재합니다
Copy link
Collaborator

Choose a reason for hiding this comment

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

오옹 이런 주석 좋은것같슴당

BACK_전산관리자: 'ROLE_BACK_전산관리자',
INFRA_전산관리자: 'ROLE_INFRA_전산관리자',
회원: 'ROLE_회원',
출제자: 'ROLE_출제자',
Copy link
Collaborator

Choose a reason for hiding this comment

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

저도 영어랑 한글이 섞여있다면 언더바로 구분하는게 좋은 것 같습니다~!!

Copy link
Contributor

@publdaze publdaze left a comment

Choose a reason for hiding this comment

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

굿굿!

@pipisebastian pipisebastian merged commit 3cf2d4a into develop Dec 11, 2023
1 check passed
@pipisebastian pipisebastian deleted the feature/Role-constansts로-빼기-#848 branch December 11, 2023 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor 리팩토링
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Role constansts로 빼기
4 participants