diff --git a/src/components/Layout/Sidebar/Sidebar.tsx b/src/components/Layout/Sidebar/Sidebar.tsx index 3812bc848..4231b0ef6 100644 --- a/src/components/Layout/Sidebar/Sidebar.tsx +++ b/src/components/Layout/Sidebar/Sidebar.tsx @@ -4,6 +4,7 @@ import { VscBug } from 'react-icons/vsc'; import { Role } from '@api/dto'; import CATEGORIES from '@constants/category'; import { KEEPER_COLOR, KEEPER_WIDTH } from '@constants/keeperTheme'; +import { MEMBER_ROLE } from '@constants/member'; import useCheckAuth from '@hooks/useCheckAuth'; import CategoryNav from '@components/Navigation/CategoryNav'; @@ -13,7 +14,13 @@ interface SidebarProps { } const Sidebar = ({ mobileSidebarOpen, setMobileSidebarOpen }: SidebarProps) => { - const executiveRoles: Role[] = ['ROLE_회장', 'ROLE_부회장', 'ROLE_서기', 'ROLE_총무', 'ROLE_사서']; + const executiveRoles: Role[] = [ + MEMBER_ROLE.회장, + MEMBER_ROLE.부회장, + MEMBER_ROLE.서기, + MEMBER_ROLE.총무, + MEMBER_ROLE.사서, + ]; const { checkIncludeOneOfAuths } = useCheckAuth(); const theme = useTheme(); diff --git a/src/constants/badge.ts b/src/constants/badge.ts index 448e6ab9d..d75cb6ffc 100644 --- a/src/constants/badge.ts +++ b/src/constants/badge.ts @@ -9,18 +9,19 @@ import librarianBadge from '@assets/dutyManage/badge_8_librarian.gif'; import graduateBadge from '@assets/profileBadge/profile_badge_state_graduate.gif'; import regularBadge from '@assets/profileBadge/profile_badge_state_regular.gif'; import sleepBadge from '@assets/profileBadge/profile_badge_state_sleep.gif'; +import { MEMBER_ROLE } from './member'; const roles = [ - { name: 'ROLE_회장', img: chairmanBadge }, - { name: 'ROLE_부회장', img: viceChairmanBadge }, - { name: 'ROLE_서기', img: clerkBadge }, - { name: 'ROLE_총무', img: administratorBadge }, - { name: 'ROLE_사서', img: librarianBadge }, - { name: 'ROLE_학술부장', img: studyManagerBadge }, - { name: 'ROLE_대외부장', img: externalManagerBadge }, - { name: 'ROLE_FRONT_전산관리자', img: ITManagerBadge }, - { name: 'ROLE_BACK_전산관리자', img: ITManagerBadge }, - { name: 'ROLE_INFRA_전산관리자', img: ITManagerBadge }, + { name: MEMBER_ROLE.회장, img: chairmanBadge }, + { name: MEMBER_ROLE.부회장, img: viceChairmanBadge }, + { name: MEMBER_ROLE.서기, img: clerkBadge }, + { name: MEMBER_ROLE.총무, img: administratorBadge }, + { name: MEMBER_ROLE.사서, img: librarianBadge }, + { name: MEMBER_ROLE.학술부장, img: studyManagerBadge }, + { name: MEMBER_ROLE.대외부장, img: externalManagerBadge }, + { name: MEMBER_ROLE.FRONT_전산관리자, img: ITManagerBadge }, + { name: MEMBER_ROLE.BACK_전산관리자, img: ITManagerBadge }, + { name: MEMBER_ROLE.INFRA_전산관리자, img: ITManagerBadge }, ]; const types: { [key: string]: string } = { 정회원: regularBadge, 졸업: graduateBadge, 휴면회원: sleepBadge }; diff --git a/src/constants/category.ts b/src/constants/category.ts index d637759a0..6e9a0e857 100644 --- a/src/constants/category.ts +++ b/src/constants/category.ts @@ -1,4 +1,5 @@ import { Role } from '@api/dto'; +import { MEMBER_ROLE } from '@constants/member'; export interface CategoryMenu { id: number; @@ -152,19 +153,19 @@ const CATEGORIES: Category[] = [ id: 605, name: '문제관리', path: 'admin/challengeManage', - roles: ['ROLE_회장', 'ROLE_출제자'], + roles: [MEMBER_ROLE.회장, MEMBER_ROLE.출제자], }, { id: 606, name: '제출로그', path: 'admin/submissions', - roles: ['ROLE_회장', 'ROLE_출제자'], + roles: [MEMBER_ROLE.회장, MEMBER_ROLE.출제자], }, { id: 607, name: '대회운영', path: 'admin/operation', - roles: ['ROLE_회장'], + roles: [MEMBER_ROLE.회장], }, ], }, */ @@ -177,37 +178,37 @@ const CATEGORIES: Category[] = [ id: 701, name: '직책관리', path: 'dutyManage', - roles: ['ROLE_회장', 'ROLE_부회장'], + roles: [MEMBER_ROLE.회장, MEMBER_ROLE.부회장], }, /* { id: 702, name: '선거관리', path: 'electionManage', - roles: ['ROLE_회장'], + roles: [MEMBER_ROLE.회장], }, */ { id: 703, name: '도서관리', path: 'libraryManage', - roles: ['ROLE_회장', 'ROLE_부회장', 'ROLE_사서'], + roles: [MEMBER_ROLE.회장, MEMBER_ROLE.부회장, MEMBER_ROLE.사서], }, { id: 704, name: '세미나관리', path: 'seminarManage', - roles: ['ROLE_회장', 'ROLE_부회장', 'ROLE_서기'], + roles: [MEMBER_ROLE.회장, MEMBER_ROLE.부회장, MEMBER_ROLE.서기], }, { id: 705, name: '활동인원관리', path: 'activeMemberManage', - roles: ['ROLE_회장', 'ROLE_부회장', 'ROLE_서기'], + roles: [MEMBER_ROLE.회장, MEMBER_ROLE.부회장, MEMBER_ROLE.서기], }, { id: 706, name: '상벌점관리', path: 'meritManage', - roles: ['ROLE_회장', 'ROLE_부회장', 'ROLE_서기'], + roles: [MEMBER_ROLE.회장, MEMBER_ROLE.부회장, MEMBER_ROLE.서기], }, ], }, diff --git a/src/constants/member.ts b/src/constants/member.ts new file mode 100644 index 000000000..7e42e4442 --- /dev/null +++ b/src/constants/member.ts @@ -0,0 +1,17 @@ +export const MEMBER_ROLE_PREFIX = 'ROLE_'; + +export const MEMBER_ROLE = { + 회장: `${MEMBER_ROLE_PREFIX}회장`, + 부회장: `${MEMBER_ROLE_PREFIX}부회장`, + 서기: `${MEMBER_ROLE_PREFIX}서기`, + 총무: `${MEMBER_ROLE_PREFIX}총무`, + 사서: `${MEMBER_ROLE_PREFIX}사서`, + 학술부장: `${MEMBER_ROLE_PREFIX}학술부장`, + 대외부장: `${MEMBER_ROLE_PREFIX}대외부장`, + 전산관리자: `${MEMBER_ROLE_PREFIX}전산관리자`, + FRONT_전산관리자: `${MEMBER_ROLE_PREFIX}FRONT_전산관리자`, + BACK_전산관리자: `${MEMBER_ROLE_PREFIX}BACK_전산관리자`, + INFRA_전산관리자: `${MEMBER_ROLE_PREFIX}INFRA_전산관리자`, + 회원: `${MEMBER_ROLE_PREFIX}회원`, + 출제자: `${MEMBER_ROLE_PREFIX}출제자`, +} as const; diff --git a/src/mocks/DutyManageApi.ts b/src/mocks/DutyManageApi.ts index 9701a291d..f7cb40f6c 100644 --- a/src/mocks/DutyManageApi.ts +++ b/src/mocks/DutyManageApi.ts @@ -6,6 +6,7 @@ import ITManagerBadge from '@assets/dutyManage/badge_5_it_manager.gif'; import clerkBadge from '@assets/dutyManage/badge_6_clerk.gif'; import administratorBadge from '@assets/dutyManage/badge_7_administrator.gif'; import librarianBadge from '@assets/dutyManage/badge_8_librarian.gif'; +import { MEMBER_ROLE } from '@constants/member'; interface RoleDutyList { jobName: string; @@ -82,14 +83,16 @@ const roleDutyListInfo: RoleDutyList[] = [ ]; const roles = [ - { name: 'ROLE_회장', img: chairmanBadge }, - { name: 'ROLE_부회장', img: viceChairmanBadge }, - { name: 'ROLE_대외부장', img: externalManagerBadge }, - { name: 'ROLE_학술부장', img: studyManagerBadge }, - { name: 'ROLE_전산관리자', img: ITManagerBadge }, - { name: 'ROLE_서기', img: clerkBadge }, - { name: 'ROLE_총무', img: administratorBadge }, - { name: 'ROLE_사서', img: librarianBadge }, + { name: MEMBER_ROLE.회장, img: chairmanBadge }, + { name: MEMBER_ROLE.부회장, img: viceChairmanBadge }, + { name: MEMBER_ROLE.대외부장, img: externalManagerBadge }, + { name: MEMBER_ROLE.학술부장, img: studyManagerBadge }, + { name: MEMBER_ROLE.FRONT_전산관리자, img: ITManagerBadge }, + { name: MEMBER_ROLE.BACK_전산관리자, img: ITManagerBadge }, + { name: MEMBER_ROLE.INFRA_전산관리자, img: ITManagerBadge }, + { name: MEMBER_ROLE.서기, img: clerkBadge }, + { name: MEMBER_ROLE.총무, img: administratorBadge }, + { name: MEMBER_ROLE.사서, img: librarianBadge }, ]; export type JobInfoType = { diff --git a/src/pages/Library/Library.tsx b/src/pages/Library/Library.tsx index cb340e4c0..9df2ea924 100644 --- a/src/pages/Library/Library.tsx +++ b/src/pages/Library/Library.tsx @@ -4,6 +4,7 @@ import Typography from '@mui/material/Typography'; import { BookListSearch } from '@api/dto'; import { useGetExecutiveInfoQuery } from '@api/dutyManageApi'; import { useGetBookListQuery, useRequestBorrowBookMutation, useGetBookBorrowsQuery } from '@api/libraryApi'; +import { MEMBER_ROLE } from '@constants/member'; import usePagination from '@hooks/usePagination'; import StandardTablePagination from '@components/Pagination/StandardTablePagination'; import PageTitle from '@components/Typography/PageTitle'; @@ -28,7 +29,7 @@ const Library = () => { const { data: executiveInfos } = useGetExecutiveInfoQuery(); const { mutate: RequestBorrowBook } = useRequestBorrowBookMutation(); - const librarian = executiveInfos?.find((role) => role.jobName === 'ROLE_사서')?.realName || ''; + const librarian = executiveInfos?.find((role) => role.jobName === MEMBER_ROLE.사서)?.realName || ''; const handleRequestBook = (bookId: number) => { RequestBorrowBook(bookId, { diff --git a/src/pages/Profile/Section/BadgeSection.tsx b/src/pages/Profile/Section/BadgeSection.tsx index c6e092184..e2d563904 100644 --- a/src/pages/Profile/Section/BadgeSection.tsx +++ b/src/pages/Profile/Section/BadgeSection.tsx @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'; import { Tooltip } from '@mui/material'; import { Role, RoleInfo } from '@api/dto'; import { roles, types } from '@constants/badge'; +import { MEMBER_ROLE_PREFIX, MEMBER_ROLE } from '@constants/member'; interface FollowListProps { memberType: string; @@ -13,7 +14,7 @@ const BadgeSection = ({ memberType, memberJobs }: FollowListProps) => { useEffect(() => { const updatedMemberJobInfo = memberJobs - .filter((job) => job !== 'ROLE_회원' && job !== 'ROLE_출제자') + .filter((job) => job !== MEMBER_ROLE.회원 && job !== MEMBER_ROLE.출제자) .map((job) => { const filteredRole = roles.find((role) => role.name === job); return { @@ -27,7 +28,7 @@ const BadgeSection = ({ memberType, memberJobs }: FollowListProps) => { return (
{MemberJobInfo.map((job: RoleInfo) => ( - + ))} diff --git a/src/pages/Profile/Tab/BookTab/BookTab.tsx b/src/pages/Profile/Tab/BookTab/BookTab.tsx index 2fb69b095..6a7142331 100644 --- a/src/pages/Profile/Tab/BookTab/BookTab.tsx +++ b/src/pages/Profile/Tab/BookTab/BookTab.tsx @@ -7,6 +7,7 @@ import { useCancleReturnBookMutation, useCancleBorrowBookMutation, } from '@api/libraryApi'; +import { MEMBER_ROLE } from '@constants/member'; import BookCard from './Card/BookCard'; import BookGuide from './Guide/BookGuide'; @@ -20,7 +21,7 @@ const BookTab = () => { const { mutate: cancleReturnBookMutation } = useCancleReturnBookMutation(); const { mutate: cancleBorrowBookMutation } = useCancleBorrowBookMutation(); - const librarian = executiveInfos?.find((role) => role.jobName === 'ROLE_사서')?.realName || ''; + const librarian = executiveInfos?.find((role) => role.jobName === MEMBER_ROLE.사서)?.realName || ''; const borrowLength = borrowedBookListData?.content?.filter((bookInfo) => bookInfo.status === '대출대기').length; const returnLength = borrowedBookListData?.content?.filter((bookInfo) => bookInfo.status === '반납대기').length; diff --git a/src/pages/admin/DutyManage/Button/DutyProfileButton.tsx b/src/pages/admin/DutyManage/Button/DutyProfileButton.tsx index 443a25394..76456672a 100644 --- a/src/pages/admin/DutyManage/Button/DutyProfileButton.tsx +++ b/src/pages/admin/DutyManage/Button/DutyProfileButton.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { Button, Typography } from '@mui/material'; import { useGetExecutiveInfoQuery } from '@api/dutyManageApi'; +import { MEMBER_ROLE } from '@constants/member'; import muiTheme from '@constants/muiTheme'; import { convertJobName } from '@mocks/DutyManageApi'; @@ -21,7 +22,7 @@ const DutyProfileButton = ({ jobName, badgeImage, setTooltipOpen, toggleModalOpe toggleModalOpen(); }; - if (jobName === 'ROLE_전산관리자') { + if (jobName === MEMBER_ROLE.전산관리자) { return (
diff --git a/src/pages/admin/DutyManage/DutyManage.tsx b/src/pages/admin/DutyManage/DutyManage.tsx index 01e24d5da..db45acf96 100644 --- a/src/pages/admin/DutyManage/DutyManage.tsx +++ b/src/pages/admin/DutyManage/DutyManage.tsx @@ -1,21 +1,21 @@ import React from 'react'; +import { MEMBER_ROLE } from '@constants/member'; import PageTitle from '@components/Typography/PageTitle'; - import DutyProfileTooltip from './Tooltip/DutyProfileTooltip'; const jobNameArray = [ - { key: 1, jobName: 'ROLE_학술부장' }, - { key: 2, jobName: 'ROLE_대외부장' }, - { key: 3, jobName: 'ROLE_전산관리자' }, - { key: 4, jobName: 'ROLE_서기' }, - { key: 5, jobName: 'ROLE_사서' }, - { key: 6, jobName: 'ROLE_총무' }, + { key: 1, jobName: MEMBER_ROLE.학술부장 }, + { key: 2, jobName: MEMBER_ROLE.대외부장 }, + { key: 3, jobName: MEMBER_ROLE.전산관리자 }, + { key: 4, jobName: MEMBER_ROLE.서기 }, + { key: 5, jobName: MEMBER_ROLE.사서 }, + { key: 6, jobName: MEMBER_ROLE.총무 }, ]; const ITjobNameArray = [ - { key: 1, jobName: 'ROLE_FRONT_전산관리자' }, - { key: 2, jobName: 'ROLE_BACK_전산관리자' }, - { key: 3, jobName: 'ROLE_INFRA_전산관리자' }, + { key: 1, jobName: MEMBER_ROLE.FRONT_전산관리자 }, + { key: 2, jobName: MEMBER_ROLE.BACK_전산관리자 }, + { key: 3, jobName: MEMBER_ROLE.INFRA_전산관리자 }, ]; const MiddleBar = () => { @@ -66,7 +66,7 @@ const ViceChairman = () => {
- +
@@ -78,7 +78,7 @@ const DutyManage = () => {
직책관리
- + diff --git a/src/pages/admin/DutyManage/Tooltip/DutyProfileTooltip.tsx b/src/pages/admin/DutyManage/Tooltip/DutyProfileTooltip.tsx index 0887743aa..de8b48605 100644 --- a/src/pages/admin/DutyManage/Tooltip/DutyProfileTooltip.tsx +++ b/src/pages/admin/DutyManage/Tooltip/DutyProfileTooltip.tsx @@ -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,13 +51,8 @@ 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; + // NOTE jobName으로는 "ROLE_전산관리자" 내려오지만, roles에는 존재하지 않습니다! 세부적인 전산관리자(프론트, 백, 인프라)만 존재합니다 return (
{ setTooltipOpen={setTooltipOpen} toggleModalOpen={toggleModalOpen} /> - {jobName !== 'ROLE_전산관리자' ? ( + {jobName !== MEMBER_ROLE.전산관리자 && ( <> { badgeImage={badgeImage} /> - ) : null} + )}
); }; diff --git a/src/pages/senimarAttend/SenimarAttend.tsx b/src/pages/senimarAttend/SenimarAttend.tsx index 0b650e475..4ce8edaa2 100644 --- a/src/pages/senimarAttend/SenimarAttend.tsx +++ b/src/pages/senimarAttend/SenimarAttend.tsx @@ -8,6 +8,7 @@ import { useGetRecentlyDoneSeminarInfoQuery, useGetRecentlyUpcomingSeminarInfoQuery, } from '@api/seminarApi'; +import { MEMBER_ROLE } from '@constants/member'; import useCheckAuth from '@hooks/useCheckAuth'; import memberState from '@recoil/member.recoil'; import starterState from '@recoil/seminarStarter.recoil'; @@ -30,7 +31,7 @@ const SeminarAttend = () => { const { data: availableSeminarData } = useGetAvailableSeminarInfoQuery(); const { checkIncludeOneOfAuths } = useCheckAuth(); - const authorizedMember = checkIncludeOneOfAuths(['ROLE_회장', 'ROLE_부회장', 'ROLE_서기']); + const authorizedMember = checkIncludeOneOfAuths([MEMBER_ROLE.회장, MEMBER_ROLE.부회장, MEMBER_ROLE.서기]); const startMember: number | undefined = useRecoilValue(starterState); const member: MemberInfo | null = useRecoilValue(memberState);