import { getGetServerSideProps } from '@/api/ssrApollo'
import Items from '@/components/items'
import { useRouter } from 'next/router'
import { USER, USER_WITH_ITEMS } from '@/fragments/users'
import { useQuery } from '@apollo/client'
import { COMMENT_TYPE_QUERY, ITEM_SORTS, ITEM_TYPES_USER, WHENS } from '@/lib/constants'
import PageLoading from '@/components/page-loading'
import { UserLayout } from '.'
import { Form, Select, DatePicker } from '@/components/form'
import { whenToFrom } from '@/lib/time'
const staticVariables = { sort: 'user' }
const variablesFunc = vars => ({
includeComments: COMMENT_TYPE_QUERY.includes(vars.type),
...staticVariables,
...vars
})
export const getServerSideProps = getGetServerSideProps(
{ query: USER_WITH_ITEMS, variables: variablesFunc, notFound: data => !data.user })
export default function UserItems ({ ssrData }) {
const router = useRouter()
const variables = variablesFunc(router.query)
const { data } = useQuery(USER, { variables })
if (!data && !ssrData) return