27 lines
891 B
JavaScript
Raw Normal View History

2021-09-30 10:46:58 -05:00
import Layout from '../../../components/layout'
import { ITEM_FULL } from '../../../fragments/items'
import ItemFull from '../../../components/item-full'
2021-10-26 15:49:37 -05:00
import { getGetServerSideProps } from '../../../api/ssrApollo'
2021-09-30 10:46:58 -05:00
import { useQuery } from '@apollo/client'
import { useRouter } from 'next/router'
import PageLoading from '../../../components/page-loading'
2021-09-30 10:46:58 -05:00
export const getServerSideProps = getGetServerSideProps(ITEM_FULL, null,
2022-09-29 15:42:33 -05:00
data => !data.item || (data.item.status === 'STOPPED' && !data.item.mine))
2021-09-30 10:46:58 -05:00
export default function Item ({ ssrData }) {
const router = useRouter()
2021-09-30 10:46:58 -05:00
2023-07-25 19:45:35 -05:00
const { data } = useQuery(ITEM_FULL, { variables: { ...router.query } })
if (!data && !ssrData) return <PageLoading />
const { item } = data || ssrData
2023-05-05 12:38:56 -05:00
const sub = item.subName || item.root?.subName
2022-02-17 11:23:43 -06:00
2021-09-30 10:46:58 -05:00
return (
<Layout sub={sub} item={item}>
2021-09-30 10:46:58 -05:00
<ItemFull item={item} />
</Layout>
)
}