Skip to content

Commit 9888340

Browse files
committed
refactor: MODAL_MENUS를 배열 인덱스로 바로 접근하도록 수정
1 parent ffa7bc9 commit 9888340

File tree

2 files changed

+33
-41
lines changed

2 files changed

+33
-41
lines changed

client/src/constants/workspace.ts

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,25 @@ Object.freeze(MENUS);
1313

1414
export const MODAL_MENUS = [
1515
{
16-
id: 1,
17-
props: {
18-
title: '워크스페이스 생성',
19-
texts: ['워크스페이스 이름을 입력해주세요.'],
20-
btnText: '생성하기',
21-
},
22-
},
23-
{
24-
id: 2,
25-
props: {
26-
title: '워크스페이스 참여',
27-
texts: ['워크스페이스 코드를 입력해주세요.'],
28-
btnText: '참여하기',
29-
},
30-
},
31-
{
32-
id: 3,
33-
props: {
34-
title: '워크스페이스 생성 완료',
35-
texts: [
36-
'워크스페이스가 생성되었습니다.',
37-
' 멤버들에게 참여 코드를 공유해보세요.',
38-
],
39-
btnText: '확인',
40-
},
41-
},
42-
];
16+
/* unused */
17+
title: '',
18+
texts: [],
19+
btnText: ''
20+
}, {
21+
title: '워크스페이스 생성',
22+
texts: ['워크스페이스 이름을 입력해주세요.'],
23+
btnText: '생성하기',
24+
}, {
25+
title: '워크스페이스 참여',
26+
texts: ['워크스페이스 코드를 입력해주세요.'],
27+
btnText: '참여하기',
28+
}, {
29+
title: '워크스페이스 생성 완료',
30+
texts: [
31+
'워크스페이스가 생성되었습니다.',
32+
' 멤버들에게 참여 코드를 공유해보세요.',
33+
],
34+
btnText: '확인',
35+
}
36+
]
4337
Object.freeze(MODAL_MENUS);

client/src/pages/Workspace/index.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,18 @@ function WorkspacePage() {
5151
</SelectModal>
5252
)}
5353

54-
{MODAL_MENUS.map(({ id, props: { title, texts, btnText } }) => {
55-
if (id === clickedMenuId)
56-
return (
57-
<WorkspaceModal
58-
key={id}
59-
{...{ title, texts, btnText }}
60-
inputValue={inputValue}
61-
onChange={onInput}
62-
onClose={() => setClickedMenuId(0)}
63-
onClick={onClickBtn}
64-
isInputDisabled={clickedMenuId === MENU.JOIN_SUCCESS_ID}
65-
/>
66-
);
67-
})}
54+
{clickedMenuId !== 0 && (
55+
<WorkspaceModal
56+
title={MODAL_MENUS[clickedMenuId].title}
57+
texts={MODAL_MENUS[clickedMenuId].texts}
58+
btnText={MODAL_MENUS[clickedMenuId].btnText}
59+
inputValue={inputValue}
60+
onChange={onInput}
61+
onClose={() => setClickedMenuId(0)}
62+
onClick={onClickBtn}
63+
isInputDisabled={clickedMenuId === MENU.JOIN_SUCCESS_ID}
64+
/>
65+
)}
6866
</div>
6967
);
7068
}

0 commit comments

Comments
 (0)