11import { FC } from 'react'
2+ import { useHref , useParams } from 'react-router-dom'
23import { useTranslation } from 'react-i18next'
34import { formatDistanceStrict } from 'date-fns'
45import Box from '@mui/material/Box'
56import Grid from '@mui/material/Grid'
67import Typography from '@mui/material/Typography'
78import { styled } from '@mui/material/styles'
8- import { RoflApp } from '../../../oasis-nexus/api'
9+ import { Layer , RoflApp , useGetRuntimeRoflAppsId } from '../../../oasis-nexus/api'
910import { getPreciseNumberFormat } from '../../../locales/getPreciseNumberFormat'
11+ import { AppErrors } from '../../../types/errors'
12+ import { useRequiredScopeParam } from '../../hooks/useScopeParam'
13+ import { useTypedSearchParam } from '../../hooks/useTypedSearchParam'
1014import { useScreenSize } from '../../hooks/useScreensize'
15+ import { PageLayout } from '../../components/PageLayout'
16+ import { SubPageCard } from '../../components/SubPageCard'
1117import { TextSkeleton } from '../../components/Skeleton'
1218import { StyledDescriptionList } from '../../components/StyledDescriptionList'
1319import { RoflAppStatusBadge } from '../../components/Rofl/RoflAppStatusBadge'
@@ -19,6 +25,55 @@ import { TeeType } from './TeeType'
1925import { Endorsement } from './Endorsement'
2026import { Enclaves } from './Enclaves'
2127import { Secrets } from './Secrets'
28+ import { RouterTabs } from '../../components/RouterTabs'
29+ import { instancesContainerId } from '../../utils/tabAnchors'
30+ import { RoflAppDetailsContext } from '../RoflAppDetailsPage/hooks'
31+
32+ export const RoflAppDetailsPage : FC = ( ) => {
33+ const { t } = useTranslation ( )
34+ const scope = useRequiredScopeParam ( )
35+ const id = useParams ( ) . id !
36+ const txLink = useHref ( '' )
37+ const instancesLink = useHref ( `instances#${ instancesContainerId } ` )
38+ const [ method , setMethod ] = useTypedSearchParam ( 'method' , 'any' , {
39+ deleteParams : [ 'page' ] ,
40+ } )
41+ const context : RoflAppDetailsContext = { scope, id, method, setMethod }
42+ const { isFetched, isLoading, data } = useGetRuntimeRoflAppsId ( scope . network , Layer . sapphire , id )
43+ const roflApp = data ?. data
44+
45+ if ( ! roflApp && isFetched ) {
46+ throw AppErrors . NotFoundRoflApp
47+ }
48+
49+ return (
50+ < PageLayout >
51+ < SubPageCard featured title = { roflApp ?. metadata [ 'net.oasis.rofl.name' ] || t ( 'rofl.header' ) } >
52+ < RoflAppDetailsView detailsPage isLoading = { isLoading } app = { roflApp } />
53+ </ SubPageCard >
54+ < Grid container spacing = { 4 } >
55+ < StyledGrid item xs = { 12 } md = { 6 } >
56+ { /* TODO: uncomment when other PRs are merged */ }
57+ { /* <MetaDataCard isFetched={isFetched} metadata={roflApp?.metadata} /> */ }
58+ </ StyledGrid >
59+ < StyledGrid item xs = { 12 } md = { 6 } >
60+ { /* TODO: uncomment when other PRs are merged */ }
61+ { /* <PolicyCard isFetched={isFetched} policy={roflApp?.policy} /> */ }
62+ </ StyledGrid >
63+ </ Grid >
64+ < RouterTabs
65+ tabs = { [
66+ { label : t ( 'common.transactions' ) , to : txLink } ,
67+ {
68+ label : t ( 'rofl.instances' ) ,
69+ to : instancesLink ,
70+ } ,
71+ ] }
72+ context = { context }
73+ />
74+ </ PageLayout >
75+ )
76+ }
2277
2378export const StyledGrid = styled ( Grid ) ( ( { theme } ) => ( {
2479 [ theme . breakpoints . up ( 'sm' ) ] : {
0 commit comments