Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with proposal warning banner #390

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions apps/web/src/pages/dao/[network]/[token]/vote/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { CACHE_TIMES } from 'src/constants/cacheTimes'
import { PUBLIC_DEFAULT_CHAINS } from 'src/constants/defaultChains'
import SWR_KEYS from 'src/constants/swrKeys'
import {
ProposalState,
getProposalState,
} from 'src/data/contract/requests/getProposalState'
import { SDK } from 'src/data/subgraph/client'
Expand All @@ -39,13 +38,6 @@ import { useChainStore } from 'src/stores/useChainStore'
import { propPageWrapper } from 'src/styles/Proposals.css'
import { AddressType } from 'src/typings'

const ACTIVE_PROPOSAL_STATES = [
ProposalState.Active,
ProposalState.Pending,
ProposalState.Queued,
ProposalState.Succeeded,
]

export interface VotePageProps {
proposalId: string
daoName: string
Expand Down Expand Up @@ -121,8 +113,10 @@ const VotePage: NextPageWithLayout<VotePageProps> = ({
const isBadActor = BAD_ACTORS.some((baddie) =>
isAddressEqual(proposal.proposer, baddie as AddressType)
)
const isActive = proposalState && ACTIVE_PROPOSAL_STATES.includes(proposalState)
const isPossibleDrain = balance?.value && checkDrain(proposal.values, balance?.value)
const isActive = proposalState ? isProposalOpen(proposalState) : false
const isPossibleDrain = balance?.value
? checkDrain(proposal.values, balance?.value)
: false
const warn = isActive && (isBadActor || isPossibleDrain)

return (
Expand Down
Loading