stacker.news/pages/~/post.js
ekzyis f8cbd43be7
Show territory details in post form (#725)
* Show territory details in post form

* Style territory details in post form

* Keep details closed by default

* Use SUB_FULL

* Undo unused changes to specify accordian default

---------

Co-authored-by: ekzyis <ek@stacker.news>
2024-01-08 17:46:23 -06:00

27 lines
813 B
JavaScript

import { getGetServerSideProps } from '../../api/ssrApollo'
import { SUB_FULL } from '../../fragments/subs'
import { CenterLayout } from '../../components/layout'
import Post from '../../components/post'
import { useQuery } from '@apollo/client'
import { useRouter } from 'next/router'
import PageLoading from '../../components/page-loading'
export const getServerSideProps = getGetServerSideProps({
query: SUB_FULL,
notFound: (data, vars) => vars.sub && !data.sub
})
export default function PostPage ({ ssrData }) {
const router = useRouter()
const { data } = useQuery(SUB_FULL, { variables: { sub: router.query.sub } })
if (!data && !ssrData) return <PageLoading />
const { sub } = data || ssrData
return (
<CenterLayout sub={sub?.name}>
<Post sub={sub} />
</CenterLayout>
)
}