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 Box from '../../../ui/box/box'; import ActionableMessage from '../../../ui/actionable-message/actionable-message'; import { SnapUIRenderer } from '../../flask/snap-ui-renderer'; export const SnapInsight = ({ transaction, origin, chainId, selectedSnap }) => { const t = useI18nContext(); const { data: response, error, loading, } = useTransactionInsightSnap({ transaction, chainId, origin, snapId: selectedSnap.id, }); const data = response?.content; const hasNoData = !error && (loading || !data || (data && Object.keys(data).length === 0)); return ( {!loading && !error && ( {data && Object.keys(data).length > 0 ? ( ) : ( {t('snapsNoInsight')} )} )} {!loading && error && ( )} {loading && ( <> {t('snapsInsightLoading')} )} ); }; SnapInsight.propTypes = { /* * The transaction data object */ transaction: PropTypes.object, /* * CAIP2 Chain ID */ chainId: PropTypes.string, /* * The origin of the transaction */ origin: PropTypes.string, /* * The insight snap selected */ selectedSnap: PropTypes.object, };