Skip to content

Commit

Permalink
Show election title on vote package
Browse files Browse the repository at this point in the history
  • Loading branch information
selankon committed Aug 8, 2024
1 parent af6b12d commit 7fd2225
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/components/Envelope/Detail.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import voteImage from '/images/vocdoni-vote.png'
import { Flex, Image, Link, Tab, TabList, TabPanel, TabPanels, Text } from '@chakra-ui/react'
import { VoteInfoResponse } from '@vocdoni/sdk'
import { PublishedElection, VoteInfoResponse } from '@vocdoni/sdk'

Check failure on line 3 in src/components/Envelope/Detail.tsx

View workflow job for this annotation

GitHub Actions / build-dev-explorer

'"@vocdoni/sdk"' has no exported member named 'VoteInfoResponse'. Did you mean 'IVoteInfoResponse'?

Check failure on line 3 in src/components/Envelope/Detail.tsx

View workflow job for this annotation

GitHub Actions / build-stg-explorer

'"@vocdoni/sdk"' has no exported member named 'VoteInfoResponse'. Did you mean 'IVoteInfoResponse'?
import { formatDistance } from 'date-fns'
import { Trans, useTranslation } from 'react-i18next'
import { generatePath, Link as RouterLink } from 'react-router-dom'
Expand All @@ -10,8 +10,8 @@ import { RoutePath } from '~constants'
import { RouteParamsTabs } from '~components/Layout/RouteParamsTabs'
import { DetailsGrid, GridItemProps } from '~components/Layout/DetailsGrid'
import { processIdGridItem } from '~components/Transactions/TxDetails/SpecificTxDetails'
import { Envelope } from '@vocdoni/chakra-components'
import { ElectionProvider } from '@vocdoni/react-providers'
import { Envelope, VotePackageType } from '@vocdoni/chakra-components'

Check failure on line 13 in src/components/Envelope/Detail.tsx

View workflow job for this annotation

GitHub Actions / build-dev-explorer

Module '"@vocdoni/chakra-components"' has no exported member 'Envelope'.

Check failure on line 13 in src/components/Envelope/Detail.tsx

View workflow job for this annotation

GitHub Actions / build-dev-explorer

Module '"@vocdoni/chakra-components"' has no exported member 'VotePackageType'.

Check failure on line 13 in src/components/Envelope/Detail.tsx

View workflow job for this annotation

GitHub Actions / build-stg-explorer

Module '"@vocdoni/chakra-components"' has no exported member 'Envelope'.

Check failure on line 13 in src/components/Envelope/Detail.tsx

View workflow job for this annotation

GitHub Actions / build-stg-explorer

Module '"@vocdoni/chakra-components"' has no exported member 'VotePackageType'.
import { ElectionProvider, useElection } from '@vocdoni/react-providers'

/**
* Show envelope content
Expand Down Expand Up @@ -62,7 +62,7 @@ const EnvelopeDetail = ({
<TabPanels>
<TabPanel>
<ElectionProvider id={envelope.electionID}>
<Envelope votePackage={envelope.package} />
<VotePackage votePackage={envelope.package} />
</ElectionProvider>
</TabPanel>
<TabPanel>
Expand All @@ -77,6 +77,27 @@ const EnvelopeDetail = ({
)
}

const VotePackage = ({ votePackage }: { votePackage: VotePackageType }) => {
const { t } = useTranslation()
const { election } = useElection()
if (!election || !(election instanceof PublishedElection)) return null

return (
<>
<Envelope votePackage={votePackage} />
<Text fontSize={'sm'} as='i'>
<Trans
i18nKey={'envelopes.from_election_title'}
components={{
a: <Link as={RouterLink} to={generatePath(RoutePath.Process, { pid: election.id, tab: null })} />,
}}
values={{ title: election.title.default }}
/>
</Text>
</>
)
}

const EnvelopeDetailsGrid = (envelope: VoteInfoResponse) => {
const { t } = useTranslation()

Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"encryption_keys": "Claus de xifrat",
"envelope_number": "Envelope nº {{num}}",
"envelope_weight": "Pes del sobre",
"from_election_title": "From election: <a>{{ title }}</a>",
"not_found": "Sobre no trobat",
"on_transaction": "On Transaction",
"overwrite_count": "Nombre de sobrescritures",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"encryption_keys": "Encryption keys",
"envelope_number": "Envelope nº {{num}}",
"envelope_weight": "Envelope weight",
"from_election_title": "From election: <a>{{title}}</a>",
"not_found": "Envelope not found",
"on_transaction": "On Transaction",
"overwrite_count": "Overwrite count",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"encryption_keys": "Claves de cifrado",
"envelope_number": "Envelope nº {{num}}",
"envelope_weight": "Peso del sobre",
"from_election_title": "From election: <a>{{ title }}</a>",
"not_found": "Sobre no encontrado",
"on_transaction": "On Transaction",
"overwrite_count": "Conteo de sobrescritura",
Expand Down

0 comments on commit 7fd2225

Please sign in to comment.