diff --git a/pages/index.tsx b/pages/index.tsx index 9ed387e..8a13420 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -72,6 +72,19 @@ function Home({ data }: PageProps) { type PageProps = BasePageProps & { data: GetOwnerData }; +const QUERY_GET_OWNER_DATA = gql` + query GetOwnerData($domainname: String) { + leads(owner_domainname: $domainname) { + fullname + leadid + } + opportunities(owner_domainname: $domainname) { + name + opportunityid + } + } +`; + export const getServerSideProps: GetServerSideProps = async (ctx) => { const user = await fetchUser({ headers: ctx?.req?.headers?.cookie @@ -84,18 +97,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => const apolloClient = initializeApollo(); const { data: ownerData } = await apolloClient.query({ - query: gql` - query GetOwnerData($domainname: String) { - leads(owner_domainname: $domainname) { - fullname - leadid - } - opportunities(owner_domainname: $domainname) { - name - opportunityid - } - } - `, + query: QUERY_GET_OWNER_DATA, variables: { domainname: getDomainName(user), },