Skip to content

Commit

Permalink
Add logout button for al census types
Browse files Browse the repository at this point in the history
  • Loading branch information
elboletaire authored and gerouvi committed Jun 28, 2024
1 parent e43778b commit 7d1794d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/components/Process/Aside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import { dotobject, ElectionStatus, formatUnits, PublishedElection } from '@vocd
import { TFunction } from 'i18next'
import { Trans, useTranslation } from 'react-i18next'
import { Link as ReactRouterLink } from 'react-router-dom'
import { useAccount } from 'wagmi'
import { useAccount, useDisconnect } from 'wagmi'
import { CensusMeta } from './Census/CensusType'

const results = (result: number, decimals?: number) =>
decimals ? parseInt(formatUnits(BigInt(result), decimals), 10) : result

const ProcessAside = () => {
const { t } = useTranslation()
const { disconnect } = useDisconnect()
const {
election,
connected,
Expand All @@ -23,7 +24,7 @@ const ProcessAside = () => {
loading: { voting },
} = useElection()
const { isConnected } = useAccount()
const { env } = useClient()
const { env, clear } = useClient()

if (!election || !(election instanceof PublishedElection)) return null

Expand Down Expand Up @@ -157,7 +158,7 @@ const ProcessAside = () => {
</Flex>
)}
</Card>
{connected && (
{(connected || isConnected) && (
<Box
alignSelf='center'
sx={{
Expand All @@ -177,6 +178,19 @@ const ProcessAside = () => {
mb={{ base: 10, md: 0 }}
>
<SpreadsheetAccess />
{isConnected && (
<Button
variant='text'
textDecor='underline'
_hover={{ textDecor: 'none' }}
onClick={() => {
disconnect()
clear()
}}
>
{t('cc.spreadsheet.logout')}
</Button>
)}
</Box>
)}
</>
Expand Down

0 comments on commit 7d1794d

Please sign in to comment.