From e4ab7520ae445fdd4990dce3685c72c807d73fe7 Mon Sep 17 00:00:00 2001 From: yu-zhen Date: Mon, 16 Sep 2024 16:16:52 +0900 Subject: [PATCH] chore: update info and ballot overview display --- .../src/components/BallotOverview.tsx | 36 +++++++------ packages/interface/src/components/Info.tsx | 51 +++++++++++-------- .../interface/src/components/VotingInfo.tsx | 2 +- .../interface/src/layouts/DefaultLayout.tsx | 10 ++-- packages/interface/src/pages/signup/index.tsx | 2 +- 5 files changed, 58 insertions(+), 43 deletions(-) diff --git a/packages/interface/src/components/BallotOverview.tsx b/packages/interface/src/components/BallotOverview.tsx index c6c5ddae..bac24c4b 100644 --- a/packages/interface/src/components/BallotOverview.tsx +++ b/packages/interface/src/components/BallotOverview.tsx @@ -1,5 +1,4 @@ import Link from "next/link"; -import { useRouter } from "next/router"; import { Heading } from "~/components/ui/Heading"; import { useBallot } from "~/contexts/Ballot"; @@ -9,29 +8,34 @@ import { EAppState } from "~/utils/types"; import { AddedProjects } from "./AddedProjects"; import { VotingUsage } from "./VotingUsage"; -export const BallotOverview = (): JSX.Element => { +interface IBallotOverviewProps { + title?: string; +} + +export const BallotOverview = ({ title = undefined }: IBallotOverviewProps): JSX.Element => { const { ballot } = useBallot(); - const { asPath } = useRouter(); const appState = useAppState(); return ( - -
- - {asPath.includes("ballot") ? "Summary" : "My Ballot"} - +
+ + {title && ( + + {title} + + )} -
- + +
); }; diff --git a/packages/interface/src/components/Info.tsx b/packages/interface/src/components/Info.tsx index 942daee2..fb952103 100644 --- a/packages/interface/src/components/Info.tsx +++ b/packages/interface/src/components/Info.tsx @@ -1,3 +1,4 @@ +import { useRouter } from "next/router"; import { tv } from "tailwind-variants"; import { createComponent } from "~/components/ui"; @@ -6,6 +7,7 @@ import { useMaci } from "~/contexts/Maci"; import { useAppState } from "~/utils/state"; import { EInfoCardState, EAppState } from "~/utils/types"; +import { BallotOverview } from "./BallotOverview"; import { InfoCard } from "./InfoCard"; import { RoundInfo } from "./RoundInfo"; import { VotingInfo } from "./VotingInfo"; @@ -25,12 +27,20 @@ const InfoContainer = createComponent( interface InfoProps { size: string; - showVotingInfo?: boolean; + showRoundInfo?: boolean; + showAppState?: boolean; + showBallot?: boolean; } -export const Info = ({ size, showVotingInfo = false }: InfoProps): JSX.Element => { +export const Info = ({ + size, + showRoundInfo = false, + showAppState = false, + showBallot = false, +}: InfoProps): JSX.Element => { const { votingEndsAt } = useMaci(); const appState = useAppState(); + const { asPath } = useRouter(); const steps = [ { @@ -62,27 +72,26 @@ export const Info = ({ size, showVotingInfo = false }: InfoProps): JSX.Element = return (
- {showVotingInfo && ( -
- + {showRoundInfo && } - {appState === EAppState.VOTING && } -
- )} + {showBallot && } - {steps.map( - (step) => - step.start && - step.end && ( - - ), - )} + {showRoundInfo && appState === EAppState.VOTING && } + + {showAppState && + steps.map( + (step) => + step.start && + step.end && ( + + ), + )}
); diff --git a/packages/interface/src/components/VotingInfo.tsx b/packages/interface/src/components/VotingInfo.tsx index c13d5345..444df2a0 100644 --- a/packages/interface/src/components/VotingInfo.tsx +++ b/packages/interface/src/components/VotingInfo.tsx @@ -15,7 +15,7 @@ export const VotingInfo = (): JSX.Element => { }, 1000); return ( -
+

Voting Ends In

{isLoading &&

Loading...

} diff --git a/packages/interface/src/layouts/DefaultLayout.tsx b/packages/interface/src/layouts/DefaultLayout.tsx index 3f57d5bb..562d09f2 100644 --- a/packages/interface/src/layouts/DefaultLayout.tsx +++ b/packages/interface/src/layouts/DefaultLayout.tsx @@ -2,7 +2,6 @@ import { GatekeeperTrait } from "maci-cli/sdk"; import { type ReactNode, type PropsWithChildren, useMemo } from "react"; import { useAccount } from "wagmi"; -import { BallotOverview } from "~/components/BallotOverview"; import Header from "~/components/Header"; import { Info } from "~/components/Info"; import { Notice } from "~/components/ui/Notice"; @@ -102,9 +101,12 @@ export const LayoutWithSidebar = ({ ...props }: ILayoutProps): JSX.Element => { sidebar="left" sidebarComponent={
- {showInfo && } - - {appState !== EAppState.APPLICATION && showBallot && address && isRegistered && } + {showSubmitButton && ballot.votes.length > 0 && (
diff --git a/packages/interface/src/pages/signup/index.tsx b/packages/interface/src/pages/signup/index.tsx index adb346cb..4e6ccc35 100644 --- a/packages/interface/src/pages/signup/index.tsx +++ b/packages/interface/src/pages/signup/index.tsx @@ -58,7 +58,7 @@ const SignupPage = (): JSX.Element => { {isConnected && !isRegistered && }
- +