From 0befd824e6f47f98dca1b8645190e41752133e2a Mon Sep 17 00:00:00 2001 From: Chika Date: Fri, 8 Jul 2022 10:57:16 +0300 Subject: [PATCH] pages/index: component props types --- pages/index.tsx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index 8a13420..b386842 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -36,7 +36,9 @@ const Grid = styled(Box)` } `; -function Home({ data }: PageProps) { +type PageProps = BasePageProps & { graphQLData: GraphQLData }; + +function Home({ graphQLData }: PageProps) { const store = useStore(); const apolloClient = useApolloClient(); @@ -46,10 +48,13 @@ function Home({ data }: PageProps) { leadOpportunityUrlsReactions(store, apolloClient); /** - * set initial data to store + * set owner data to store */ - const leads = data.leads ? convertEntitiesToOptions(data.leads) : []; - const opportunities = data.opportunities ? convertEntitiesToOptions(data.opportunities) : []; + const { ownerData } = graphQLData; + const leads = ownerData.leads ? convertEntitiesToOptions(ownerData.leads) : []; + const opportunities = ownerData.opportunities + ? convertEntitiesToOptions(ownerData.opportunities) + : []; const { $calculation } = store; @@ -70,7 +75,9 @@ function Home({ data }: PageProps) { ); } -type PageProps = BasePageProps & { data: GetOwnerData }; +type GraphQLData = { + ownerData: GetOwnerData; +}; const QUERY_GET_OWNER_DATA = gql` query GetOwnerData($domainname: String) { @@ -106,8 +113,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => return { props: { user, - data: { - ...ownerData, + graphQLData: { + ownerData, }, initialApolloState: apolloClient.cache.extract(), },