+
+
{
+ console.log(e.target.checked);
+ setSelected(e.target.checked);
+ if (e.target.checked) {
+ switch (pollType) {
+ case PollType.SINGLE_VOTE:
+ onChange(true, 1);
+ break;
+ case PollType.MULTIPLE_VOTE:
+ onChange(true, 1);
+ break;
+ case PollType.WEIGHTED_MULTIPLE_VOTE:
+ if (votes) {
+ onChange(true, votes);
+ } else {
+ setIsInvalid(true);
+ }
+ break;
+ }
+ } else {
+ onChange(false, 0);
+ setIsInvalid(false);
+ setVotes(0);
+ if (votesFieldRef.current) {
+ votesFieldRef.current.value = "";
+ }
}
- `}
- onClick={handleClick}
- >
-
{children}
-
-
+ }}
+ name={pollType === PollType.SINGLE_VOTE ? "candidate-votes" : `candidate-votes-${index}`}
+ />
+
+
{candidate}
-
+
+ {pollType === PollType.WEIGHTED_MULTIPLE_VOTE && (
+
+ )}
+ >
);
};
diff --git a/packages/nextjs/contracts/deployedContracts.ts b/packages/nextjs/contracts/deployedContracts.ts
index 6f48b64..3452ee4 100644
--- a/packages/nextjs/contracts/deployedContracts.ts
+++ b/packages/nextjs/contracts/deployedContracts.ts
@@ -1374,7 +1374,7 @@ const deployedContracts = {
{
indexed: false,
internalType: "string",
- name: "ipfsHash",
+ name: "metadata",
type: "string",
},
{
@@ -1463,7 +1463,7 @@ const deployedContracts = {
},
{
internalType: "string",
- name: "_ipfsHash",
+ name: "_metadata",
type: "string",
},
{
@@ -1511,7 +1511,7 @@ const deployedContracts = {
},
{
internalType: "string",
- name: "ipfsHash",
+ name: "metadata",
type: "string",
},
{
@@ -1614,7 +1614,7 @@ const deployedContracts = {
},
{
internalType: "string",
- name: "ipfsHash",
+ name: "metadata",
type: "string",
},
{
diff --git a/packages/nextjs/types/poll.ts b/packages/nextjs/types/poll.ts
index a0060d0..c295160 100644
--- a/packages/nextjs/types/poll.ts
+++ b/packages/nextjs/types/poll.ts
@@ -10,7 +10,7 @@ export interface RawPoll {
maciPollId: bigint;
name: string;
encodedOptions: `0x${string}`;
- ipfsHash: string;
+ metadata: string;
pollContracts: {
poll: string;
messageProcessor: string;
@@ -23,21 +23,13 @@ export interface RawPoll {
tallyJsonCID: string;
}
-export interface Poll {
- id: bigint;
- maciPollId: bigint;
- name: string;
- encodedOptions: `0x${string}`;
- ipfsHash: string;
- pollContracts: {
- poll: string;
- messageProcessor: string;
- tally: string;
- };
- startTime: bigint;
- endTime: bigint;
- numOfOptions: bigint;
- options: readonly string[];
- tallyJsonCID: string;
+export interface Poll extends RawPoll {
status: PollStatus;
}
+
+export enum PollType {
+ NOT_SELECTED,
+ SINGLE_VOTE,
+ MULTIPLE_VOTE,
+ WEIGHTED_MULTIPLE_VOTE,
+}