33 lines
732 B
TypeScript
33 lines
732 B
TypeScript
import initializeApollo from 'apollo/client';
|
|
import Calculation from 'Components/Calculation';
|
|
import type { GetServerSideProps } from 'next';
|
|
import { fetchUser } from 'services/user';
|
|
import type { BasePageProps } from 'types/page';
|
|
|
|
type PageProps = BasePageProps;
|
|
|
|
function Home() {
|
|
return <Calculation />;
|
|
}
|
|
|
|
export const getServerSideProps: GetServerSideProps<PageProps> = async (ctx) => {
|
|
const user = await fetchUser({
|
|
headers: ctx?.req?.headers?.cookie
|
|
? {
|
|
cookie: ctx.req.headers.cookie,
|
|
}
|
|
: undefined,
|
|
});
|
|
|
|
const apolloClient = initializeApollo();
|
|
|
|
return {
|
|
props: {
|
|
user,
|
|
initialApolloState: apolloClient.cache.extract(),
|
|
},
|
|
};
|
|
};
|
|
|
|
export default Home;
|