Compare commits
16 Commits
dev
...
release/bu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eea7109fe6 | ||
|
|
ab0670ddf8 | ||
|
|
e6f6639366 | ||
|
|
89c6e47a85 | ||
|
|
458307508b | ||
|
|
72e0cbb0f3 | ||
|
|
ed5f096afa | ||
|
|
b9d9c9d7bc | ||
|
|
a780656f29 | ||
|
|
090217039e | ||
|
|
e607176770 | ||
|
|
6d9a26a54d | ||
|
|
a0cc238508 | ||
|
|
225c0e5a7b | ||
|
|
e0fc9077b4 | ||
|
|
fcf521eb8c |
7
.dockerignore
Normal file
7
.dockerignore
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Dockerfile
|
||||||
|
.dockerignore
|
||||||
|
node_modules
|
||||||
|
npm-debug.log
|
||||||
|
README.md
|
||||||
|
.next
|
||||||
|
.git
|
||||||
4
.env
4
.env
@ -1,6 +1,2 @@
|
|||||||
####### USERS ########
|
####### USERS ########
|
||||||
USERS_SUPER=["akalinina","vchikalkin"]
|
USERS_SUPER=["akalinina","vchikalkin"]
|
||||||
|
|
||||||
####### URLS ########
|
|
||||||
URL_GET_USER=http://auth_service/auth/user
|
|
||||||
NEXT_PUBLIC_URL_CRM_GRAPHQL_PROXY=/api/crmgraphql
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
####### Colors ########
|
|
||||||
NEXT_PUBLIC_COLOR_PRIMARY=#1C01A9
|
|
||||||
NEXT_PUBLIC_COLOR_SECONDARY=#3A0185
|
|
||||||
NEXT_PUBLIC_COLOR_TERTIARTY=#580161
|
|
||||||
|
|
||||||
|
|
||||||
####### ICONS ########
|
|
||||||
NEXT_PUBLIC_FAVICON=favicon.prod.ico
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
####### Colors ########
|
|
||||||
NEXT_PUBLIC_COLOR_PRIMARY=#BF3676
|
|
||||||
NEXT_PUBLIC_COLOR_SECONDARY=#FD4047
|
|
||||||
NEXT_PUBLIC_COLOR_TERTIARTY=#FF9112
|
|
||||||
@ -19,6 +19,7 @@ const defaultLinkProps: ComponentProps<typeof Link> = {
|
|||||||
const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
||||||
selectLead: {
|
selectLead: {
|
||||||
render: () => {
|
render: () => {
|
||||||
|
const elementName = 'selectLead';
|
||||||
const title = titles.selectLead;
|
const title = titles.selectLead;
|
||||||
const valueName = map.selectLead;
|
const valueName = map.selectLead;
|
||||||
const Component = components.selectLead;
|
const Component = components.selectLead;
|
||||||
@ -26,7 +27,7 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
const builder = builders.selectLead;
|
const builder = builders.selectLead;
|
||||||
|
|
||||||
const Element = builder(Component, {
|
const Element = builder(Component, {
|
||||||
elementName: 'selectLead',
|
elementName,
|
||||||
valueName,
|
valueName,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -36,9 +37,13 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container key="selectLead">
|
<Container key={elementName}>
|
||||||
<Head title={title} addon={<LinkComponent {...defaultLinkProps} />} />
|
<Head
|
||||||
<Element {...props} />
|
htmlFor={elementName}
|
||||||
|
title={title}
|
||||||
|
addon={<LinkComponent {...defaultLinkProps} />}
|
||||||
|
/>
|
||||||
|
<Element {...props} id={elementName} />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -46,6 +51,7 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
|
|
||||||
selectOpportunity: {
|
selectOpportunity: {
|
||||||
render: () => {
|
render: () => {
|
||||||
|
const elementName = 'selectOpportunity';
|
||||||
const title = titles.selectOpportunity;
|
const title = titles.selectOpportunity;
|
||||||
const valueName = map.selectOpportunity;
|
const valueName = map.selectOpportunity;
|
||||||
const Component = components.selectOpportunity;
|
const Component = components.selectOpportunity;
|
||||||
@ -53,7 +59,7 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
const builder = builders.selectOpportunity;
|
const builder = builders.selectOpportunity;
|
||||||
|
|
||||||
const Element = builder(Component, {
|
const Element = builder(Component, {
|
||||||
elementName: 'selectOpportunity',
|
elementName,
|
||||||
valueName,
|
valueName,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -63,9 +69,13 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container key="selectOpportunity">
|
<Container key={elementName}>
|
||||||
<Head title={title} addon={<LinkComponent {...defaultLinkProps} />} />
|
<Head
|
||||||
<Element {...props} />
|
htmlFor={elementName}
|
||||||
|
title={title}
|
||||||
|
addon={<LinkComponent {...defaultLinkProps} />}
|
||||||
|
/>
|
||||||
|
<Element {...props} id={elementName} />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -73,6 +83,7 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
|
|
||||||
selectQuote: {
|
selectQuote: {
|
||||||
render: () => {
|
render: () => {
|
||||||
|
const elementName = 'selectQuote';
|
||||||
const title = titles.selectQuote;
|
const title = titles.selectQuote;
|
||||||
const valueName = map.selectQuote;
|
const valueName = map.selectQuote;
|
||||||
const Component = components.selectQuote;
|
const Component = components.selectQuote;
|
||||||
@ -80,7 +91,7 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
const builder = builders.selectQuote;
|
const builder = builders.selectQuote;
|
||||||
|
|
||||||
const Element = builder(Component, {
|
const Element = builder(Component, {
|
||||||
elementName: 'selectQuote',
|
elementName,
|
||||||
valueName,
|
valueName,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -90,9 +101,13 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container key="selectQuote">
|
<Container key={elementName}>
|
||||||
<Head title={title} addon={<LinkComponent {...defaultLinkProps} />} />
|
<Head
|
||||||
<Element {...props} />
|
htmlFor={elementName}
|
||||||
|
title={title}
|
||||||
|
addon={<LinkComponent {...defaultLinkProps} />}
|
||||||
|
/>
|
||||||
|
<Element {...props} id={elementName} />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -100,6 +115,7 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
|
|
||||||
tbxVehicleTaxInYear: {
|
tbxVehicleTaxInYear: {
|
||||||
render: () => {
|
render: () => {
|
||||||
|
const elementName = 'tbxVehicleTaxInYear';
|
||||||
const title = titles.tbxVehicleTaxInYear;
|
const title = titles.tbxVehicleTaxInYear;
|
||||||
const valueName = map.tbxVehicleTaxInYear;
|
const valueName = map.tbxVehicleTaxInYear;
|
||||||
const Component = components.tbxVehicleTaxInYear;
|
const Component = components.tbxVehicleTaxInYear;
|
||||||
@ -107,15 +123,15 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
const builder = builders.tbxVehicleTaxInYear;
|
const builder = builders.tbxVehicleTaxInYear;
|
||||||
|
|
||||||
const Element = builder(Component, {
|
const Element = builder(Component, {
|
||||||
elementName: 'tbxVehicleTaxInYear',
|
elementName,
|
||||||
valueName,
|
valueName,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip title="Без учета налога на роскошь" placement="topLeft">
|
<Tooltip title="Без учета налога на роскошь" placement="topLeft">
|
||||||
<Container>
|
<Container>
|
||||||
<Head title={title} />
|
<Head htmlFor={elementName} title={title} />
|
||||||
<Element {...props} />
|
<Element {...props} id={elementName} />
|
||||||
</Container>
|
</Container>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
@ -124,6 +140,7 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
|
|
||||||
selectHighSeasonStart: {
|
selectHighSeasonStart: {
|
||||||
render: () => {
|
render: () => {
|
||||||
|
const elementName = 'selectHighSeasonStart';
|
||||||
const title = titles.selectHighSeasonStart;
|
const title = titles.selectHighSeasonStart;
|
||||||
const valueName = map.selectHighSeasonStart;
|
const valueName = map.selectHighSeasonStart;
|
||||||
const Component = components.selectHighSeasonStart;
|
const Component = components.selectHighSeasonStart;
|
||||||
@ -131,15 +148,15 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
const builder = builders.selectHighSeasonStart;
|
const builder = builders.selectHighSeasonStart;
|
||||||
|
|
||||||
const Element = builder(Component, {
|
const Element = builder(Component, {
|
||||||
elementName: 'selectHighSeasonStart',
|
elementName,
|
||||||
valueName,
|
valueName,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip title="С какого платежа начинается полный высокий сезон" placement="topLeft">
|
<Tooltip title="С какого платежа начинается полный высокий сезон" placement="topLeft">
|
||||||
<Container>
|
<Container>
|
||||||
<Head title={title} />
|
<Head htmlFor={elementName} title={title} />
|
||||||
<Element {...props} />
|
<Element {...props} id={elementName} />
|
||||||
</Container>
|
</Container>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -21,8 +21,8 @@ const render = Object.keys(map).reduce((acc, elementName) => {
|
|||||||
acc[elementName] = {
|
acc[elementName] = {
|
||||||
render: () => (
|
render: () => (
|
||||||
<Container key={elementName}>
|
<Container key={elementName}>
|
||||||
<Head title={title} />
|
<Head title={title} htmlFor={elementName} />
|
||||||
<Element {...props} />
|
<Element {...props} id={elementName} />
|
||||||
</Container>
|
</Container>
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import styled from 'styled-components';
|
|||||||
import { Flex } from 'UIKit/grid';
|
import { Flex } from 'UIKit/grid';
|
||||||
import { min } from 'UIKit/mq';
|
import { min } from 'UIKit/mq';
|
||||||
|
|
||||||
const ElementTitle = styled.h5`
|
const ElementTitle = styled.label`
|
||||||
color: rgba(0, 0, 0, 0.75);
|
color: rgba(0, 0, 0, 0.75);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
@ -18,10 +18,18 @@ const ElementTitle = styled.h5`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export function Head({ title, addon }: { title: string; addon?: ReactNode }) {
|
export function Head({
|
||||||
|
title,
|
||||||
|
addon,
|
||||||
|
htmlFor,
|
||||||
|
}: {
|
||||||
|
title: string;
|
||||||
|
addon?: ReactNode;
|
||||||
|
htmlFor: string;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<Flex flexDirection={['row']} justifyContent={['space-between']} alignItems={['center']}>
|
<Flex flexDirection={['row']} justifyContent={['space-between']} alignItems={['center']}>
|
||||||
<ElementTitle>{title}</ElementTitle>
|
<ElementTitle htmlFor={htmlFor}>{title}</ElementTitle>
|
||||||
{addon}
|
{addon}
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
|
|||||||
65
Dockerfile
Normal file
65
Dockerfile
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# Install dependencies only when needed
|
||||||
|
FROM node:16-alpine AS deps
|
||||||
|
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||||
|
RUN apk add --no-cache libc6-compat
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json yarn.lock ./
|
||||||
|
RUN yarn install --frozen-lockfile
|
||||||
|
|
||||||
|
# If using npm with a `package-lock.json` comment out above and use below instead
|
||||||
|
# COPY package.json package-lock.json ./
|
||||||
|
# RUN npm ci
|
||||||
|
|
||||||
|
# Rebuild the source code only when needed
|
||||||
|
FROM node:16-alpine AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
ARG NEXT_PUBLIC_URL_CRM_GRAPHQL_PROXY
|
||||||
|
ARG NEXT_PUBLIC_COLOR_PRIMARY
|
||||||
|
ARG NEXT_PUBLIC_COLOR_SECONDARY
|
||||||
|
ARG NEXT_PUBLIC_COLOR_TERTIARTY
|
||||||
|
ARG NEXT_PUBLIC_FAVICON
|
||||||
|
ARG NEXT_TELEMETRY_DISABLED
|
||||||
|
ARG NEXT_PUBLIC_URL_CRM_GRAPHQL_DIRECT
|
||||||
|
ARG NEXT_PUBLIC_URL_GET_USER
|
||||||
|
|
||||||
|
# Next.js collects completely anonymous telemetry data about general usage.
|
||||||
|
# Learn more here: https://nextjs.org/telemetry
|
||||||
|
# Uncomment the following line in case you want to disable telemetry during the build.
|
||||||
|
# ENV NEXT_TELEMETRY_DISABLED 1
|
||||||
|
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
|
# If using npm comment out above and use below instead
|
||||||
|
# RUN npm run build
|
||||||
|
|
||||||
|
# Production image, copy all the files and run next
|
||||||
|
FROM node:16-alpine AS runner
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV NODE_ENV production
|
||||||
|
# Uncomment the following line in case you want to disable telemetry during runtime.
|
||||||
|
# ENV NEXT_TELEMETRY_DISABLED 1
|
||||||
|
|
||||||
|
RUN addgroup --system --gid 1001 nodejs
|
||||||
|
RUN adduser --system --uid 1001 nextjs
|
||||||
|
|
||||||
|
# You only need to copy next.config.js if you are NOT using the default configuration
|
||||||
|
COPY --from=builder /app/next.config.js ./
|
||||||
|
COPY --from=builder /app/public ./public
|
||||||
|
COPY --from=builder /app/package.json ./package.json
|
||||||
|
|
||||||
|
# Automatically leverage output traces to reduce image size
|
||||||
|
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||||
|
|
||||||
|
USER nextjs
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
ENV PORT 3000
|
||||||
|
|
||||||
|
CMD ["node", "server.js"]
|
||||||
@ -3,7 +3,7 @@ module.exports = {
|
|||||||
client: {
|
client: {
|
||||||
service: {
|
service: {
|
||||||
name: 'crmgraphql',
|
name: 'crmgraphql',
|
||||||
// url: process.env.URL_CRM_GRAPHQL_DIRECT,
|
// url: process.env.NEXT_PUBLIC_URL_CRM_GRAPHQL_DIRECT,
|
||||||
localSchemaFile: './graphql/crm.schema.graphql',
|
localSchemaFile: './graphql/crm.schema.graphql',
|
||||||
},
|
},
|
||||||
excludes: ['graphql/**/*'],
|
excludes: ['graphql/**/*'],
|
||||||
|
|||||||
@ -7,7 +7,7 @@ let apolloClient;
|
|||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const uri = typeof window === 'undefined'
|
const uri = typeof window === 'undefined'
|
||||||
? process.env.URL_CRM_GRAPHQL_DIRECT
|
? process.env.NEXT_PUBLIC_URL_CRM_GRAPHQL_DIRECT
|
||||||
: process.env.NEXT_PUBLIC_URL_CRM_GRAPHQL_PROXY;
|
: process.env.NEXT_PUBLIC_URL_CRM_GRAPHQL_PROXY;
|
||||||
|
|
||||||
function createApolloClient() {
|
function createApolloClient() {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ const users = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const handlers = [
|
export const handlers = [
|
||||||
rest.get('http://auth_service/auth/user', (req, res, ctx) => {
|
rest.get('http://auth_service/user', (req, res, ctx) => {
|
||||||
return res(ctx.json(users.akalinina));
|
return res(ctx.json(users.vchikalkin));
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable operator-linebreak */
|
||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
const withPlugins = require('next-compose-plugins');
|
const withPlugins = require('next-compose-plugins');
|
||||||
const withLess = require('next-with-less');
|
const withLess = require('next-with-less');
|
||||||
@ -5,6 +6,7 @@ const withGraphQL = require('next-plugin-graphql');
|
|||||||
|
|
||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
|
output: 'standalone',
|
||||||
swcMinify: true,
|
swcMinify: true,
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
eslint: {
|
eslint: {
|
||||||
@ -14,14 +16,6 @@ const nextConfig = {
|
|||||||
styledComponents: true,
|
styledComponents: true,
|
||||||
},
|
},
|
||||||
pageExtensions: ['tsx', 'jsx'],
|
pageExtensions: ['tsx', 'jsx'],
|
||||||
async rewrites() {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
source: process.env.NEXT_PUBLIC_URL_CRM_GRAPHQL_PROXY,
|
|
||||||
destination: process.env.URL_CRM_GRAPHQL_DIRECT,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
},
|
|
||||||
experimental: {
|
experimental: {
|
||||||
modularizeImports: {
|
modularizeImports: {
|
||||||
'lodash-es': {
|
'lodash-es': {
|
||||||
@ -30,6 +24,16 @@ const nextConfig = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
rewrites:
|
||||||
|
process.env.NODE_ENV === 'development' &&
|
||||||
|
async function rewrites() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
source: process.env.NEXT_PUBLIC_URL_CRM_GRAPHQL_PROXY,
|
||||||
|
destination: process.env.NEXT_PUBLIC_URL_CRM_GRAPHQL_DIRECT,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const plugins = [
|
const plugins = [
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
"next-compose-plugins": "^2.2.1",
|
"next-compose-plugins": "^2.2.1",
|
||||||
"next-plugin-graphql": "^0.0.2",
|
"next-plugin-graphql": "^0.0.2",
|
||||||
"next-with-less": "^2.0.5",
|
"next-with-less": "^2.0.5",
|
||||||
|
"normalize.css": "^8.0.1",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"rebass": "^4.0.7",
|
"rebass": "^4.0.7",
|
||||||
|
|||||||
@ -6,10 +6,12 @@ import { useApollo } from 'apollo/hooks';
|
|||||||
import Layout from 'Components/Layout';
|
import Layout from 'Components/Layout';
|
||||||
import type { AppProps } from 'next/app';
|
import type { AppProps } from 'next/app';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
|
import 'normalize.css';
|
||||||
import StoreProvider from 'stores/Provider';
|
import StoreProvider from 'stores/Provider';
|
||||||
import { ThemeProvider } from 'styled-components';
|
import { ThemeProvider } from 'styled-components';
|
||||||
import { GlobalStyle } from 'UIKit/colors';
|
import { GlobalStyle } from 'UIKit/colors';
|
||||||
import theme from 'UIKit/theme';
|
import theme from 'UIKit/theme';
|
||||||
|
import '../styles/fonts.css';
|
||||||
import '../styles/globals.css';
|
import '../styles/globals.css';
|
||||||
|
|
||||||
import ruRU from 'antd/lib/locale/ru_RU';
|
import ruRU from 'antd/lib/locale/ru_RU';
|
||||||
|
|||||||
@ -7,6 +7,7 @@ export default class MyDocument extends Document {
|
|||||||
const originalRenderPage = ctx.renderPage;
|
const originalRenderPage = ctx.renderPage;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// prettier-ignore
|
||||||
ctx.renderPage = () => originalRenderPage({
|
ctx.renderPage = () => originalRenderPage({
|
||||||
enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />),
|
enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />),
|
||||||
});
|
});
|
||||||
@ -32,27 +33,9 @@ export default class MyDocument extends Document {
|
|||||||
<Html lang="ru" translate="no">
|
<Html lang="ru" translate="no">
|
||||||
<Head>
|
<Head>
|
||||||
<meta charSet="utf-8" />
|
<meta charSet="utf-8" />
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="true" />
|
|
||||||
<link rel="preconnect" href="https://cdnjs.cloudflare.com" crossOrigin="true" />
|
|
||||||
<link
|
|
||||||
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap"
|
|
||||||
rel="stylesheet"
|
|
||||||
/>
|
|
||||||
<link
|
|
||||||
rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<link
|
|
||||||
rel="icon"
|
|
||||||
href={process.env.NEXT_PUBLIC_FAVICON || 'favicon.ico'}
|
|
||||||
crossOrigin="use-credentials"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<meta name="theme-color" content="#000000" />
|
<meta name="theme-color" content="#000000" />
|
||||||
<meta name="description" content="Лизинговый калькулятор Эволюция" />
|
<meta name="description" content="Лизинговый калькулятор Эволюция" />
|
||||||
|
<link rel="icon" href={process.env.NEXT_PUBLIC_FAVICON} crossOrigin="use-credentials" />
|
||||||
<link rel="apple-touch-icon" href="logo-100.png" crossOrigin="use-credentials" />
|
<link rel="apple-touch-icon" href="logo-100.png" crossOrigin="use-credentials" />
|
||||||
</Head>
|
</Head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@ -3,16 +3,13 @@ import { useApolloClient } from '@apollo/client';
|
|||||||
import initializeApollo from 'apollo/client';
|
import initializeApollo from 'apollo/client';
|
||||||
import * as Calculation from 'Components/Calculation';
|
import * as Calculation from 'Components/Calculation';
|
||||||
import Output from 'Components/Output';
|
import Output from 'Components/Output';
|
||||||
import defaultOptions from 'config/default-options';
|
|
||||||
import * as InsuranceTableConfig from 'config/tables/insurance-table';
|
|
||||||
import { merge } from 'lodash-es';
|
|
||||||
import type { GetServerSideProps } from 'next';
|
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import * as agentsReactions from 'process/agents/reactions';
|
import * as agentsReactions from 'process/agents/reactions';
|
||||||
import * as calculateReactions from 'process/calculate/reactions';
|
import * as calculateReactions from 'process/calculate/reactions';
|
||||||
import { getCRMData } from 'process/init/get-data';
|
import { getInsuranceData, getMainData, getOwnerData } from 'process/init/get-data';
|
||||||
import * as leadOpportunityReactions from 'process/lead-opportunity/reactions';
|
import * as leadOpportunityReactions from 'process/lead-opportunity/reactions';
|
||||||
import paymentsReactions from 'process/payments/reactions';
|
import paymentsReactions from 'process/payments/reactions';
|
||||||
|
import { useEffect } from 'react';
|
||||||
import { fetchUser } from 'services/user';
|
import { fetchUser } from 'services/user';
|
||||||
import { useStore } from 'stores/hooks';
|
import { useStore } from 'stores/hooks';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
@ -43,22 +40,30 @@ const Grid = styled(Box)`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function Home() {
|
function injectReactions(store, apolloClient) {
|
||||||
const store = useStore();
|
|
||||||
const apolloClient = useApolloClient();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add reactions to store
|
|
||||||
*/
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
leadOpportunityReactions.common(store, apolloClient);
|
leadOpportunityReactions.common(store, apolloClient);
|
||||||
leadOpportunityReactions.urls(store, apolloClient);
|
leadOpportunityReactions.urls(store, apolloClient);
|
||||||
paymentsReactions(store, apolloClient);
|
paymentsReactions(store, apolloClient);
|
||||||
calculateReactions.validation(store, apolloClient);
|
calculateReactions.validation(store, apolloClient);
|
||||||
agentsReactions.common(store, apolloClient);
|
agentsReactions.common(store, apolloClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Home() {
|
||||||
|
const store = useStore();
|
||||||
|
const apolloClient = useApolloClient();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getMainData(apolloClient).then(({ options }) => {
|
||||||
|
store.$calculation.$options.setManyOptions(options);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
getInsuranceData(apolloClient).then(({ tables }) => {
|
||||||
|
store.$tables.insurance.setManyRowOptions(tables.insurance);
|
||||||
|
});
|
||||||
|
|
||||||
|
injectReactions(store, apolloClient);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid>
|
<Grid>
|
||||||
<Head>
|
<Head>
|
||||||
@ -71,7 +76,7 @@ function Home() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getServerSideProps: GetServerSideProps = async ({ req }) => {
|
export const getServerSideProps = async ({ req }) => {
|
||||||
const { cookie = '' } = req.headers;
|
const { cookie = '' } = req.headers;
|
||||||
|
|
||||||
const user = await fetchUser({
|
const user = await fetchUser({
|
||||||
@ -81,18 +86,14 @@ export const getServerSideProps: GetServerSideProps = async ({ req }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const apolloClient = initializeApollo();
|
const apolloClient = initializeApollo();
|
||||||
const { options, tables } = await getCRMData(apolloClient, user);
|
|
||||||
|
const { options: ownerOptions } = await getOwnerData(apolloClient, user);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
user,
|
user,
|
||||||
calculation: {
|
calculation: {
|
||||||
options: merge(defaultOptions, options),
|
options: ownerOptions,
|
||||||
},
|
|
||||||
tables: {
|
|
||||||
insurance: {
|
|
||||||
options: merge(InsuranceTableConfig.defaultOptions, tables.insurance),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
initialApolloState: apolloClient.cache.extract(),
|
initialApolloState: apolloClient.cache.extract(),
|
||||||
@ -5,7 +5,6 @@ import dayjs from 'dayjs';
|
|||||||
import utc from 'dayjs/plugin/utc';
|
import utc from 'dayjs/plugin/utc';
|
||||||
import { getDomainName } from 'services/user/tools';
|
import { getDomainName } from 'services/user/tools';
|
||||||
import type { User } from 'services/user/types';
|
import type { User } from 'services/user/types';
|
||||||
import { normalizeOptions } from 'tools/entity';
|
|
||||||
import type { GetAddproductTypes } from './__generated__/GetAddproductTypes';
|
import type { GetAddproductTypes } from './__generated__/GetAddproductTypes';
|
||||||
import type { GetInsuranceData } from './__generated__/GetInsuranceData';
|
import type { GetInsuranceData } from './__generated__/GetInsuranceData';
|
||||||
import type { GetMainOptions } from './__generated__/GetMainOptions';
|
import type { GetMainOptions } from './__generated__/GetMainOptions';
|
||||||
@ -133,42 +132,28 @@ const QUERY_GET_INSURANCE_DATA = gql`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export async function getCRMData(apolloClient: ApolloClient<NormalizedCache>, user: User) {
|
export async function getOwnerData(apolloClient: ApolloClient<NormalizedCache>, user: User) {
|
||||||
const {
|
const { data: ownerData } = await apolloClient.query<GetOwnerData, GetOwnerDataVariables>({
|
||||||
data: { selectLead, selectOpportunity },
|
|
||||||
} = await apolloClient.query<GetOwnerData, GetOwnerDataVariables>({
|
|
||||||
query: QUERY_GET_OWNER_DATA,
|
query: QUERY_GET_OWNER_DATA,
|
||||||
variables: {
|
variables: {
|
||||||
domainname: getDomainName(user),
|
domainname: getDomainName(user),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
options: ownerData,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getMainData(apolloClient: ApolloClient<object>) {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const { data: options } = await apolloClient.query<GetMainOptions>({
|
const { data: mainOptions } = await apolloClient.query<GetMainOptions>({
|
||||||
query: QUERY_GET_MAIN_OPTIONS,
|
query: QUERY_GET_MAIN_OPTIONS,
|
||||||
variables: {
|
variables: {
|
||||||
currentDate: dayjs().utc().toISOString()
|
currentDate: dayjs().utc().toISOString()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
|
||||||
data: { kasko, osago, fingap },
|
|
||||||
} = await apolloClient.query<GetInsuranceData>({
|
|
||||||
query: QUERY_GET_INSURANCE_DATA,
|
|
||||||
});
|
|
||||||
|
|
||||||
const insuranceData = {
|
|
||||||
osago: {
|
|
||||||
insuranceCompany: normalizeOptions(osago),
|
|
||||||
},
|
|
||||||
kasko: {
|
|
||||||
insuranceCompany: normalizeOptions(kasko),
|
|
||||||
},
|
|
||||||
fingap: {
|
|
||||||
insuranceCompany: normalizeOptions(fingap),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const { data: subsidies } = await apolloClient.query<GetSubsidies>({
|
const { data: subsidies } = await apolloClient.query<GetSubsidies>({
|
||||||
query: QUERY_GET_SUBSIDIES,
|
query: QUERY_GET_SUBSIDIES,
|
||||||
variables: {
|
variables: {
|
||||||
@ -230,9 +215,7 @@ export async function getCRMData(apolloClient: ApolloClient<NormalizedCache>, us
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
options: {
|
options: {
|
||||||
selectLead,
|
...mainOptions,
|
||||||
selectOpportunity,
|
|
||||||
...options,
|
|
||||||
selectSubsidy,
|
selectSubsidy,
|
||||||
selectImportProgram,
|
selectImportProgram,
|
||||||
selectRegionRegistration,
|
selectRegionRegistration,
|
||||||
@ -244,8 +227,29 @@ export async function getCRMData(apolloClient: ApolloClient<NormalizedCache>, us
|
|||||||
selectTracker,
|
selectTracker,
|
||||||
selectInsNSIB,
|
selectInsNSIB,
|
||||||
},
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getInsuranceData(apolloClient: ApolloClient<object>) {
|
||||||
|
const { data: insuranceData } = await apolloClient.query<GetInsuranceData>({
|
||||||
|
query: QUERY_GET_INSURANCE_DATA,
|
||||||
|
});
|
||||||
|
|
||||||
|
const insurance = {
|
||||||
|
osago: {
|
||||||
|
insuranceCompany: insuranceData.osago,
|
||||||
|
},
|
||||||
|
kasko: {
|
||||||
|
insuranceCompany: insuranceData.kasko,
|
||||||
|
},
|
||||||
|
fingap: {
|
||||||
|
insuranceCompany: insuranceData.fingap,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
tables: {
|
tables: {
|
||||||
insurance: insuranceData,
|
insurance,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,9 @@ export default function paymentsReactions(store: RootStore, apolloClient: Apollo
|
|||||||
} else {
|
} else {
|
||||||
removeError();
|
removeError();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fireImmediately: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
public/fonts/Montserrat/Montserrat-Black.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-Black.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-BlackItalic.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-BlackItalic.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-Bold.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-Bold.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-BoldItalic.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-ExtraBold.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-ExtraBold.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-ExtraBoldItalic.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-ExtraBoldItalic.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-ExtraLight.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-ExtraLight.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-ExtraLightItalic.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-ExtraLightItalic.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-Italic.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-Italic.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-Light.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-Light.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-LightItalic.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-LightItalic.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-Medium.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-Medium.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-MediumItalic.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-MediumItalic.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-Regular.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-Regular.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-SemiBold.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-SemiBold.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-SemiBoldItalic.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-SemiBoldItalic.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-Thin.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-Thin.ttf
Normal file
Binary file not shown.
BIN
public/fonts/Montserrat/Montserrat-ThinItalic.ttf
Normal file
BIN
public/fonts/Montserrat/Montserrat-ThinItalic.ttf
Normal file
Binary file not shown.
@ -6,7 +6,7 @@ import type { User } from './types';
|
|||||||
|
|
||||||
export async function fetchUser(config: AxiosRequestConfig) {
|
export async function fetchUser(config: AxiosRequestConfig) {
|
||||||
const user = await axios
|
const user = await axios
|
||||||
.get<User>(process.env.URL_GET_USER || '', config)
|
.get<User>(process.env.NEXT_PUBLIC_URL_GET_USER || '', config)
|
||||||
.then((res) => love(res.data));
|
.then((res) => love(res.data));
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
import type { Elements, ElementsTypes } from 'Components/Calculation/config/map/values';
|
import type { Elements, ElementsTypes } from 'Components/Calculation/config/map/values';
|
||||||
import defaultOptions from 'config/default-options';
|
import defaultOptions from 'config/default-options';
|
||||||
import type { BaseOption } from 'Elements/types';
|
import type { BaseOption } from 'Elements/types';
|
||||||
|
import { merge } from 'lodash-es';
|
||||||
import { makeAutoObservable } from 'mobx';
|
import { makeAutoObservable } from 'mobx';
|
||||||
import type RootStore from 'stores/root';
|
import type RootStore from 'stores/root';
|
||||||
import type { CalculationOptions } from './types';
|
import type { CalculationOptions } from './types';
|
||||||
@ -17,7 +18,7 @@ export default class OptionsStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hydrate = (initialOptions: CalculationOptions) => {
|
hydrate = (initialOptions: CalculationOptions) => {
|
||||||
this.options = initialOptions;
|
this.options = merge(defaultOptions, initialOptions);
|
||||||
};
|
};
|
||||||
|
|
||||||
getOptions<T extends Elements>(elementName: T) {
|
getOptions<T extends Elements>(elementName: T) {
|
||||||
|
|||||||
@ -56,10 +56,14 @@ export default class InsuranceTable {
|
|||||||
return this.options[key];
|
return this.options[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
setRowOptions = (key: Insurance.Keys, rowOptions: Partial<Insurance.RowOptions>) => {
|
setRowOptions = (key: Insurance.Keys, rowOptions: Insurance.RowOptions) => {
|
||||||
mergeWith(this.options[key], rowOptions);
|
mergeWith(this.options[key], rowOptions);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setManyRowOptions = (options: Partial<Record<Insurance.Keys, Insurance.RowOptions>>) => {
|
||||||
|
mergeWith(this.options, options);
|
||||||
|
};
|
||||||
|
|
||||||
getRowStatuses(key: Insurance.Keys) {
|
getRowStatuses(key: Insurance.Keys) {
|
||||||
return this.statuses[key];
|
return this.statuses[key];
|
||||||
}
|
}
|
||||||
|
|||||||
6
styles/fonts.css
Normal file
6
styles/fonts.css
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
@font-face {
|
||||||
|
font-family: Montserrat;
|
||||||
|
src: url('../public/fonts/Montserrat/Montserrat-Medium.ttf');
|
||||||
|
font-weight: 500;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
@ -19,5 +19,5 @@
|
|||||||
},
|
},
|
||||||
"files": ["types/graphql.d.ts"],
|
"files": ["types/graphql.d.ts"],
|
||||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
|
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
|
||||||
"exclude": ["node_modules", "**/__generated__"]
|
"exclude": ["node_modules", "**/__generated__", "./types/graphql.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4380,6 +4380,11 @@ normalize-url@^6.1.0:
|
|||||||
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a"
|
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a"
|
||||||
integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==
|
integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==
|
||||||
|
|
||||||
|
normalize.css@^8.0.1:
|
||||||
|
version "8.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/normalize.css/-/normalize.css-8.0.1.tgz#9b98a208738b9cc2634caacbc42d131c97487bf3"
|
||||||
|
integrity sha512-qizSNPO93t1YUuUhP22btGOo3chcvDFqFaj2TRybP0DMxkHOCTYwp3n34fel4a31ORXy4m1Xq0Gyqpb5m33qIg==
|
||||||
|
|
||||||
npm-run-path@^4.0.1:
|
npm-run-path@^4.0.1:
|
||||||
version "4.0.1"
|
version "4.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea"
|
resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user