@@ -15,26 +15,32 @@ import { formatNumber } from "~/utils/formatNumber";
15
15
import { Dialog } from "~/components/ui/Dialog" ;
16
16
import { VotingEndsIn } from "./VotingEndsIn" ;
17
17
import { useProjectCount } from "~/features/projects/hooks/useProjects" ;
18
- import { config } from "~/config" ;
19
18
import { useIsMutating } from "@tanstack/react-query" ;
20
19
import { getQueryKey } from "@trpc/react-query" ;
21
20
import { api } from "~/utils/api" ;
22
21
import { getAppState } from "~/utils/state" ;
23
22
import dynamic from "next/dynamic" ;
23
+ import { useRoundToken } from "~/features/distribute/hooks/useAlloPool" ;
24
+ import { useCurrentRound } from "~/features/rounds/hooks/useRound" ;
24
25
25
26
function BallotOverview ( ) {
26
27
const router = useRouter ( ) ;
27
28
28
29
const { data : ballot } = useBallot ( ) ;
29
30
const isSaving = useIsMutating ( getQueryKey ( api . ballot . save ) ) ;
30
31
32
+ const round = useCurrentRound ( ) ;
33
+ const token = useRoundToken ( ) ;
31
34
const sum = sumBallot ( ballot ?. votes ) ;
32
35
33
36
const allocations = ballot ?. votes ?? [ ] ;
34
- const canSubmit = router . route === "/ ballot" && allocations . length ;
37
+ const canSubmit = router . route . includes ( " ballot") && allocations . length ;
35
38
36
39
const { data : projectCount } = useProjectCount ( ) ;
37
40
41
+ const tokenName = token . data ?. symbol ;
42
+ const maxVotesTotal = round . data ?. maxVotesTotal ?? 0 ;
43
+
38
44
const appState = getAppState ( ) ;
39
45
if ( appState === "RESULTS" )
40
46
return (
@@ -84,22 +90,22 @@ function BallotOverview() {
84
90
< BallotSection
85
91
title = {
86
92
< div className = "flex justify-between" >
87
- { config . tokenName } allocated:
93
+ { tokenName } allocated:
88
94
< div
89
95
className = { clsx ( "text-gray-900 dark:text-gray-300" , {
90
- [ "text-primary-500" ] : sum > config . votingMaxTotal ,
96
+ [ "text-primary-500" ] : sum > maxVotesTotal ,
91
97
} ) }
92
98
>
93
- { formatNumber ( sum ) } { config . tokenName }
99
+ { formatNumber ( sum ) } { tokenName }
94
100
</ div >
95
101
</ div >
96
102
}
97
103
>
98
- < Progress value = { sum } max = { config . votingMaxTotal } />
104
+ < Progress value = { sum } max = { maxVotesTotal } />
99
105
< div className = "flex justify-between text-xs" >
100
106
< div > Total</ div >
101
107
< div >
102
- { formatNumber ( config . votingMaxTotal ?? 0 ) } { config . tokenName }
108
+ { formatNumber ( maxVotesTotal ?? 0 ) } { tokenName }
103
109
</ div >
104
110
</ div >
105
111
</ BallotSection >
@@ -112,7 +118,7 @@ function BallotOverview() {
112
118
Adding to ballot...
113
119
</ Button >
114
120
) : canSubmit ? (
115
- < SubmitBallotButton disabled = { sum > config . votingMaxTotal } />
121
+ < SubmitBallotButton disabled = { sum > maxVotesTotal } />
116
122
) : allocations . length ? (
117
123
< Button className = "w-full" variant = "primary" as = { Link } href = { "/ballot" } >
118
124
View ballot
0 commit comments