Skip to content

Commit 347897e

Browse files
committed
feat: 투표 블럭을 생성한 사람만 등록 가능하도록 변경
1 parent d4e9372 commit 347897e

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

client/src/components/Block/VoteBlock/VoteBlockTemplate.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
];
@@ -182,7 +183,7 @@ function VoteBlockTemplate({
182183
readOnly={isRegisteredMode || isEndMode}
183184
defaultValue={text}
184185
/>
185-
{isCreateMode && (
186+
{isRegisteringMode && (
186187
<Button
187188
icon={<BiX size="20" color="white" />}
188189
ariaLabel="항목 삭제"
@@ -199,7 +200,7 @@ function VoteBlockTemplate({
199200
</ul>
200201

201202
<div className={style['vote-buttons']}>
202-
{isCreateMode && (
203+
{isRegisteringMode && (
203204
<>
204205
<Button onClick={onAdd} text="항목 추가" />
205206
<Button onClick={onRegister} text="투표 등록" />

client/src/components/Block/VoteBlock/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ import VoteBlockTemplate from './VoteBlockTemplate';
88

99
interface VoteBlockProps {
1010
id: string;
11+
registerable: boolean;
1112
}
1213

13-
function VoteBlock({ id }: VoteBlockProps) {
14+
function VoteBlock({ id, registerable }: VoteBlockProps) {
1415
const { momSocket: socket } = useSocketContext();
1516

16-
const [voteMode, setVoteMode] = useState<VoteMode>(VoteMode.CREATE);
17+
const [voteMode, setVoteMode] = useState<VoteMode>(
18+
registerable ? VoteMode.REGISTERING : VoteMode.CREATE,
19+
);
1720
const initialOption: Option[] = [{ id: 1, text: '', count: 0 }];
1821
const [options, setOptions] = useState<Option[]>(initialOption);
1922

client/src/components/Block/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function Block({ id, index, onKeyDown, registerRef }: BlockProps) {
6565
/>
6666
);
6767
case BlockType.VOTE:
68-
return <VoteBlock id={id} />;
68+
return <VoteBlock id={id} registerable={localUpdateFlagRef.current} />;
6969
case BlockType.QUESTION:
7070
return <QuestionBlock id={id} />;
7171
default:

client/src/constants/block.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const BLOCKS_TYPE = [
3939

4040
export enum VoteMode {
4141
CREATE,
42+
REGISTERING,
4243
REGISTERED,
4344
END,
4445
}

0 commit comments

Comments
 (0)