Skip to content

Commit

Permalink
fix voting power popover (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoncalves authored Sep 17, 2024
1 parent 5afef04 commit 9624854
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
38 changes: 25 additions & 13 deletions src/app/proposals/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import { LatestProposalsTable } from '@/app/proposals/LatestProposalsTable'
import { MainContainer } from '@/components/MainContainer/MainContainer'
import { MetricsCard } from '@/components/MetricsCard'
import { Popover } from '@/components/Popover'
import { TxStatusMessage } from '@/components/TxStatusMessage/TxStatusMessage'
import { Paragraph, Span } from '@/components/Typography'
import { toFixed } from '@/lib/utils'
import { useRouter } from 'next/navigation'
import { FaRegQuestionCircle } from 'react-icons/fa'
import { useVotingPower } from './hooks/useVotingPower'
import { TxStatusMessage } from '@/components/TxStatusMessage/TxStatusMessage'

export default function Proposals() {
const { votingPower, canCreateProposal, threshold } = useVotingPower()

const { latestProposals } = useFetchLatestProposals()

return (
Expand All @@ -39,21 +40,32 @@ export default function Proposals() {
)
}

const PopoverContent = () => (
<>
<p className="text-[12px] font-bold mb-1">How is my voting power calculated?</p>
<p className="text-[12px]">
Your voting power is calculated as the number of tokens (votes) that have been delegated to you before
the proposal became active. You can delegate your votes to yourself, or to someone else. Others can also
delegate their votes to you.
</p>
</>
)
const PopoverContent = () => {
const router = useRouter()
return (
<>
<Paragraph size="small" className="font-bold mb-1">
How is my voting power calculated?
</Paragraph>
<Paragraph size="small">
Your voting power is determined by the amount of stRIF (staked RIF) you hold. To increase your voting
power,{' '}
<Span
className="text-primary text-[14px] hover:underline cursor-pointer"
onClick={() => router.push('/user?action=stake')}
>
stake RIF tokens now
</Span>
.
</Paragraph>
</>
)
}

const VotingPowerPopover = () => (
<Popover content={<PopoverContent />}>
<button className="flex flex-row">
<p>My voting power</p>
<Paragraph>My voting power</Paragraph>
<FaRegQuestionCircle className="ml-1" />
</button>
</Popover>
Expand Down
14 changes: 14 additions & 0 deletions src/app/user/Balances/StakeRIFCell.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import { useBalancesContext } from '@/app/user/Balances/context/BalancesContext'
import { cn } from '@/lib/utils'
import { useSearchParams } from 'next/navigation'
import { useEffect, useState } from 'react'

export const StakeRIFCell = () => {
const searchParams = useSearchParams()
const action = searchParams?.get('action')
const [openModal, setOpenModal] = useState(action === 'stake')

const { stakeModal, balances } = useBalancesContext()
const { balance } = balances['RIF']
const hasEnoughBalance = Number(balance) > 0

useEffect(() => {
if (openModal && hasEnoughBalance) {
stakeModal.openModal()
setOpenModal(false)
}
}, [openModal, hasEnoughBalance, stakeModal])

return (
<p
onClick={hasEnoughBalance ? stakeModal.openModal : undefined}
Expand Down
2 changes: 1 addition & 1 deletion src/app/user/Stake/Steps/stepsUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const textsDependingOnAction = {
previewText:
'You have enough allowance to stake. Preview your stake and make sure everything is correct!',
inProcess: 'STAKE IN PROCESS',
description: <>Congratulations and thank you for staking your RIF in the Collective.</>,
description: 'Congratulations and thank you for staking your RIF in the Collective.',
},
UNSTAKE: {
modalTitle: 'UNSTAKE ',
Expand Down

0 comments on commit 9624854

Please sign in to comment.