import React from 'react'; import { useSelector } from 'react-redux'; import { useHistory, useParams } from 'react-router-dom'; import semver from 'semver'; import { BUTTON_VARIANT, Box, Button, Tag, } from '../../../components/component-library'; import { Text } from '../../../components/component-library/text/deprecated'; import { BlockSize, Display, FlexDirection, 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.website} {currentSnap.auditUrls.map((auditLink, index) => { return ( ); })} {currentSnap.version} {currentSnap.lastUpdated} {isInstalled && ( )} ); }