-
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
Feature/role constansts로 빼기 #848 #852
The head ref may contain hidden characters: "feature/Role-constansts\uB85C-\uBE7C\uAE30-#848"
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export const MEMBER_ROLE_PREFIX = 'ROLE_'; | ||
|
||
// 1. | ||
export const MEMBER_ROLE = { | ||
회장: 'ROLE_회장', | ||
부회장: 'ROLE_부회장', | ||
서기: 'ROLE_서기', | ||
총무: 'ROLE_총무', | ||
사서: 'ROLE_사서', | ||
학술부장: 'ROLE_학술부장', | ||
대외부장: 'ROLE_대외부장', | ||
전산관리자: 'ROLE_전산관리자', | ||
FRONT_전산관리자: 'ROLE_FRONT_전산관리자', | ||
BACK_전산관리자: 'ROLE_BACK_전산관리자', | ||
INFRA_전산관리자: 'ROLE_INFRA_전산관리자', | ||
회원: 'ROLE_회원', | ||
출제자: 'ROLE_출제자', | ||
} as const; | ||
|
||
// 2. | ||
export const MEMBER_ROLE2 = { | ||
회장: `${MEMBER_ROLE_PREFIX}회장`, | ||
부회장: `${MEMBER_ROLE_PREFIX}부회장`, | ||
} as const; | ||
|
||
// 3. | ||
const prefix = (detail: string) => `${MEMBER_ROLE_PREFIX}${detail}`; | ||
|
||
export const MEMBER_ROLE3 = { | ||
회장: prefix('회장'), | ||
부회장: prefix('부회장'), | ||
} as const; | ||
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.
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. 2222 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. 왜죠!!!!! 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. 저는 1번도 괜찮을 것 같긴 합니다!
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.
1. 3. 사실 이게 제일 깔끔해보이지는 한데, 단순한 텍스트에 함수 실행문이 들어가는 게 조금 과한 것 같다는 생각도 들더라구요! 그래서 최종적으로 prefix 변수를 사용하지만 템플릿 리터럴로 표현된 2번으로 선택하였습니다! 하지만 prefix로 사용되는 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import { Typography } from '@mui/material'; | |
import List from '@mui/material/List'; | ||
import ListItem from '@mui/material/ListItem'; | ||
import { VscSearch } from 'react-icons/vsc'; | ||
import { MEMBER_ROLE } from '@constants/member'; | ||
import muiTheme from '@constants/muiTheme'; | ||
import { roleDutyListInfo, roles } from '@mocks/DutyManageApi'; | ||
|
||
|
@@ -50,12 +51,7 @@ const DutyProfileTooltip = ({ jobName }: DutyProfileTooltipProps) => { | |
const [tooltipOpen, setTooltipOpen] = useState(false); | ||
const [modalOpen, toggleModalOpen] = useReducer((prev) => !prev, false); | ||
|
||
let badgeImage; | ||
if (jobName.search('전산관리자') !== -1) { | ||
badgeImage = roles.find((role) => role.name === 'ROLE_전산관리자')?.img; | ||
} else { | ||
badgeImage = roles.find((role) => role.name === jobName)?.img; | ||
} | ||
const badgeImage = roles.find((role) => role.name === jobName)?.img; | ||
|
||
return ( | ||
<div className="relative z-10"> | ||
|
@@ -65,7 +61,7 @@ const DutyProfileTooltip = ({ jobName }: DutyProfileTooltipProps) => { | |
setTooltipOpen={setTooltipOpen} | ||
toggleModalOpen={toggleModalOpen} | ||
/> | ||
{jobName !== 'ROLE_전산관리자' ? ( | ||
{jobName !== MEMBER_ROLE.전산관리자 && ( | ||
Comment on lines
-68
to
+64
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. 굿!! |
||
<> | ||
<DescriptionRoleDutyTooltip | ||
title={tooltipContent(jobName)} | ||
|
@@ -85,7 +81,7 @@ const DutyProfileTooltip = ({ jobName }: DutyProfileTooltipProps) => { | |
badgeImage={badgeImage} | ||
/> | ||
</> | ||
) : null} | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
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.
상수를 선언할 때,
chairman
이 아닌 한글로회장
으로 선언해줬습니다! 영어로 하면 오히려 코드읽기가 어려울 것 같아서 입니다..! 그런데 한글의 경우,FRONT_전산관리자
같은 경우 어떻게 선언해줘야할지(카멜케이스, _ 등등) 고민입니다..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.
저도 영어랑 한글이 섞여있다면 언더바로 구분하는게 좋은 것 같습니다~!!