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