import React from 'react'; import { useSelector } from 'react-redux'; import { useHistory, useParams } from 'react-router-dom'; import semver from 'semver'; import { ButtonVariant, Box, Button, Tag, Text, } from '../../../components/component-library'; import { BlockSize, Display, FlexDirection, OverflowWrap, TextColor, TextVariant, } from '../../../helpers/constants/design-system'; import { ADD_SNAP_ACCOUNT_ROUTE, SNAPS_VIEW_ROUTE, } from '../../../helpers/constants/routes'; import { useI18nContext } from '../../../hooks/useI18nContext'; import { getSnapRegistry, getSnaps } from '../../../selectors'; import { SnapDetails } from '../new-snap-account-page'; import Detail from './detail'; import { SnapDetailHeader } from './header'; interface RouteParams { snapId: string; } export default function SnapAccountDetailPage() { const t = useI18nContext(); const history = useHistory(); const { snapId } = useParams(); const installedSnaps = useSelector(getSnaps); const snapRegistryList: Record = useSelector(getSnapRegistry); const currentSnap = Object.values(snapRegistryList).find( (snap) => snap.id === snapId, ); if (!currentSnap) { history.push(ADD_SNAP_ACCOUNT_ROUTE); return null; } const isInstalled = Boolean(installedSnaps[currentSnap.snapId]); const updateAvailable = isInstalled && semver.gt(currentSnap.version, installedSnaps[currentSnap.snapId].version); return ( {currentSnap.snapSlug} {currentSnap.snapDescription} {currentSnap.tags.map((tag, index) => { return ( ); })} {currentSnap.developer} {currentSnap.auditUrls.map((auditLink, index) => { return ( ); })} {currentSnap.version} {currentSnap.lastUpdated} {isInstalled && ( )} ); }