@@ -10,6 +10,7 @@ import { toast } from 'sonner';
1010
1111interface VoteState {
1212 isLoading : boolean ;
13+ voteResult : boolean ;
1314 deadline : number | null ;
1415 votes : Record < string , [ 'yes' | 'no' , string ] > ;
1516 yesVotesCount : number | null ;
@@ -31,7 +32,7 @@ function useVoteContainer(): UseVoteContainer {
3132 const { viewFunction } = useNear ( ) ;
3233
3334 const [ deadline , setDeadline ] = useState < number | null > ( null ) ;
34- // const [voteFinishedAt, setVoteFinishedAt ] = useState<number | null>(null );
35+ const [ voteResult , setVoteResult ] = useState ( false ) ;
3536 const [ votes , setVotes ] = useState < Record < string , [ 'yes' | 'no' , string ] > > ( { } ) ;
3637 const [ votedStakeAmount , setVotedStakeAmount ] = useState ( Big ( 0 ) ) ;
3738 const [ totalVotedStakeAmount , setTotalVotedStakeAmount ] = useState ( Big ( 0 ) ) ;
@@ -60,14 +61,14 @@ function useVoteContainer(): UseVoteContainer {
6061 setTotalVotedStakeAmount ( Big ( data [ 2 ] ) ) ;
6162 } , [ viewFunction ] ) ;
6263
63- // const getResult = useCallback(async () => {
64- // const data = await viewFunction({
65- // contractId: contractId,
66- // method: 'get_result',
67- // });
68- // logger.debug('get_result', data);
69- // setVoteFinishedAt (data || null );
70- // }, [viewFunction]);
64+ const getResult = useCallback ( async ( ) => {
65+ const data = await viewFunction ( {
66+ contractId : contractId ,
67+ method : 'get_result' ,
68+ } ) ;
69+ logger . debug ( 'get_result' , data ) ;
70+ setVoteResult ( data || false ) ;
71+ } , [ viewFunction ] ) ;
7172
7273 const getVotes = useCallback ( async ( ) => {
7374 const data = await viewFunction ( {
@@ -98,7 +99,7 @@ function useVoteContainer(): UseVoteContainer {
9899 const { isLoading, error } = useSWR (
99100 'vote_data' ,
100101 async ( ) => {
101- const promises = Promise . all ( [ getTotalVotedStake ( ) , getVotes ( ) , getDeadline ( ) ] ) ;
102+ const promises = Promise . all ( [ getTotalVotedStake ( ) , getVotes ( ) , getDeadline ( ) , getResult ( ) ] ) ;
102103 return await promises ;
103104 } ,
104105 // {
@@ -119,6 +120,7 @@ function useVoteContainer(): UseVoteContainer {
119120
120121 return {
121122 isLoading,
123+ voteResult,
122124 deadline,
123125 votes,
124126 yesVotesCount,
0 commit comments