32 lines
937 B
JavaScript
Raw Normal View History

2021-10-26 15:49:37 -05:00
import Layout from '../../components/layout'
import { useQuery } from '@apollo/client'
import UserHeader from '../../components/user-header'
import Seo from '../../components/seo'
import Items from '../../components/items'
import { USER_WITH_POSTS } from '../../fragments/users'
import { getGetServerSideProps } from '../../api/ssrApollo'
2022-02-17 11:23:43 -06:00
export const getServerSideProps = getGetServerSideProps(USER_WITH_POSTS)
2021-10-26 15:49:37 -05:00
2022-02-17 11:23:43 -06:00
export default function UserPosts ({ data: { user, items: { items, cursor } } }) {
2021-10-26 15:49:37 -05:00
const { data } = useQuery(USER_WITH_POSTS,
{ variables: { name: user.name, sort: 'user' } })
2021-10-26 15:49:37 -05:00
if (data) {
2022-02-17 11:23:43 -06:00
({ user, items: { items, cursor } } = data)
2021-10-26 15:49:37 -05:00
}
return (
<Layout noSeo>
<Seo user={user} />
<UserHeader user={user} />
2021-11-12 16:39:52 -06:00
<div className='mt-2'>
<Items
items={items} cursor={cursor}
variables={{ name: user.name, sort: 'user' }}
2021-11-12 16:39:52 -06:00
/>
</div>
2021-10-26 15:49:37 -05:00
</Layout>
)
}