Skip to content

Commit

Permalink
add user territories page
Browse files Browse the repository at this point in the history
  • Loading branch information
mzivil committed Feb 21, 2024
1 parent af95c64 commit 7f0f384
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pages/[name]/territories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { getGetServerSideProps } from '../../api/ssrApollo'
import { useRouter } from 'next/router'
import { USER, USER_WITH_SUBS } from '../../fragments/users'
import { useQuery } from '@apollo/client'
import PageLoading from '../../components/page-loading'
import { UserLayout } from '.'
import TerritoryList from '../../components/territory-list'

export const getServerSideProps = getGetServerSideProps({ query: USER_WITH_SUBS })

export default function UserTerritories ({ ssrData }) {
const router = useRouter()
const variables = { ...router.query }

const { data } = useQuery(USER, { variables })
if (!data && !ssrData) return <PageLoading />

const { user } = data || ssrData

return (
<UserLayout user={user}>
<div className='mt-2'>
<TerritoryList
ssrData={ssrData}
query={USER_WITH_SUBS}
variables={variables}
destructureData={data => data.userSubs}
rank
/>
</div>
</UserLayout>
)
}

0 comments on commit 7f0f384

Please sign in to comment.