forked from quic-issues/427e7578-d7bf-49c8-aee9-2dd999e25316
40 lines
964 B
TypeScript
40 lines
964 B
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
|
|
export default function PollCreation({ pollManager }: any) {
|
|
const [question, setQuestion] = useState("");
|
|
const [options, setOptions] = useState<string[]>(["", ""]);
|
|
|
|
return (
|
|
<div>
|
|
<input
|
|
className="border p-2 w-full"
|
|
placeholder="Question"
|
|
value={question}
|
|
onChange={(e) => setQuestion(e.target.value)}
|
|
/>
|
|
|
|
{options.map((opt, i) => (
|
|
<input
|
|
key={i}
|
|
className="border p-2 w-full mt-2"
|
|
placeholder={`Option ${i + 1}`}
|
|
value={opt}
|
|
onChange={(e) => {
|
|
const newOpts = [...options];
|
|
newOpts[i] = e.target.value;
|
|
setOptions(newOpts);
|
|
}}
|
|
/>
|
|
))}
|
|
|
|
<button
|
|
className="bg-green-500 text-white px-4 mt-2"
|
|
onClick={() => pollManager.createPoll(question, options)}
|
|
>
|
|
Create Poll
|
|
</button>
|
|
</div>
|
|
);
|
|
} |