forked from quic-issues/427e7578-d7bf-49c8-aee9-2dd999e25316
p2p poll logic added
This commit is contained in:
40
components/PollCreation.tsx
Normal file
40
components/PollCreation.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
"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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user