41 lines
902 B
TypeScript
41 lines
902 B
TypeScript
import initializeApollo from 'apollo/client';
|
||
import Calculation from 'Components/Calculation';
|
||
import type { GetServerSideProps } from 'next';
|
||
import Head from 'next/head';
|
||
import { fetchUser } from 'services/user';
|
||
import type { BasePageProps } from 'types/page';
|
||
|
||
type PageProps = BasePageProps;
|
||
|
||
function Home() {
|
||
return (
|
||
<>
|
||
<Head>
|
||
<title>Лизинговый калькулятор - Эволюция</title>
|
||
</Head>
|
||
<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;
|