diff --git a/packages/interface/src/layouts/BaseLayout.tsx b/packages/interface/src/layouts/BaseLayout.tsx index 26f62b6b..de3d885d 100644 --- a/packages/interface/src/layouts/BaseLayout.tsx +++ b/packages/interface/src/layouts/BaseLayout.tsx @@ -3,6 +3,7 @@ import Head from "next/head"; import { useRouter } from "next/router"; import { useTheme } from "next-themes"; import { type PropsWithChildren, createContext, useContext, useEffect, useCallback, useMemo } from "react"; +import { toast } from "sonner"; import { tv } from "tailwind-variants"; import { useAccount } from "wagmi"; @@ -62,9 +63,12 @@ export const BaseLayout = ({ const { isRegistered } = useMaci(); const manageDisplay = useCallback(() => { - if ((requireAuth && !address && !isConnecting) || (requireRegistration && !isRegistered)) { + if (requireAuth && !address && !isConnecting) { router.push("/"); } + if (requireRegistration && !isRegistered) { + toast.error("You must sign up to access the full information on this page."); + } }, [requireAuth, address, isConnecting, requireRegistration, isRegistered, router]); useEffect(() => { diff --git a/packages/interface/src/pages/rounds/[pollId]/ballot/index.tsx b/packages/interface/src/pages/rounds/[pollId]/ballot/index.tsx index aa1fcf2d..aae0bae0 100644 --- a/packages/interface/src/pages/rounds/[pollId]/ballot/index.tsx +++ b/packages/interface/src/pages/rounds/[pollId]/ballot/index.tsx @@ -1,9 +1,7 @@ import clsx from "clsx"; import Link from "next/link"; -import { useRouter } from "next/router"; -import { useEffect, useState, useMemo, useCallback } from "react"; +import { useCallback, useState, useMemo } from "react"; import { useFormContext } from "react-hook-form"; -import { useAccount } from "wagmi"; import { Button } from "~/components/ui/Button"; import { Dialog } from "~/components/ui/Dialog"; @@ -154,21 +152,13 @@ interface IBallotPageProps { } const BallotPage = ({ pollId }: IBallotPageProps): JSX.Element => { - const { address, isConnecting } = useAccount(); const { getBallot, sumBallot } = useBallot(); const { getRoundByPollId } = useRound(); - const router = useRouter(); const roundState = useRoundState({ pollId }); const round = useMemo(() => getRoundByPollId(pollId), [pollId, getRoundByPollId]); const ballot = useMemo(() => getBallot(pollId), [round?.pollId, getBallot]); - useEffect(() => { - if (!address && !isConnecting) { - router.push("/"); - } - }, [address, isConnecting, router]); - const handleSubmit = useCallback(() => { sumBallot(); }, [sumBallot]);