Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion client/app/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import { sepolia } from "viem/chains";
import { ArrowPathIcon , PlusIcon, TrashIcon} from "@heroicons/react/24/solid";
import { useRouter } from "next/navigation";
import ElectionInfoPopup from "../components/Modal/ElectionInfoPopup";
import {Loader} from "rsuite";

const CreatePage: React.FC = () => {
const router = useRouter();
const [isLoading,setIsLoading] = useState<boolean>(false);
const [selectedBallot, setSelectedBallot] = useState<number>(1);
const { switchChain } = useSwitchChain();
const { chain } = useAccount();
Expand Down Expand Up @@ -79,6 +81,7 @@ const CreatePage: React.FC = () => {
}
// passed candidates to the create election function
try {
setIsLoading(true);
await writeContractAsync({
address: ELECTION_FACTORY_ADDRESS,
abi: ElectionFactory,
Expand All @@ -96,6 +99,9 @@ const CreatePage: React.FC = () => {
console.error("Error creating election:", error);
toast.error(ErrorMessage(error));
}
finally{
setIsLoading(false);
}
};

const handleBallotChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
Expand Down Expand Up @@ -229,7 +235,7 @@ const CreatePage: React.FC = () => {
whileHover={{ scale: 1.02 }}
whileTap={{ scale: 0.98 }}
>
Create Election
{isLoading ? <Loader/>: "Create Election"}
</motion.button>
</form>
</motion.div>
Expand Down