67 lines
1.4 KiB
TypeScript
67 lines
1.4 KiB
TypeScript
import initializeApollo from 'apollo/client';
|
||
import * as Calculation from 'Components/Calculation';
|
||
import type { GetServerSideProps } from 'next';
|
||
import Head from 'next/head';
|
||
import { fetchUser } from 'services/user';
|
||
import styled from 'styled-components';
|
||
import type { BasePageProps } from 'types/page';
|
||
import { Box } from 'UIKit/grid';
|
||
import { min } from 'UIKit/mq';
|
||
|
||
const Grid = styled(Box)`
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 10px;
|
||
|
||
${min('laptop')} {
|
||
display: grid;
|
||
align-items: flex-start;
|
||
grid-template-columns: 2fr 1fr;
|
||
}
|
||
|
||
${min('desktop')} {
|
||
grid-template-columns: 2fr 1fr 1.5fr;
|
||
margin: 8px 5%;
|
||
}
|
||
|
||
${min('desktop-xl')} {
|
||
margin: 8px 10%;
|
||
}
|
||
`;
|
||
|
||
function Home() {
|
||
return (
|
||
<Grid>
|
||
<Head>
|
||
<title>Лизинговый калькулятор - Эволюция</title>
|
||
</Head>
|
||
<Calculation.Form />
|
||
<Calculation.Settings />
|
||
<Calculation.Results />
|
||
</Grid>
|
||
);
|
||
}
|
||
|
||
type PageProps = BasePageProps;
|
||
|
||
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;
|