Skip to content

Commit

Permalink
refactor : 숫자 상수로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
lodado committed Mar 17, 2022
1 parent 573bafb commit 9b16012
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
40 changes: 23 additions & 17 deletions frontend/src/components/organisms/PreferenceModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import { useRecoilState } from 'recoil';
import { preferenceModalState } from '@state/modal';
import { PREFERENCE_MODAL_STATUS } from '@enum/index';
import PreferenceMenuContent from './PreferenceMenuContent';
import AboutUs from './AboutUs/AboutUs';
import ThemeSelect from './ThemeSelect';
Expand All @@ -14,22 +15,27 @@ import {
RowDiv,
} from './styles';

const selectedContent = ({ isClicked }: { isClicked: number }): JSX.Element => {
switch (isClicked) {
case 1:
const { ABOUT, THEME, OUT } = PREFERENCE_MODAL_STATUS;

const selectedContent = ({
currentPreferenceStatus,
}: {
currentPreferenceStatus: number;
}): JSX.Element => {
switch (currentPreferenceStatus) {
case ABOUT:
return <AboutUs />;
case 2:
case THEME:
return <ThemeSelect />;
case 3:
return <WorkspaceOut />;
case OUT:
default:
return <WorkspaceOut />;
}
};

const PreferenceModal = (): JSX.Element => {
const [isOpen, setIsOpen] = useRecoilState(preferenceModalState);
const [isClicked, setClick] = useState<number>(1);
const [currentPreferenceStatus, setClick] = useState<number>(ABOUT);

return (
<StyledModal isOpen={isOpen} onClose={() => setIsOpen(false)} zIndex={100}>
Expand All @@ -38,27 +44,27 @@ const PreferenceModal = (): JSX.Element => {
<RowDiv>
<MenuContainer>
<StyledDivLists
isClicked={isClicked}
index={1}
onClick={() => setClick(1)}
isClicked={currentPreferenceStatus}
index={ABOUT}
onClick={() => setClick(ABOUT)}
text="About us"
/>
<StyledDivLists
isClicked={isClicked}
index={2}
onClick={() => setClick(2)}
isClicked={currentPreferenceStatus}
index={THEME}
onClick={() => setClick(THEME)}
text="테마 설정"
/>
<StyledDivLists
isClicked={isClicked}
index={3}
isClicked={currentPreferenceStatus}
index={OUT}
color="red"
onClick={() => setClick(3)}
onClick={() => setClick(OUT)}
text="워크스페이스 탈퇴"
/>
</MenuContainer>
<PreferenceMenuContent>
{selectedContent({ isClicked })}
{selectedContent({ currentPreferenceStatus })}
</PreferenceMenuContent>
</RowDiv>
</Container>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/enum/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export const CHANNELTYPE = {
1: '🔒',
0: '#',
} as const;

export const PREFERENCE_MODAL_STATUS = { ABOUT: 1, THEME: 2, OUT: 3 };

0 comments on commit 9b16012

Please sign in to comment.