-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathConsensusTransactionEvents.tsx
More file actions
47 lines (44 loc) · 1.57 KB
/
ConsensusTransactionEvents.tsx
File metadata and controls
47 lines (44 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { FC } from 'react'
import { useTranslation } from 'react-i18next'
import { Transaction, useGetConsensusEvents } from '../../../oasis-nexus/api'
import { AppErrors } from '../../../types/errors'
import { NUMBER_OF_ITEMS_ON_SEPARATE_PAGE as limit } from '../../config'
import { ConsensusEventsList } from '../ConsensusEvents/ConsensusEventsList'
import { useSearchParamsPagination } from '../Table/useSearchParamsPagination'
import { CardEmptyState } from '../CardEmptyState'
export const ConsensusTransactionEvents: FC<{
transaction: Transaction
}> = ({ transaction }) => {
const { t } = useTranslation()
const pagination = useSearchParamsPagination('page')
const offset = (pagination.selectedPage - 1) * limit
const eventsQuery = useGetConsensusEvents(transaction.network, {
tx_hash: transaction.hash,
limit,
offset,
})
const { isFetched, isLoading, data, isError } = eventsQuery
const events = data?.data.events
if (isFetched && pagination.selectedPage > 1 && !events?.length) {
throw AppErrors.PageDoesNotExist
}
if (!events?.length && isFetched) {
return <CardEmptyState label={t('event.cantFindMatchingEvents')} />
}
return (
<ConsensusEventsList
scope={transaction}
events={events}
isLoading={isLoading}
isError={isError}
pagination={{
selectedPage: pagination.selectedPage,
linkToPage: pagination.linkToPage,
totalCount: data?.data.total_count,
isTotalCountClipped: data?.data.is_total_count_clipped,
rowsPerPage: limit,
}}
showTxHash={false}
/>
)
}