Skip to content

Commit 14837eb

Browse files
committed
feat: 종료 버튼 추가
등록 후에 종료 버튼이 나타나게 함 Resolve: #147
1 parent 1ac0a2d commit 14837eb

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

client/src/components/VoteBlock/index.tsx

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ function VoteBlock() {
2626
const inputRef = useRef<HTMLInputElement>(null);
2727

2828
const onRegister = () => {
29+
if (!options.length) throw new Error('투표 항목은 최소 1개에요 ^^');
30+
2931
if (!isUnRegisterd) return;
3032

3133
setIsUnRegisterd(false);
@@ -53,6 +55,12 @@ function VoteBlock() {
5355
setOptions(filteredOptions);
5456
};
5557

58+
const onClose = () => {
59+
alert('투표 종료..!');
60+
/**투표 결과 보여줘야함 */
61+
setIsUnRegisterd(true);
62+
};
63+
5664
return (
5765
<div className={style['vote-container']}>
5866
<h3 className={style.title}>투표</h3>
@@ -73,25 +81,25 @@ function VoteBlock() {
7381
))}
7482
</ul>
7583
{isUnRegisterd && (
76-
<>
77-
<div className={style['option-item']}>
78-
<div className={style['box-fill']}></div>
79-
<input
80-
ref={inputRef}
81-
className={style['option-input']}
82-
placeholder="항목을 입력해주세요"
83-
></input>
84-
</div>
85-
<div className={style['vote-buttons']}>
86-
<Button className={style.button} onClick={onAdd} text="항목 추가" />
87-
<Button
88-
className={style.button}
89-
onClick={onRegister}
90-
text="투표 등록"
91-
/>
92-
</div>
93-
</>
84+
<div className={style['option-item']}>
85+
<div className={style['box-fill']}></div>
86+
<input
87+
ref={inputRef}
88+
className={style['option-input']}
89+
placeholder="항목을 입력해주세요"
90+
></input>
91+
</div>
9492
)}
93+
<div className={style['vote-buttons']}>
94+
{isUnRegisterd ? (
95+
<>
96+
<Button onClick={onAdd} text="항목 추가" />
97+
<Button onClick={onRegister} text="투표 등록" />
98+
</>
99+
) : (
100+
<Button onClick={onClose} text="투표 종료" />
101+
)}
102+
</div>
95103
</div>
96104
);
97105
}

client/src/components/VoteBlock/style.module.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
}
1919

2020
.option-item {
21-
2221
display: flex;
2322
position: relative;
2423
flex-direction: row;
@@ -74,7 +73,7 @@
7473

7574
margin-top: 20px;
7675

77-
.button {
76+
button {
7877
display: flex;
7978
align-items: center;
8079
justify-content: center;

0 commit comments

Comments
 (0)