import React from 'react'; import PropTypes from 'prop-types'; import Preloader from '../../../ui/icon/preloader/preloader-icon.component'; import Typography from '../../../ui/typography/typography'; import { ALIGN_ITEMS, COLORS, FLEX_DIRECTION, JUSTIFY_CONTENT, TEXT_ALIGN, TYPOGRAPHY, } from '../../../../helpers/constants/design-system'; import { useI18nContext } from '../../../../hooks/useI18nContext'; import { useTransactionInsightSnap } from '../../../../hooks/flask/useTransactionInsightSnap'; import SnapContentFooter from '../../flask/snap-content-footer/snap-content-footer'; import Box from '../../../ui/box/box'; export const SnapInsight = ({ transaction, chainId, selectedSnap }) => { const t = useI18nContext(); const response = useTransactionInsightSnap({ transaction, chainId, snapId: selectedSnap.id, }); const data = response?.insights; const hasNoData = !data || !Object.keys(data).length; return ( {data ? ( {Object.keys(data).length ? ( <> {Object.keys(data).map((key, i) => (
{key} {data[key]}
))}
) : ( {t('snapsNoInsight')} )}
) : ( <> {t('snapsInsightLoading')} )}
); }; SnapInsight.propTypes = { /* * The transaction data object */ transaction: PropTypes.object, /* * CAIP2 Chain ID */ chainId: PropTypes.string, /* * The insight snap selected */ selectedSnap: PropTypes.object, };