@@ -30,8 +30,9 @@ function VoteBlockTemplate({
3030 options,
3131 setOptions,
3232} : VoteBlockProps ) {
33- const [ isCreateMode , isRegisteredMode , isEndMode ] = [
33+ const [ isCreateMode , isRegisteringMode , isRegisteredMode , isEndMode ] = [
3434 mode === VoteMode . CREATE ,
35+ mode === VoteMode . REGISTERING ,
3536 mode === VoteMode . REGISTERED ,
3637 mode === VoteMode . END ,
3738 ] ;
@@ -67,7 +68,7 @@ function VoteBlockTemplate({
6768 setOptions ( validOptions ) ;
6869 setVoteMode ( VoteMode . REGISTERED ) ;
6970
70- socket . emit ( BLOCK_EVENT . CREATE_VOTE , id , validOptions ) ;
71+ socket . emit ( BLOCK_EVENT . REGISTER_VOTE , id , validOptions ) ;
7172
7273 toast ( '투표 등록 완료 ^^' , { type : 'info' } ) ;
7374 } ;
@@ -143,63 +144,70 @@ function VoteBlockTemplate({
143144
144145 return (
145146 < div className = { style [ 'vote-container' ] } >
146- < h3 className = { style . title } > 투표 </ h3 >
147+ < h3 className = { style . title } > { '투표' } </ h3 >
147148 { ( isRegisteredMode || isEndMode ) && (
148149 < span className = { style [ 'participant-cnt' ] } >
149150 { participantCount } 명 참여
150151 </ span >
151152 ) }
152-
153- < ul >
154- { options . map ( ( { id, text, count } , index ) => (
155- < li
156- className = { cx ( 'option-item' , {
157- 'selected-item' :
158- ( isRegisteredMode || isEndMode ) && id === selectedOptionId ,
159- } ) }
160- key = { id }
161- onClick = { ( ) => onSelect ( id ) }
162- >
163- { isEndMode && (
164- < div
165- className = { style [ 'vote-result-bar' ] }
166- style = { {
167- width : `${ getPercent ( count ) } %` ,
168- backgroundColor : color . highlight100 ,
169- } }
170- > </ div >
171- ) }
172-
173- < div className = { style [ 'box-fill' ] } > { index + 1 } </ div >
174- < input
175- type = "text"
176- className = { cx ( 'option-input' , {
177- selected : isRegisteredMode ,
178- } ) }
179- placeholder = "항목을 입력해주세요"
180- onChange = { onChange }
181- data-id = { id }
182- readOnly = { isRegisteredMode || isEndMode }
183- defaultValue = { text }
184- />
185- { isCreateMode && (
186- < Button
187- icon = { < BiX size = "20" color = "white" /> }
188- ariaLabel = "항목 삭제"
189- onClick = { ( ) => onDelete ( id ) }
190- />
191- ) }
192- { isEndMode && (
193- < div className = { style [ 'vote-result-text' ] } >
194- { getVoteResultText ( count ) }
195- </ div >
196- ) }
197- </ li >
198- ) ) }
199- </ ul >
200-
153+ {
154+ < ul >
155+ { isCreateMode ? (
156+ < li className = { style [ 'option-item' ] } >
157+ < div className = { style [ 'box-fill' ] } > { '^^' } </ div >
158+ < div > 등록될 때까지 기다려주세요</ div >
159+ </ li >
160+ ) : (
161+ options . map ( ( { id, text, count } , index ) => (
162+ < li
163+ className = { cx ( 'option-item' , {
164+ 'selected-item' :
165+ ( isRegisteredMode || isEndMode ) && id === selectedOptionId ,
166+ } ) }
167+ key = { id }
168+ onClick = { ( ) => onSelect ( id ) }
169+ >
170+ { isEndMode && (
171+ < div
172+ className = { style [ 'vote-result-bar' ] }
173+ style = { {
174+ width : `${ getPercent ( count ) } %` ,
175+ backgroundColor : color . highlight100 ,
176+ } }
177+ > </ div >
178+ ) }
179+
180+ < div className = { style [ 'box-fill' ] } > { index + 1 } </ div >
181+ < input
182+ type = "text"
183+ className = { cx ( 'option-input' , {
184+ selected : isRegisteredMode ,
185+ } ) }
186+ placeholder = "항목을 입력해주세요"
187+ onChange = { onChange }
188+ data-id = { id }
189+ readOnly = { isRegisteredMode || isEndMode }
190+ defaultValue = { text }
191+ />
192+ { isRegisteringMode && (
193+ < Button
194+ icon = { < BiX size = "20" color = "white" /> }
195+ ariaLabel = "항목 삭제"
196+ onClick = { ( ) => onDelete ( id ) }
197+ />
198+ ) }
199+ { isEndMode && (
200+ < div className = { style [ 'vote-result-text' ] } >
201+ { getVoteResultText ( count ) }
202+ </ div >
203+ ) }
204+ </ li >
205+ ) )
206+ ) }
207+ </ ul >
208+ }
201209 < div className = { style [ 'vote-buttons' ] } >
202- { isCreateMode && (
210+ { isRegisteringMode && (
203211 < >
204212 < Button onClick = { onAdd } text = "항목 추가" />
205213 < Button onClick = { onRegister } text = "투표 등록" />
0 commit comments