Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2310261
Blind csp implementation (#4)
selankon Sep 4, 2024
adf3567
Upgrade packages (#11)
selankon Oct 17, 2024
33f582f
Add VotingVoteModal (#12)
selankon Oct 17, 2024
9b02376
Implement Multielection
selankon Oct 9, 2024
2988e9c
Implement Multielection VoteButton
selankon Oct 10, 2024
8edc360
Fix styles
selankon Oct 10, 2024
ff033f7
Create a submit form controller
selankon Oct 11, 2024
c407b1e
Fix global submit validation
selankon Oct 11, 2024
555beab
Add validator
selankon Oct 11, 2024
ebb20cf
Fix unique key prop
selankon Oct 11, 2024
2e56db8
Fix Layout issues
selankon Oct 11, 2024
626bfc1
Move MultiElection components to ui components
selankon Oct 14, 2024
78a0980
Use new version of MultiProcess provider
selankon Oct 16, 2024
b840340
Fix not render first election
selankon Oct 17, 2024
067cf7d
Show renderWith elections results
selankon Oct 17, 2024
c4ede87
Hide vote menu when is multiprocess
selankon Oct 17, 2024
e803ca5
Unify VoteButton layout
selankon Oct 18, 2024
d82dee3
Recover voting modals
selankon Oct 18, 2024
53c55c8
Fix ConfirmVoteModal.tsx
selankon Oct 18, 2024
c788c60
Add confirmContents to isRenderWith elections
selankon Oct 21, 2024
0a17664
Hide vote button if voted
selankon Oct 21, 2024
b56bb95
Implement multielection voted
selankon Oct 22, 2024
5af2740
Fix confirm modal answers
selankon Oct 22, 2024
1010e38
Add not able to vote on confirmation modal
selankon Oct 22, 2024
ed3d28c
Use strict false
selankon Oct 31, 2024
78ad9d3
Fix no default process
selankon Nov 6, 2024
94213c4
Properly import renderwith
selankon Nov 6, 2024
ad79285
Fix isWeighted
selankon Nov 11, 2024
d1f324e
Fix vote modals
selankon Nov 11, 2024
fb34703
Fix use root election context properly
selankon Nov 12, 2024
f920fa0
Add translations
selankon Nov 12, 2024
09ec70f
Change spreadsheet acces theme
selankon Nov 13, 2024
70cbe70
Fix alert overflow
selankon Nov 13, 2024
d2b3ac8
Update results on renderwith elections
selankon Nov 15, 2024
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
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
"@emotion/styled": "^11.10.6",
"@rainbow-me/rainbowkit": "^2.1.2",
"@tanstack/react-query": "^5.40.1",
"@vocdoni/chakra-components": "~0.8.3",
"@vocdoni/sdk": "~0.8.1",
"date-fns": "^3.6.0",
"@vocdoni/chakra-components": "~0.9.6",
"@vocdoni/sdk": "~0.9.1",
"date-fns": "^4.1.0",
"ethers": "^5.7.2",
"framer-motion": "^11.2.10",
"i18next": "^23.11.5",
"i18next-browser-languagedetector": "^8.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.51.5",
"react-i18next": "^14.1.2",
"react-i18next": "^15.0.3",
"react-icons": "^5.2.1",
"react-markdown": "^9.0.1",
"react-player": "^2.16.0",
Expand Down
Binary file added public/assets/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/vocdoni.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ import { VocdoniEnvironment } from '~constants'
import { translations } from '~i18n/components'
import { clientToSigner } from '~util/wagmi-adapters'
import { RoutesProvider } from './router'
import { ExternalProvider, JsonRpcFetchFunc } from '@ethersproject/providers'

export const App = () => {
const { data } = useWalletClient()
const { t } = useTranslation()

let signer: Signer = {} as Signer
if (data) {
signer = clientToSigner(data)
signer = clientToSigner({
transport: data.transport as ExternalProvider | JsonRpcFetchFunc,
chain: data.chain,
account: data.account,
})
}

return (
Expand Down
23 changes: 14 additions & 9 deletions src/components/Process/Aside.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box, Button, Card, Flex, FlexProps, Link, Text } from '@chakra-ui/react'
import { ConnectButton } from '@rainbow-me/rainbowkit'
import { VoteButton as CVoteButton, environment, SpreadsheetAccess, VoteWeight } from '@vocdoni/chakra-components'
import { environment, SpreadsheetAccess, VoteButton as CVoteButton, VoteWeight } from '@vocdoni/chakra-components'
import { useClient, useElection } from '@vocdoni/react-providers'
import { dotobject, ElectionStatus, formatUnits, PublishedElection } from '@vocdoni/sdk'
import { TFunction } from 'i18next'
Expand All @@ -25,14 +25,16 @@ const ProcessAside = () => {
} = useElection()
const { isConnected } = useAccount()
const { env, clear } = useClient()

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

const census: CensusMeta = dotobject(election?.meta || {}, 'census')

const isMultiProcess = !!election.get('multiprocess')
const renderVoteMenu =
voted ||
(voting && election?.electionType.anonymous) ||
(hasOverwriteEnabled(election) && isInCensus && votesLeft > 0 && voted)
!isMultiProcess &&
(voted ||
(voting && election?.electionType.anonymous) ||
(hasOverwriteEnabled(election) && isInCensus && votesLeft > 0 && voted))

const showVoters =
election?.status !== ElectionStatus.CANCELED &&
Expand Down Expand Up @@ -197,7 +199,8 @@ const ProcessAside = () => {
)
}

export const VoteButton = ({ ...props }: FlexProps) => {
type VoteButtonProps = FlexProps
export const VoteButton = (props: VoteButtonProps) => {
const { t } = useTranslation()
const { election, connected, isAbleToVote, isInCensus } = useElection()
const { isConnected } = useAccount()
Expand All @@ -215,7 +218,8 @@ export const VoteButton = ({ ...props }: FlexProps) => {
return null
}

const isWeighted = election?.census.weight !== election?.census.size
const isWeighted = Number(election?.census.weight) !== election?.census.size
const isBlindCsp = census?.type === 'csp' && election?.meta.csp?.service === 'vocdoni-blind-csp'

return (
<Flex
Expand All @@ -228,7 +232,7 @@ export const VoteButton = ({ ...props }: FlexProps) => {
px={{ base: 3, lg2: 0 }}
{...props}
>
{census?.type !== 'spreadsheet' && !connected && (
{census?.type !== 'spreadsheet' && !isBlindCsp && !connected && (
<ConnectButton.Custom>
{({ account, chain, openConnectModal, authenticationStatus, mounted }) => {
const ready = mounted && authenticationStatus !== 'loading'
Expand Down Expand Up @@ -269,7 +273,8 @@ export const VoteButton = ({ ...props }: FlexProps) => {
mb={4}
sx={{
'&::disabled': {
opacity: '0.8',
// opacity: '0.8',
display: 'none',
},
}}
/>
Expand Down
42 changes: 42 additions & 0 deletions src/components/Process/BlindCSPConnect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { useCallback, useState } from 'react'
import { useClient, useElection } from '@vocdoni/react-providers'
import { VocdoniSDKClient } from '@vocdoni/sdk'
import { Wallet } from 'ethers'
import { Button } from '@chakra-ui/react'
import { Trans } from 'react-i18next'

const BlindCSPConnect = () => {
const [isLoading, setIsLoading] = useState(false)
const { env } = useClient()
const { election, setClient, connected, client: cl } = useElection()
const connect = useCallback(() => {
setIsLoading(true)
try {
setClient(
new VocdoniSDKClient({
env,
wallet: Wallet.createRandom(),
electionId: election?.id,
})
)
} catch (e) {
console.warn('Error trying to login with private key ', e)
// this should not be required... if it fails, the client should already be the one set
setClient(cl)
} finally {
setIsLoading(false)
}
}, [env, election?.id])

return (
<>
{(!cl.wallet || Object.keys(cl.wallet).length === 0) && (
<Button w={'full'} onClick={connect} isLoading={isLoading}>
<Trans i18nKey={'blindcsp.connect'}>Demo connect</Trans>
</Button>
)}
</>
)
}

export default BlindCSPConnect
2 changes: 1 addition & 1 deletion src/components/Process/CardDetailed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ProcessCardDetailed = ({ election }: Props) => {
<ElectionProvider election={election}>
<Card variant='detailed'>
<CardBody>
<Link to={`/processes/${enforceHexPrefix(election.id)}`}>
<Link to={`/${enforceHexPrefix(election.id)}`}>
<ProcessDetailedCardTitle />
<Box>
<ElectionStatusBadge />
Expand Down
Loading