From d3f7dfbfa63092b8bcba8a0ff64909840fe9045a Mon Sep 17 00:00:00 2001 From: selankon Date: Thu, 22 Aug 2024 11:21:58 +0200 Subject: [PATCH] Unify NoResultsError component --- src/components/Accounts/Details/Elections.tsx | 10 ++++------ src/components/Accounts/Details/Transfers.tsx | 7 ++----- src/components/Layout/ContentError.tsx | 7 ++++++- src/components/Process/Detail.tsx | 13 ++++--------- src/components/Transactions/TransactionList.tsx | 7 ++----- src/i18n/locales/ca.json | 2 +- src/i18n/locales/en.json | 2 +- src/i18n/locales/es.json | 2 +- 8 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/components/Accounts/Details/Elections.tsx b/src/components/Accounts/Details/Elections.tsx index f77382c..ae72e55 100644 --- a/src/components/Accounts/Details/Elections.tsx +++ b/src/components/Accounts/Details/Elections.tsx @@ -1,6 +1,6 @@ import { Flex, Text } from '@chakra-ui/react' import { AccountData } from '@vocdoni/sdk' -import { Trans } from 'react-i18next' +import { Trans, useTranslation } from 'react-i18next' import { LoadingCards } from '~components/Layout/Loading' import { RoutedPagination } from '~components/Pagination/Pagination' import { RoutedPaginationProvider, useRoutedPagination } from '~components/Pagination/PaginationProvider' @@ -14,12 +14,10 @@ interface OrgComponentProps { } const AccountElections = ({ org }: OrgComponentProps) => { + const { t } = useTranslation() + if (org.electionIndex === 0) { - return ( - - No elections yet! - - ) + return } return ( diff --git a/src/components/Accounts/Details/Transfers.tsx b/src/components/Accounts/Details/Transfers.tsx index 7230562..5762c74 100644 --- a/src/components/Accounts/Details/Transfers.tsx +++ b/src/components/Accounts/Details/Transfers.tsx @@ -64,6 +64,7 @@ const AccountTransfers = (txProps: AccountTransfersProps) => { const AccountTransfersTable = ({ txCount, org }: AccountTransfersProps) => { const { page } = usePagination() const { formatDistance } = useDateFns() + const { t } = useTranslation() const { data, isLoading, isError, error } = useAccountTransfers({ address: org.address, @@ -74,11 +75,7 @@ const AccountTransfersTable = ({ txCount, org }: AccountTransfersProps) => { }) if (txCount === 0) { - return ( - - No transfers yet! - - ) + return } if (!txCount || isLoading) { diff --git a/src/components/Layout/ContentError.tsx b/src/components/Layout/ContentError.tsx index c2a396a..4c853af 100644 --- a/src/components/Layout/ContentError.tsx +++ b/src/components/Layout/ContentError.tsx @@ -3,7 +3,12 @@ import { Trans, useTranslation } from 'react-i18next' export const NoResultsError = ({ msg }: { msg?: string }) => { const { t } = useTranslation() - return {msg ?? t('errors.no_results', { defaultValue: 'Looks like there are no results to show.' })} + return ( + + + {msg ?? t('errors.no_results', { defaultValue: 'Looks like there are nothing to show.' })} + + ) } export type ContentErrorType = Error | undefined | null | string diff --git a/src/components/Process/Detail.tsx b/src/components/Process/Detail.tsx index 12ee43d..08ebbe5 100644 --- a/src/components/Process/Detail.tsx +++ b/src/components/Process/Detail.tsx @@ -50,6 +50,7 @@ import { FallbackHeaderImg, RoutePath } from '~constants' import { useElectionKeys, useElectionVotesList } from '~queries/processes' import { ucfirst } from '~utils/strings' import { RouteParamsTabs } from '~components/Layout/RouteParamsTabs' +import { NoResultsError } from '~components/Layout/ContentError' const Detail = () => { const { election } = useElection() @@ -161,10 +162,7 @@ const Detail = () => { {election.description?.default ? ( ) : ( - - - No description set! - + )} @@ -221,13 +219,10 @@ const ElectionKeys = ({ electionId }: { electionId: string }) => { const EnvelopeExplorer = () => { const { election: e } = useElection() const election = e as PublishedElection + const { t } = useTranslation() if (!election || election.voteCount === 0) { - return ( - - No votes yet! - - ) + return } return ( diff --git a/src/components/Transactions/TransactionList.tsx b/src/components/Transactions/TransactionList.tsx index dd91293..ef80a9f 100644 --- a/src/components/Transactions/TransactionList.tsx +++ b/src/components/Transactions/TransactionList.tsx @@ -121,12 +121,9 @@ const TransactionsListCards = ({ error: Error | null height?: number }) => { + const { t } = useTranslation() if (!data || (data && data.transactions.length <= 0)) { - return ( - - There are no transactions. - - ) + return } if (isLoading) { diff --git a/src/i18n/locales/ca.json b/src/i18n/locales/ca.json index a984715..9448a66 100644 --- a/src/i18n/locales/ca.json +++ b/src/i18n/locales/ca.json @@ -83,7 +83,7 @@ }, "errors": { "content_error": "Sembla que el contingut al qual intentaves accedir ha generat un error.", - "no_results": "Sembla que no hi ha resultats per mostrar." + "no_results": "Sembla que no hi ha res a mostrar." }, "featured": { "a_cutting_edge_voting_protocol": "Un protocol de votació avançat", diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 0b45c13..92e3f1b 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -80,7 +80,7 @@ }, "errors": { "content_error": "Looks like the content you were accessing threw an error.", - "no_results": "Looks like there are no results to show." + "no_results": "Looks like there are nothing to show." }, "featured": { "a_cutting_edge_voting_protocol": "A cutting edge voting protocol", diff --git a/src/i18n/locales/es.json b/src/i18n/locales/es.json index f7a6c56..80048e2 100644 --- a/src/i18n/locales/es.json +++ b/src/i18n/locales/es.json @@ -83,7 +83,7 @@ }, "errors": { "content_error": "Parece que el contenido al que accediste arrojó un error.", - "no_results": "Parece que no hay resultados para mostrar." + "no_results": "Parece que no hay nada para mostrar." }, "featured": { "a_cutting_edge_voting_protocol": "Un protocolo de votación de vanguardia",