From dcde0b36168748df2eb3a7883893c48ac70574b0 Mon Sep 17 00:00:00 2001 From: selankon Date: Thu, 8 Aug 2024 10:46:41 +0200 Subject: [PATCH 01/10] Improve envelope page --- src/components/Envelope/Detail.tsx | 175 ++++++++++++------ .../TxDetails/SpecificTxDetails.tsx | 2 +- src/constants.ts | 4 +- src/pages/envelope.tsx | 3 +- src/pages/verify.tsx | 3 +- 5 files changed, 123 insertions(+), 64 deletions(-) diff --git a/src/components/Envelope/Detail.tsx b/src/components/Envelope/Detail.tsx index 00774448..6e07899e 100644 --- a/src/components/Envelope/Detail.tsx +++ b/src/components/Envelope/Detail.tsx @@ -1,23 +1,32 @@ import voteImage from '/images/vocdoni-vote.png' -import { Flex, Heading, Image, Link, Text } from '@chakra-ui/react' +import { Flex, Image, Link, Tab, TabList, TabPanel, TabPanels, Text } from '@chakra-ui/react' import { VoteInfoResponse } from '@vocdoni/sdk' import { formatDistance } from 'date-fns' import { Trans, useTranslation } from 'react-i18next' import { generatePath, Link as RouterLink } from 'react-router-dom' -import { CopyButton } from '~components/Layout/CopyButton' -import ShowRawButton from '~components/Layout/ShowRawButton' +import { CopyButton, ReducedTextAndCopy } from '~components/Layout/CopyButton' +import { RawContentBox } from '~components/Layout/ShowRawButton' 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' -const EnvelopeDetail = (envelope: VoteInfoResponse) => { +/** + * Show envelope content + * @param route this is needed to use the RoutedParamsTabs + * @param envelope envelope data + * @constructor + */ +const EnvelopeDetail = ({ + route, + ...envelope +}: { route: RoutePath.Envelope | RoutePath.Verify } & VoteInfoResponse) => { const { t } = useTranslation() - const emitted = formatDistance(new Date(envelope.date), new Date(), { addSuffix: true }) - const encKeys = envelope.encryptionKeys?.join(',') return ( - - Envelope Detail - {t('envelopes.vote_registered')} @@ -38,58 +47,106 @@ const EnvelopeDetail = (envelope: VoteInfoResponse) => { - - - - Emitted {{ emitted: emitted }} - - - {encKeys && encKeys?.length > 0 && ( - - - Encryption keys: {{ encKeys: encKeys }} - - - )} - {envelope.overwriteCount > 0 && ( - - - Overwrite count: {{ overwriteCount: envelope.overwriteCount }} - - - )} - - - Envelope weight: {{ weight: envelope.weight }} - - - - - ), - }} - values={{ block: envelope.blockHeight }} - /> - - - , - }} - values={{ pid: envelope.electionID }} - /> - - - + + + + Envelope Content + + + Details + + + Raw + + + + + + + + + + + + + + + + ) } +const EnvelopeDetailsGrid = (envelope: VoteInfoResponse) => { + const { t } = useTranslation() + + const emitted = formatDistance(new Date(envelope.date), new Date(), { addSuffix: true }) + const encKeys = envelope.encryptionKeys?.join(',') + + const details: GridItemProps[] = [ + { + label: t('envelopes.emitted', { defaultValue: 'Emitted' }), + children: {emitted}, + }, + ...(envelope.overwriteCount > 0 + ? [ + { + label: t('envelopes.overwrite_count', { defaultValue: 'Overwrite count' }), + children: envelope.overwriteCount, + }, + ] + : []), + { + label: 'Overwrite count', + children: {envelope.overwriteCount}, + }, + ...(encKeys && encKeys?.length > 0 + ? [ + { + label: t('envelopes.encryption_keys', { defaultValue: 'Encryption keys' }), + children: encKeys, + }, + ] + : []), + { + label: t('envelopes.envelope_weight', { defaultValue: 'Envelope weight' }), + children: {envelope.weight}, + }, + { + label: t('envelopes.committed_in_block', { defaultValue: 'Committed in block' }), + children: ( + + {envelope.blockHeight} + + ), + }, + { + label: t('envelopes.on_transaction', { defaultValue: 'On Transaction' }), + children: ( + + {envelope.txHash} + + ), + }, + { ...processIdGridItem(envelope.electionID, t) }, + ] + return +} + export default EnvelopeDetail diff --git a/src/components/Transactions/TxDetails/SpecificTxDetails.tsx b/src/components/Transactions/TxDetails/SpecificTxDetails.tsx index 9c9f966a..1924302f 100644 --- a/src/components/Transactions/TxDetails/SpecificTxDetails.tsx +++ b/src/components/Transactions/TxDetails/SpecificTxDetails.tsx @@ -20,7 +20,7 @@ import { SmallOrganizationCard } from '~components/Organizations/Card' import { RoutePath } from '~constants' import { b64ToHex } from '~utils/objects' -const processIdGridItem = (processId: string, t: TFunction): GridItemProps => { +export const processIdGridItem = (processId: string, t: TFunction): GridItemProps => { return { label: t('transactions.belongs_to_process', { defaultValue: 'Belongs to process' }), children: ( diff --git a/src/constants.ts b/src/constants.ts index 808b7a85..f83bece6 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -22,7 +22,7 @@ export enum RoutePath { Base = '/', Block = '/block/:height/:tab?/:page?', BlocksList = '/blocks/:page?', - Envelope = '/envelope/:verifier', + Envelope = '/envelope/:verifier/:tab?', Organization = '/organization/:pid/:tab?/:page?', OrganizationsList = '/organizations/:page?/:query?', Process = '/process/:pid/:tab?', @@ -32,7 +32,7 @@ export enum RoutePath { TransactionByHashOrHeight = '/transactions/id/:hashOrHeight', Validator = '/validator/:address/:tab?', Validators = '/validators', - Verify = '/verify/:verifier?', + Verify = '/verify/:verifier?/:tab?', } // old explorer route paths (used by RouteRedirector) diff --git a/src/pages/envelope.tsx b/src/pages/envelope.tsx index 83c6c977..c5182483 100644 --- a/src/pages/envelope.tsx +++ b/src/pages/envelope.tsx @@ -1,10 +1,11 @@ import { VoteInfoResponse } from '@vocdoni/sdk' import { useLoaderData } from 'react-router-dom' import EnvelopeDetail from '~components/Envelope/Detail' +import { RoutePath } from '~constants' const Envelope = () => { const envelope = useLoaderData() as VoteInfoResponse - return + return } export default Envelope diff --git a/src/pages/verify.tsx b/src/pages/verify.tsx index 0d860ad8..082290d4 100644 --- a/src/pages/verify.tsx +++ b/src/pages/verify.tsx @@ -5,6 +5,7 @@ import { Loading } from '~components/Layout/Loading' import { Flex, Heading } from '@chakra-ui/react' import { Trans } from 'react-i18next' import EnvelopeDetail from '~components/Envelope/Detail' +import { RoutePath } from '~constants' const Verify = () => { const { verifier }: { verifier?: string } = useParams() @@ -31,7 +32,7 @@ const Verify = () => { Envelope not found{' '} )} - {data && } + {data && } ) } From 3c2f8b6f98d58af29964affedcb52c57f0820bf1 Mon Sep 17 00:00:00 2001 From: selankon Date: Thu, 8 Aug 2024 10:53:45 +0200 Subject: [PATCH 02/10] Fix translations --- src/components/Envelope/Detail.tsx | 2 +- src/components/Process/Detail.tsx | 8 ++++---- src/i18n/locales/ca.json | 24 +++++++++++------------- src/i18n/locales/en.json | 22 ++++++++++------------ src/i18n/locales/es.json | 24 +++++++++++------------- 5 files changed, 37 insertions(+), 43 deletions(-) diff --git a/src/components/Envelope/Detail.tsx b/src/components/Envelope/Detail.tsx index 6e07899e..79d3e238 100644 --- a/src/components/Envelope/Detail.tsx +++ b/src/components/Envelope/Detail.tsx @@ -50,7 +50,7 @@ const EnvelopeDetail = ({ - Envelope Content + Envelope Content Details diff --git a/src/components/Process/Detail.tsx b/src/components/Process/Detail.tsx index 8e27a730..40d915e3 100644 --- a/src/components/Process/Detail.tsx +++ b/src/components/Process/Detail.tsx @@ -280,7 +280,7 @@ const EnvelopeCard = ({ envelope, count }: { envelope: VoteSummary; count: numbe - + Envelope nº {{ num: count }} @@ -295,7 +295,7 @@ const EnvelopeCard = ({ envelope, count }: { envelope: VoteSummary; count: numbe as={RouterLink} to={generatePath(RoutePath.Block, { height: envelope.blockHeight.toString(), tab: null, page: null })} > - + Block {{ height: envelope.blockHeight }} @@ -307,12 +307,12 @@ const EnvelopeCard = ({ envelope, count }: { envelope: VoteSummary; count: numbe tab: null, })} > - + Transaction: {{ transactionIndex: envelope.transactionIndex }} - Details + Details diff --git a/src/i18n/locales/ca.json b/src/i18n/locales/ca.json index 73c770f8..b8806aea 100644 --- a/src/i18n/locales/ca.json +++ b/src/i18n/locales/ca.json @@ -24,22 +24,20 @@ "election": { "no_votes_yet": "Encara no hi ha vots!" }, - "envelope": { - "block": "Bloc {{height}}", - "details": "Detalls", - "envelope_number": "Sobre nº {{num}}", - "tx_number": "Transacció: {{transactionIndex}}" - }, "envelopes": { - "belongs_to_process": "Pertany al procés {{pid}}", - "committed_in_block": "Registrat en el bloc #{{block}}", - "emitted": "Emès {{emitted}}", - "encryption_keys": "Claus de xifrat: {{encKeys}}", - "envelope_detail": "Detall del sobre", - "envelope_weight": "Pes del sobre: {{weight}}", + "block": "Block", + "committed_in_block": "Registrat en el bloc", + "content": "Envelope Content", + "details": "Details", + "emitted": "Emès", + "encryption_keys": "Claus de xifrat", + "envelope_number": "Envelope nº {{num}}", + "envelope_weight": "Pes del sobre", "not_found": "Sobre no trobat", - "overwrite_count": "Nombre de sobrescritures: {{overwriteCount}}", + "on_transaction": "On Transaction", + "overwrite_count": "Nombre de sobrescritures", "registered_correctly": "El vot s'ha registrat correctament", + "tx_number": "Transaction: {{transactionIndex}}", "verifier_code": "Codi de verificació", "vote_registered": "Vot registrat" }, diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 3c3b6bac..98b279fd 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -23,22 +23,20 @@ "election": { "no_votes_yet": "No votes yet!" }, - "envelope": { - "block": "Block {{height}}", - "details": "Details", - "envelope_number": "Envelope nº {{num}}", - "tx_number": "Transaction: {{transactionIndex}}" - }, "envelopes": { - "belongs_to_process": "Belongs to process {{pid}}", - "committed_in_block": "Commited in block #{{block}}", + "block": "Block", + "committed_in_block": "Commited in block", + "content": "Envelope Content", + "details": "Details", "emitted": "Emitted {{emitted}}", - "encryption_keys": "Encryption keys: {{encKeys}}", - "envelope_detail": "Envelope Detail", - "envelope_weight": "Envelope weight: {{weight}}", + "encryption_keys": "Encryption keys", + "envelope_number": "Envelope nº {{num}}", + "envelope_weight": "Envelope weight", "not_found": "Envelope not found", - "overwrite_count": "Overwrite count: {{overwriteCount}}", + "on_transaction": "On Transaction", + "overwrite_count": "Overwrite count", "registered_correctly": "Vote has been registered correctly", + "tx_number": "Transaction: {{transactionIndex}}", "verifier_code": "Verifier code", "vote_registered": "Vote registered" }, diff --git a/src/i18n/locales/es.json b/src/i18n/locales/es.json index bb2801de..2e625cca 100644 --- a/src/i18n/locales/es.json +++ b/src/i18n/locales/es.json @@ -24,22 +24,20 @@ "election": { "no_votes_yet": "¡Aún no hay votos!" }, - "envelope": { - "block": "Bloque {{height}}", - "details": "Detalles", - "envelope_number": "Sobre nº {{num}}", - "tx_number": "Transacción: {{transactionIndex}}" - }, "envelopes": { - "belongs_to_process": "Pertenece al proceso {{pid}}", - "committed_in_block": "Registrado en el bloque #{{block}}", - "emitted": "Emitido {{emitted}}", - "encryption_keys": "Claves de cifrado: {{encKeys}}", - "envelope_detail": "Detalle del Sobre", - "envelope_weight": "Peso del sobre: {{weight}}", + "block": "Block", + "committed_in_block": "Registrado en el bloque", + "content": "Envelope Content", + "details": "Details", + "emitted": "Emitido", + "encryption_keys": "Claves de cifrado", + "envelope_number": "Envelope nº {{num}}", + "envelope_weight": "Peso del sobre", "not_found": "Sobre no encontrado", - "overwrite_count": "Conteo de sobrescritura: {{overwriteCount}}", + "on_transaction": "On Transaction", + "overwrite_count": "Conteo de sobrescritura", "registered_correctly": "El voto ha sido registrado correctamente", + "tx_number": "Transaction: {{transactionIndex}}", "verifier_code": "Código verificador", "vote_registered": "Voto registrado" }, From fd5eb1bfe73cd59da43250b3d4cefa101c22cfc7 Mon Sep 17 00:00:00 2001 From: selankon Date: Thu, 8 Aug 2024 11:09:26 +0200 Subject: [PATCH 03/10] Style `Envelope` component --- src/theme/components/Envelope.ts | 22 ++++++++++++++++++++++ src/theme/components/index.ts | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 src/theme/components/Envelope.ts diff --git a/src/theme/components/Envelope.ts b/src/theme/components/Envelope.ts new file mode 100644 index 00000000..5850bb2a --- /dev/null +++ b/src/theme/components/Envelope.ts @@ -0,0 +1,22 @@ +import { createMultiStyleConfigHelpers } from '@chakra-ui/react' +import { envelopeAnatomy } from '@vocdoni/chakra-components' + +const { defineMultiStyleConfig, definePartsStyle } = createMultiStyleConfigHelpers(envelopeAnatomy) + +const Envelope = defineMultiStyleConfig({ + baseStyle: definePartsStyle({ + title: { + pb: 0, + fontWeight: 'bold', + fontSize: 'lg', + }, + choiceTitle: { + _before: { + content: '"-"', + pr: 1, + }, + }, + }), +}) + +export default Envelope diff --git a/src/theme/components/index.ts b/src/theme/components/index.ts index 5a275dab..4cc4741d 100644 --- a/src/theme/components/index.ts +++ b/src/theme/components/index.ts @@ -5,11 +5,13 @@ import Link from './Link' import Questions from './Questions' import Radio from './Radio' import Tag from './Tag' +import Envelope from '~src/theme/components/Envelope' const components = { Card, ElectionTitle, ElectionHeader, + Envelope, Questions, Radio, ElectionResults, From bf1ced1c81fcfebb5bc147d0d65fea34905f3191 Mon Sep 17 00:00:00 2001 From: selankon Date: Thu, 8 Aug 2024 11:34:23 +0200 Subject: [PATCH 04/10] Show election title on vote package --- src/components/Envelope/Detail.tsx | 29 +++++++++++++++++++++++++---- src/i18n/locales/ca.json | 1 + src/i18n/locales/en.json | 1 + src/i18n/locales/es.json | 1 + 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/components/Envelope/Detail.tsx b/src/components/Envelope/Detail.tsx index 79d3e238..3aa11694 100644 --- a/src/components/Envelope/Detail.tsx +++ b/src/components/Envelope/Detail.tsx @@ -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' import { formatDistance } from 'date-fns' import { Trans, useTranslation } from 'react-i18next' import { generatePath, Link as RouterLink } from 'react-router-dom' @@ -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' +import { ElectionProvider, useElection } from '@vocdoni/react-providers' /** * Show envelope content @@ -62,7 +62,7 @@ const EnvelopeDetail = ({ - + @@ -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 ( + <> + + + , + }} + values={{ title: election.title.default }} + /> + + + ) +} + const EnvelopeDetailsGrid = (envelope: VoteInfoResponse) => { const { t } = useTranslation() diff --git a/src/i18n/locales/ca.json b/src/i18n/locales/ca.json index b8806aea..e763d9f3 100644 --- a/src/i18n/locales/ca.json +++ b/src/i18n/locales/ca.json @@ -33,6 +33,7 @@ "encryption_keys": "Claus de xifrat", "envelope_number": "Envelope nº {{num}}", "envelope_weight": "Pes del sobre", + "from_election_title": "From election: {{ title }}", "not_found": "Sobre no trobat", "on_transaction": "On Transaction", "overwrite_count": "Nombre de sobrescritures", diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 98b279fd..3f8e9b7c 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -32,6 +32,7 @@ "encryption_keys": "Encryption keys", "envelope_number": "Envelope nº {{num}}", "envelope_weight": "Envelope weight", + "from_election_title": "From election: {{title}}", "not_found": "Envelope not found", "on_transaction": "On Transaction", "overwrite_count": "Overwrite count", diff --git a/src/i18n/locales/es.json b/src/i18n/locales/es.json index 2e625cca..8b80bc0f 100644 --- a/src/i18n/locales/es.json +++ b/src/i18n/locales/es.json @@ -33,6 +33,7 @@ "encryption_keys": "Claves de cifrado", "envelope_number": "Envelope nº {{num}}", "envelope_weight": "Peso del sobre", + "from_election_title": "From election: {{ title }}", "not_found": "Sobre no encontrado", "on_transaction": "On Transaction", "overwrite_count": "Conteo de sobrescritura", From 222a000f4d2b29b6a7f65f4db2b4e1665f40c13a Mon Sep 17 00:00:00 2001 From: selankon Date: Fri, 9 Aug 2024 12:45:43 +0200 Subject: [PATCH 05/10] Bump chakra components --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index b0f99362..816d22df 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1963,9 +1963,9 @@ react-refresh "^0.14.0" "@vocdoni/chakra-components@~0.8.1": - version "0.8.7" - resolved "https://registry.yarnpkg.com/@vocdoni/chakra-components/-/chakra-components-0.8.7.tgz#b3b6655eab8d3d888b03bc1ea0de811d843320d2" - integrity sha512-BPbzkWSb5QKAejqvevMrpkiVkEw3GYz312oeso1kPdk+7idEvcKIvkdihbqCTD4iHSaixI1MoQ8945MLrmCkvA== + version "0.8.8" + resolved "https://registry.yarnpkg.com/@vocdoni/chakra-components/-/chakra-components-0.8.8.tgz#8af3a84886ff09a38bf78f42901b58015ecf5a07" + integrity sha512-xkI8mErw2OYuNbfxNEVUX/Udh8e+uf1J8vgWv+V7PAoQsdNAWme8BSbabyg/U9ubXL9mvPzvDnmGZkaE85qUgQ== dependencies: "@vocdoni/react-providers" "~0.4.4" From aaddb22dc061a90b06ff95bba144d72e93e696bc Mon Sep 17 00:00:00 2001 From: selankon Date: Fri, 9 Aug 2024 12:46:15 +0200 Subject: [PATCH 06/10] Implement tx vote sense --- src/components/Envelope/Detail.tsx | 32 +++++++++---------- .../TxDetails/SpecificTxDetails.tsx | 15 ++++++++- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/components/Envelope/Detail.tsx b/src/components/Envelope/Detail.tsx index 3aa11694..3fbf6cdb 100644 --- a/src/components/Envelope/Detail.tsx +++ b/src/components/Envelope/Detail.tsx @@ -1,17 +1,17 @@ import voteImage from '/images/vocdoni-vote.png' -import { Flex, Image, Link, Tab, TabList, TabPanel, TabPanels, Text } from '@chakra-ui/react' -import { PublishedElection, VoteInfoResponse } from '@vocdoni/sdk' -import { formatDistance } from 'date-fns' -import { Trans, useTranslation } from 'react-i18next' -import { generatePath, Link as RouterLink } from 'react-router-dom' -import { CopyButton, ReducedTextAndCopy } from '~components/Layout/CopyButton' -import { RawContentBox } from '~components/Layout/ShowRawButton' -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, VotePackageType } from '@vocdoni/chakra-components' -import { ElectionProvider, useElection } from '@vocdoni/react-providers' +import {Flex, Image, Link, Tab, TabList, TabPanel, TabPanels, Text} from '@chakra-ui/react' +import {PublishedElection, VoteInfoResponse} from '@vocdoni/sdk' +import {formatDistance} from 'date-fns' +import {Trans, useTranslation} from 'react-i18next' +import {generatePath, Link as RouterLink} from 'react-router-dom' +import {CopyButton, ReducedTextAndCopy} from '~components/Layout/CopyButton' +import {RawContentBox} from '~components/Layout/ShowRawButton' +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, VotePackageType} from '@vocdoni/chakra-components' +import {ElectionProvider, useElection} from '@vocdoni/react-providers' /** * Show envelope content @@ -77,13 +77,13 @@ const EnvelopeDetail = ({ ) } -const VotePackage = ({ votePackage }: { votePackage: VotePackageType }) => { +export const VotePackage = ({ votePackage }: { votePackage: VotePackageType }) => { const { t } = useTranslation() const { election } = useElection() if (!election || !(election instanceof PublishedElection)) return null return ( - <> + { values={{ title: election.title.default }} /> - + ) } diff --git a/src/components/Transactions/TxDetails/SpecificTxDetails.tsx b/src/components/Transactions/TxDetails/SpecificTxDetails.tsx index 1924302f..288829d1 100644 --- a/src/components/Transactions/TxDetails/SpecificTxDetails.tsx +++ b/src/components/Transactions/TxDetails/SpecificTxDetails.tsx @@ -1,5 +1,5 @@ import { Box, Code, Flex, Icon, Text } from '@chakra-ui/react' -import { OrganizationProvider } from '@vocdoni/react-providers' +import { ElectionProvider, OrganizationProvider } from '@vocdoni/react-providers' import { AdminTx, ensure0x, @@ -19,6 +19,7 @@ import { DetailsGrid, GridItemProps } from '~components/Layout/DetailsGrid' import { SmallOrganizationCard } from '~components/Organizations/Card' import { RoutePath } from '~constants' import { b64ToHex } from '~utils/objects' +import { VotePackage } from '~components/Envelope/Detail' export const processIdGridItem = (processId: string, t: TFunction): GridItemProps => { return { @@ -84,6 +85,18 @@ const VoteTxDetails = ({ rawTx, votePackage, processId }: { rawTx: any } & VoteE }, ] : []), + ...(votePackage + ? [ + { + label: t('transactions.vote_sense', { defaultValue: 'Vote sense' }), + children: ( + + + + ), + }, + ] + : []), ] return } From b6cf9e3ca706576b587fe7d8c59613e64a2a44ce Mon Sep 17 00:00:00 2001 From: selankon Date: Fri, 9 Aug 2024 12:50:33 +0200 Subject: [PATCH 07/10] Fix interface name --- src/components/Envelope/Detail.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Envelope/Detail.tsx b/src/components/Envelope/Detail.tsx index 3fbf6cdb..2501ef6b 100644 --- a/src/components/Envelope/Detail.tsx +++ b/src/components/Envelope/Detail.tsx @@ -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 {PublishedElection, VoteInfoResponse} from '@vocdoni/sdk' +import {IVoteInfoResponse, PublishedElection} from '@vocdoni/sdk' import {formatDistance} from 'date-fns' import {Trans, useTranslation} from 'react-i18next' import {generatePath, Link as RouterLink} from 'react-router-dom' @@ -22,7 +22,7 @@ import {ElectionProvider, useElection} from '@vocdoni/react-providers' const EnvelopeDetail = ({ route, ...envelope -}: { route: RoutePath.Envelope | RoutePath.Verify } & VoteInfoResponse) => { +}: { route: RoutePath.Envelope | RoutePath.Verify } & IVoteInfoResponse) => { const { t } = useTranslation() return ( @@ -98,7 +98,7 @@ export const VotePackage = ({ votePackage }: { votePackage: VotePackageType }) = ) } -const EnvelopeDetailsGrid = (envelope: VoteInfoResponse) => { +const EnvelopeDetailsGrid = (envelope: IVoteInfoResponse) => { const { t } = useTranslation() const emitted = formatDistance(new Date(envelope.date), new Date(), { addSuffix: true }) From 88f75bb9a8464b6e22d3aae24faa27e2360b4440 Mon Sep 17 00:00:00 2001 From: selankon Date: Fri, 9 Aug 2024 12:53:49 +0200 Subject: [PATCH 08/10] Fix routes --- src/components/Envelope/Detail.tsx | 26 +++++++++++++------------- src/components/Layout/TopBar.tsx | 2 +- src/components/Process/Detail.tsx | 2 +- src/components/Verify/index.tsx | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/Envelope/Detail.tsx b/src/components/Envelope/Detail.tsx index 2501ef6b..eb178e4a 100644 --- a/src/components/Envelope/Detail.tsx +++ b/src/components/Envelope/Detail.tsx @@ -1,17 +1,17 @@ import voteImage from '/images/vocdoni-vote.png' -import {Flex, Image, Link, Tab, TabList, TabPanel, TabPanels, Text} from '@chakra-ui/react' -import {IVoteInfoResponse, PublishedElection} from '@vocdoni/sdk' -import {formatDistance} from 'date-fns' -import {Trans, useTranslation} from 'react-i18next' -import {generatePath, Link as RouterLink} from 'react-router-dom' -import {CopyButton, ReducedTextAndCopy} from '~components/Layout/CopyButton' -import {RawContentBox} from '~components/Layout/ShowRawButton' -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, VotePackageType} from '@vocdoni/chakra-components' -import {ElectionProvider, useElection} from '@vocdoni/react-providers' +import { Flex, Image, Link, Tab, TabList, TabPanel, TabPanels, Text } from '@chakra-ui/react' +import { IVoteInfoResponse, PublishedElection } from '@vocdoni/sdk' +import { formatDistance } from 'date-fns' +import { Trans, useTranslation } from 'react-i18next' +import { generatePath, Link as RouterLink } from 'react-router-dom' +import { CopyButton, ReducedTextAndCopy } from '~components/Layout/CopyButton' +import { RawContentBox } from '~components/Layout/ShowRawButton' +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, VotePackageType } from '@vocdoni/chakra-components' +import { ElectionProvider, useElection } from '@vocdoni/react-providers' /** * Show envelope content diff --git a/src/components/Layout/TopBar.tsx b/src/components/Layout/TopBar.tsx index f536a712..d91f7e1e 100644 --- a/src/components/Layout/TopBar.tsx +++ b/src/components/Layout/TopBar.tsx @@ -72,7 +72,7 @@ export const TopBar = () => { const rightLinks: HeaderLink[] = [ { name: t('links.verify_vote', { defaultValue: 'Verify vote' }), - url: generatePath(RoutePath.Verify, { verifier: null }), + url: generatePath(RoutePath.Verify, { verifier: null, tab: null }), }, ] diff --git a/src/components/Process/Detail.tsx b/src/components/Process/Detail.tsx index 40d915e3..a69b1770 100644 --- a/src/components/Process/Detail.tsx +++ b/src/components/Process/Detail.tsx @@ -311,7 +311,7 @@ const EnvelopeCard = ({ envelope, count }: { envelope: VoteSummary; count: numbe Transaction: {{ transactionIndex: envelope.transactionIndex }} - + Details diff --git a/src/components/Verify/index.tsx b/src/components/Verify/index.tsx index fe2f3014..3027091a 100644 --- a/src/components/Verify/index.tsx +++ b/src/components/Verify/index.tsx @@ -26,7 +26,7 @@ const SearchVote = ({ compact }: { compact?: boolean }) => {