import { Extrinsic, EventRecord } from '@polkadot/types/interfaces'; import { Vec } from '@polkadot/types'; import clsx from 'clsx'; import { Placeholder } from '@/entities/placeholder'; import MainTablePlaceholderSVG from '@/shared/assets/images/placeholders/blockMainTablePlaceholder.svg?react'; import commonStyles from '@/pages/explorer/explorer.module.scss'; import { IdeaEvent } from '../../idea-event'; import { Row } from '../row'; import styles from './main-table.module.scss'; type Props = { extrinsics: Extrinsic[] | undefined; eventRecords: Vec | undefined; error: string; }; const MainTable = ({ extrinsics, eventRecords, error }: Props) => { const isAnyExtrinsic = extrinsics && extrinsics.length > 0; const isListEmpty = extrinsics?.length === 0; const headerClassName = clsx(commonStyles.header, styles.header); const getExtrinsicEvents = (index: number) => eventRecords ?.filter(({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eq(index)) .map(({ event }) => new IdeaEvent(event)); const getRows = () => extrinsics?.map((extrinsic, index) => ( // eslint-disable-next-line react/no-array-index-key )); return (
Extrinsics Events Weight Signer
{isAnyExtrinsic ? ( getRows() ) : ( } title="There are no events yet" description={error || 'The list is empty while there are no events'} isEmpty={isListEmpty || !!error} /> )}
); }; export { MainTable };