-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from CarmineOptions/feature/user-voted
feat: show user voted
- Loading branch information
Showing
6 changed files
with
164 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import { AccountInterface } from "starknet"; | ||
import { Vote } from "../Vote/Vote"; | ||
import { VoteButtons } from "../Vote/Vote"; | ||
import { ProposalWithOpinion } from "../../calls/liveProposals"; | ||
|
||
type Props = { | ||
proposal: number; | ||
balance: bigint; | ||
proposal: ProposalWithOpinion; | ||
balance?: bigint; | ||
account?: AccountInterface; | ||
}; | ||
|
||
export const ProposalItem = ({ proposal, balance, account }: Props) => ( | ||
<div> | ||
<h3>Proposal {proposal}</h3> | ||
<h3>Proposal {proposal.propId}</h3> | ||
<div> | ||
<Vote proposal={proposal} balance={balance} account={account} /> | ||
<VoteButtons proposal={proposal} balance={balance} account={account} /> | ||
</div> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,37 @@ | ||
import { useQuery } from "react-query"; | ||
import { NoContent } from "../TableNoContent"; | ||
import ProposalTable from "./ProposalTable"; | ||
import { QueryKeys } from "../../queries/keys"; | ||
import { fetchLiveProposals } from "../../calls/liveProposals"; | ||
import { queryProposalsWithOpinions } from "../../calls/liveProposals"; | ||
import { LoadingAnimation } from "../Loading/Loading"; | ||
import { useAccount } from "../../hooks/useAccount"; | ||
import { useUserBalance } from "../../hooks/useUserBalance"; | ||
import { VE_CRM_ADDRESS } from "../../constants/amm"; | ||
|
||
export const Proposals = () => { | ||
const { isLoading, isError, data } = useQuery( | ||
[QueryKeys.liveProposals], | ||
fetchLiveProposals | ||
const account = useAccount(); | ||
const balance = useUserBalance(VE_CRM_ADDRESS); | ||
const { | ||
isLoading, | ||
isError, | ||
data: proposals, | ||
} = useQuery( | ||
[`proposals-${account?.address}`, account?.address], | ||
queryProposalsWithOpinions | ||
); | ||
|
||
if (isError) { | ||
return <p>Something went wrong, please try again later.</p>; | ||
} | ||
|
||
if (isLoading || !data) { | ||
if (isLoading || !proposals) { | ||
return <LoadingAnimation />; | ||
} | ||
|
||
if (data.length === 0) { | ||
if (proposals.length === 0) { | ||
return <NoContent text="No proposals are currently live" />; | ||
} | ||
|
||
return <ProposalTable activeData={data} />; | ||
return ( | ||
<ProposalTable proposals={proposals} account={account} balance={balance} /> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters