Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c25ba30d0 | ||
|
|
ba36eb502b | ||
|
|
2c9a2bd30c | ||
|
|
f35acee64b | ||
|
|
a4c02a747f | ||
|
|
66b1e2cdcb | ||
|
|
81eca1c6e0 | ||
|
|
89f2b3b68c | ||
|
|
549bd901da | ||
|
|
6aad2d3aa2 | ||
|
|
09959e3ac3 | ||
|
|
7014462d42 | ||
|
|
62417b88ba | ||
|
|
bf0b5c9907 | ||
|
|
5347c3ef6c | ||
|
|
194292c083 | ||
|
|
7d023dba1e | ||
|
|
9c63cadf29 | ||
|
|
88b7501b4d | ||
|
|
8f53187a3c | ||
|
|
ef8059b3b1 | ||
|
|
8627233a17 | ||
|
|
2ece25dcb6 | ||
|
|
0eccd799c7 | ||
|
|
2e8c333374 | ||
|
|
671b25a087 | ||
|
|
4a314326fb | ||
|
|
d0270a3c9e | ||
|
|
71fc44e7a6 | ||
|
|
d6f5c73b9d | ||
|
|
d7908bb5da | ||
|
|
ed5391076c | ||
|
|
4a190e962a | ||
|
|
4644dbb404 | ||
|
|
5c6b419452 | ||
|
|
048d132da2 | ||
|
|
dd154a3004 | ||
|
|
8dbcf4bb7f | ||
|
|
c0f825a587 | ||
|
|
2b3dd5e7b9 | ||
|
|
5d1aa99d75 | ||
|
|
4be47fced5 | ||
|
|
66fc8ee70e | ||
|
|
09fc6956d8 | ||
|
|
501ed13f8a | ||
|
|
61132928b5 | ||
|
|
21b009c833 | ||
|
|
c616b981f1 | ||
|
|
93d16cf35c | ||
|
|
bd7cf3284b | ||
|
|
a0e6c4ff2f | ||
|
|
88fbb616b5 | ||
|
|
7efea2acc9 | ||
|
|
907f288815 | ||
|
|
2fea400060 | ||
|
|
f695835c61 | ||
|
|
47d47a0bfd | ||
|
|
540d5642a1 | ||
|
|
2ec2a14706 | ||
|
|
f7110497d3 | ||
|
|
c9326697f6 | ||
|
|
c2982cf31b | ||
|
|
8c69b3b9c4 | ||
|
|
24987be78e | ||
|
|
defc625324 | ||
|
|
eee91d5f2d | ||
|
|
a65202c653 | ||
|
|
ffaad142e8 |
@ -1,3 +0,0 @@
|
|||||||
.git
|
|
||||||
README.md
|
|
||||||
node_modules
|
|
||||||
@ -1,6 +1,7 @@
|
|||||||
|
.git
|
||||||
Dockerfile
|
Dockerfile
|
||||||
.dockerignore
|
.dockerignore
|
||||||
node_modules
|
node_modules
|
||||||
npm-debug.log
|
*.log
|
||||||
dist
|
dist
|
||||||
README.md
|
README.md
|
||||||
@ -2,14 +2,14 @@
|
|||||||
# Make sure you update both files!
|
# Make sure you update both files!
|
||||||
|
|
||||||
FROM node:alpine AS builder
|
FROM node:alpine AS builder
|
||||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
RUN corepack enable && corepack prepare pnpm@8.9.0 --activate
|
||||||
ENV PNPM_HOME=/usr/local/bin
|
ENV PNPM_HOME=/usr/local/bin
|
||||||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
# 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
|
RUN apk add --no-cache libc6-compat
|
||||||
RUN apk update
|
RUN apk update
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN pnpm add -g turbo dotenv-cli
|
RUN pnpm add -g turbo@1.12.4 dotenv-cli
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN turbo prune --scope=api --docker
|
RUN turbo prune --scope=api --docker
|
||||||
|
|
||||||
@ -31,7 +31,6 @@ RUN pnpm install
|
|||||||
# Build the project and its dependencies
|
# Build the project and its dependencies
|
||||||
COPY --from=builder /app/out/full/ .
|
COPY --from=builder /app/out/full/ .
|
||||||
COPY turbo.json turbo.json
|
COPY turbo.json turbo.json
|
||||||
COPY .env .env
|
|
||||||
RUN pnpm dotenv -e .env turbo run build --filter=api...
|
RUN pnpm dotenv -e .env turbo run build --filter=api...
|
||||||
|
|
||||||
FROM node:alpine AS runner
|
FROM node:alpine AS runner
|
||||||
|
|||||||
@ -45,6 +45,7 @@
|
|||||||
"fastify": "^4.26.1",
|
"fastify": "^4.26.1",
|
||||||
"jest": "^29.5.0",
|
"jest": "^29.5.0",
|
||||||
"prettier": "^3.0.0",
|
"prettier": "^3.0.0",
|
||||||
|
"shared": "workspace:*",
|
||||||
"source-map-support": "^0.5.21",
|
"source-map-support": "^0.5.21",
|
||||||
"supertest": "^6.3.3",
|
"supertest": "^6.3.3",
|
||||||
"ts-jest": "29.1.1",
|
"ts-jest": "29.1.1",
|
||||||
|
|||||||
@ -14,6 +14,7 @@ export const queryTTL: Record<string, number | false> = {
|
|||||||
GetDealerPerson: seconds().fromHours(1),
|
GetDealerPerson: seconds().fromHours(1),
|
||||||
GetDealerPersons: seconds().fromHours(1),
|
GetDealerPersons: seconds().fromHours(1),
|
||||||
GetDealers: seconds().fromMinutes(15),
|
GetDealers: seconds().fromMinutes(15),
|
||||||
|
GetEltInsuranceRules: seconds().fromHours(12),
|
||||||
GetFuelCards: seconds().fromHours(12),
|
GetFuelCards: seconds().fromHours(12),
|
||||||
GetGPSBrands: seconds().fromHours(24),
|
GetGPSBrands: seconds().fromHours(24),
|
||||||
GetGPSModels: seconds().fromHours(24),
|
GetGPSModels: seconds().fromHours(24),
|
||||||
@ -32,6 +33,7 @@ export const queryTTL: Record<string, number | false> = {
|
|||||||
GetOpportunities: false,
|
GetOpportunities: false,
|
||||||
GetOpportunity: false,
|
GetOpportunity: false,
|
||||||
GetOpportunityUrl: seconds().fromHours(12),
|
GetOpportunityUrl: seconds().fromHours(12),
|
||||||
|
GetOsagoAddproductTypes: seconds().fromHours(12),
|
||||||
GetProduct: seconds().fromHours(12),
|
GetProduct: seconds().fromHours(12),
|
||||||
GetProducts: seconds().fromHours(12),
|
GetProducts: seconds().fromHours(12),
|
||||||
GetQuote: false,
|
GetQuote: false,
|
||||||
|
|||||||
@ -1,9 +1,21 @@
|
|||||||
import { queryTTL } from './lib/config';
|
import { queryTTL } from './lib/config';
|
||||||
import type { GQLRequest } from './types';
|
import type { GQLRequest, GQLResponse } from './types';
|
||||||
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||||
import { All, Controller, Inject, Req, Res } from '@nestjs/common';
|
import {
|
||||||
|
All,
|
||||||
|
Controller,
|
||||||
|
Delete,
|
||||||
|
Get,
|
||||||
|
HttpException,
|
||||||
|
HttpStatus,
|
||||||
|
Inject,
|
||||||
|
Query,
|
||||||
|
Req,
|
||||||
|
Res,
|
||||||
|
} from '@nestjs/common';
|
||||||
import type { Cache } from 'cache-manager';
|
import type { Cache } from 'cache-manager';
|
||||||
import { FastifyReply, FastifyRequest } from 'fastify';
|
import { FastifyReply, FastifyRequest } from 'fastify';
|
||||||
|
import type { QueryItem } from 'shared/types/cache';
|
||||||
import { env } from 'src/config/env';
|
import { env } from 'src/config/env';
|
||||||
|
|
||||||
type RedisStore = Omit<Cache, 'set'> & {
|
type RedisStore = Omit<Cache, 'set'> & {
|
||||||
@ -15,6 +27,7 @@ export class ProxyController {
|
|||||||
constructor(
|
constructor(
|
||||||
@Inject(CACHE_MANAGER) private readonly cacheManager: RedisStore,
|
@Inject(CACHE_MANAGER) private readonly cacheManager: RedisStore,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@All('/graphql')
|
@All('/graphql')
|
||||||
public async graphql(@Req() req: FastifyRequest, @Res() reply: FastifyReply) {
|
public async graphql(@Req() req: FastifyRequest, @Res() reply: FastifyReply) {
|
||||||
const { operationName, query, variables } = req.body as GQLRequest;
|
const { operationName, query, variables } = req.body as GQLRequest;
|
||||||
@ -34,11 +47,81 @@ export class ProxyController {
|
|||||||
method: req.method,
|
method: req.method,
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await response.json();
|
const data = (await response.json()) as GQLResponse;
|
||||||
|
|
||||||
|
if (!response.ok || data?.error || data?.errors?.length)
|
||||||
|
throw new HttpException(
|
||||||
|
response.statusText,
|
||||||
|
response.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
);
|
||||||
|
|
||||||
const ttl = queryTTL[operationName];
|
const ttl = queryTTL[operationName];
|
||||||
if (data && ttl !== false)
|
if (data && ttl !== false)
|
||||||
await this.cacheManager.set(key, data, { ttl: ttl || env.CACHE_TTL });
|
await this.cacheManager.set(key, data, { ttl: ttl || env.CACHE_TTL });
|
||||||
|
|
||||||
return reply.send(data);
|
return reply.send(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('/get-queries')
|
||||||
|
public async getQueriesList(@Res() reply: FastifyReply) {
|
||||||
|
const res = await this.getAllQueries();
|
||||||
|
|
||||||
|
return reply.send(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getAllQueries() {
|
||||||
|
const list = await this.cacheManager.store.keys('*');
|
||||||
|
|
||||||
|
return (Object.keys(queryTTL) as Array<keyof typeof queryTTL>).reduce(
|
||||||
|
(acc, queryName) => {
|
||||||
|
const queries = list.filter((x) => x.split(' ').at(0) === queryName);
|
||||||
|
if (queries.length) {
|
||||||
|
const ttl = queryTTL[queryName];
|
||||||
|
acc[queryName] = { queries, ttl };
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, QueryItem>,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete('/delete-query')
|
||||||
|
public async deleteQuery(
|
||||||
|
@Query('queryKey') queryKey: string,
|
||||||
|
@Res() reply: FastifyReply,
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
await this.cacheManager.del(queryKey);
|
||||||
|
|
||||||
|
return reply.send('ok');
|
||||||
|
} catch (error) {
|
||||||
|
throw new HttpException(error, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete('/reset')
|
||||||
|
public async reset(@Res() reply: FastifyReply) {
|
||||||
|
try {
|
||||||
|
await this.cacheManager.reset();
|
||||||
|
|
||||||
|
return reply.send('ok');
|
||||||
|
} catch (error) {
|
||||||
|
throw new HttpException(error, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('/get-query')
|
||||||
|
public async getQueryValue(
|
||||||
|
@Query('queryKey') queryKey: string,
|
||||||
|
@Res() reply: FastifyReply,
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
const value = await this.cacheManager.get(queryKey);
|
||||||
|
|
||||||
|
return reply.send(value);
|
||||||
|
} catch (error) {
|
||||||
|
throw new HttpException(error, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,3 +3,9 @@ export type GQLRequest = {
|
|||||||
query: string;
|
query: string;
|
||||||
variables: string;
|
variables: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type GQLResponse = {
|
||||||
|
data: unknown;
|
||||||
|
error?: unknown;
|
||||||
|
errors?: unknown[];
|
||||||
|
};
|
||||||
|
|||||||
8
apps/web/.dockerignore
Normal file
8
apps/web/.dockerignore
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.git
|
||||||
|
Dockerfile
|
||||||
|
.dockerignore
|
||||||
|
node_modules
|
||||||
|
*.log
|
||||||
|
dist
|
||||||
|
.next
|
||||||
|
README.md
|
||||||
1
apps/web/.gitignore
vendored
1
apps/web/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
# Sentry Config File
|
# Sentry Config File
|
||||||
.sentryclirc
|
.sentryclirc
|
||||||
|
/styles/antd.min.css
|
||||||
@ -16,7 +16,7 @@ generates:
|
|||||||
object: true
|
object: true
|
||||||
defaultValue: true
|
defaultValue: true
|
||||||
scalars:
|
scalars:
|
||||||
Uuid: string
|
UUID: string
|
||||||
Decimal: number
|
Decimal: number
|
||||||
DateTime: string
|
DateTime: string
|
||||||
# exclude: './graphql/crm.schema.graphql'
|
# exclude: './graphql/crm.schema.graphql'
|
||||||
|
|||||||
19
apps/web/@types/errors.ts
Normal file
19
apps/web/@types/errors.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import elementsToValues from '@/Components/Calculation/config/map/values';
|
||||||
|
|
||||||
|
export const ERR_ELT_KASKO = 'ERR_ELT_KASKO';
|
||||||
|
export const ERR_ELT_OSAGO = 'ERR_ELT_OSAGO';
|
||||||
|
export const ERR_FINGAP_TABLE = 'ERR_FINGAP_TABLE';
|
||||||
|
export const ERR_INSURANCE_TABLE = 'ERR_INSURANCE_TABLE';
|
||||||
|
export const ERR_PAYMENTS_TABLE = 'ERR_PAYMENTS_TABLE';
|
||||||
|
|
||||||
|
export const ERROR_TABLE_KEYS = [
|
||||||
|
ERR_ELT_KASKO,
|
||||||
|
ERR_ELT_OSAGO,
|
||||||
|
ERR_FINGAP_TABLE,
|
||||||
|
ERR_INSURANCE_TABLE,
|
||||||
|
ERR_PAYMENTS_TABLE,
|
||||||
|
];
|
||||||
|
|
||||||
|
export const ERROR_ELEMENTS_KEYS = Object.keys(elementsToValues);
|
||||||
|
|
||||||
|
export const ERROR_KEYS = [...ERROR_ELEMENTS_KEYS, ...ERROR_TABLE_KEYS];
|
||||||
77
apps/web/Components/Admin/Cache/Query.tsx
Normal file
77
apps/web/Components/Admin/Cache/Query.tsx
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
import * as cacheApi from '@/api/cache/query';
|
||||||
|
import { min } from '@/styles/mq';
|
||||||
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
import { memo, useState } from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { Button, Collapse } from 'ui/elements';
|
||||||
|
import { Flex } from 'ui/grid';
|
||||||
|
|
||||||
|
type QueryProps = {
|
||||||
|
readonly onDeleteQuery: () => Promise<void>;
|
||||||
|
readonly queryKey: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const StyledPre = styled.pre`
|
||||||
|
max-height: 300px;
|
||||||
|
overflow-y: auto;
|
||||||
|
|
||||||
|
${min('desktop')} {
|
||||||
|
max-height: 800px;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const Query = memo(({ onDeleteQuery, queryKey }: QueryProps) => {
|
||||||
|
const { data, refetch } = useQuery({
|
||||||
|
enabled: false,
|
||||||
|
queryFn: ({ signal }) => signal && cacheApi.getQueryValue(queryKey, { signal }),
|
||||||
|
queryKey: ['admin', 'cache', 'query', queryKey],
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [activeKey, setActiveKey] = useState<string | undefined>(undefined);
|
||||||
|
const [deletePending, setDeletePending] = useState(false);
|
||||||
|
|
||||||
|
const content = (
|
||||||
|
<>
|
||||||
|
<StyledPre>{JSON.stringify(data, null, 2)}</StyledPre>
|
||||||
|
<Flex justifyContent="flex-end">
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
danger
|
||||||
|
disabled={deletePending}
|
||||||
|
onClick={() => {
|
||||||
|
setDeletePending(true);
|
||||||
|
onDeleteQuery().finally(() => {
|
||||||
|
setDeletePending(false);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Удалить
|
||||||
|
</Button>
|
||||||
|
</Flex>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Collapse
|
||||||
|
bordered={false}
|
||||||
|
activeKey={activeKey}
|
||||||
|
items={[
|
||||||
|
{
|
||||||
|
children: data ? content : 'Загрузка...',
|
||||||
|
key: queryKey,
|
||||||
|
label: queryKey,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
onChange={() => {
|
||||||
|
if (activeKey) {
|
||||||
|
setActiveKey(undefined);
|
||||||
|
} else {
|
||||||
|
setActiveKey(queryKey);
|
||||||
|
|
||||||
|
refetch();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
22
apps/web/Components/Admin/Cache/QueryList.tsx
Normal file
22
apps/web/Components/Admin/Cache/QueryList.tsx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { Query } from './Query';
|
||||||
|
import * as cacheApi from '@/api/cache/query';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import type { QueryItem } from 'shared/types/cache';
|
||||||
|
|
||||||
|
type QueryListProps = QueryItem;
|
||||||
|
|
||||||
|
export const QueryList = ({ queries }: QueryListProps) => {
|
||||||
|
const [deletedQueries, setDeletedQueries] = useState<QueryItem['queries']>([]);
|
||||||
|
|
||||||
|
function handleDeleteQuery(queryKey: string) {
|
||||||
|
return cacheApi
|
||||||
|
.deleteQuery(queryKey)
|
||||||
|
.then(() => setDeletedQueries([...deletedQueries, queryKey]));
|
||||||
|
}
|
||||||
|
|
||||||
|
const activeQueries = queries.filter((queryKey) => !deletedQueries.includes(queryKey));
|
||||||
|
|
||||||
|
return activeQueries.map((queryKey) => (
|
||||||
|
<Query key={queryKey} queryKey={queryKey} onDeleteQuery={() => handleDeleteQuery(queryKey)} />
|
||||||
|
));
|
||||||
|
};
|
||||||
24
apps/web/Components/Admin/Cache/ReloadButton.tsx
Normal file
24
apps/web/Components/Admin/Cache/ReloadButton.tsx
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import { Button } from 'ui/elements';
|
||||||
|
import { ReloadOutlined } from 'ui/elements/icons';
|
||||||
|
|
||||||
|
export function ReloadButton({ onClick }: { readonly onClick: () => Promise<unknown> }) {
|
||||||
|
const [pending, setPending] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
loading={pending}
|
||||||
|
onClick={() => {
|
||||||
|
setPending(true);
|
||||||
|
onClick().finally(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
setPending(false);
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
icon={<ReloadOutlined rev="" />}
|
||||||
|
>
|
||||||
|
Обновить
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
70
apps/web/Components/Admin/Cache/index.tsx
Normal file
70
apps/web/Components/Admin/Cache/index.tsx
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import Background from '../../Layout/Background';
|
||||||
|
import { useFilteredQueries } from './lib/hooks';
|
||||||
|
import { QueryList } from './QueryList';
|
||||||
|
import { reset } from '@/api/cache/query';
|
||||||
|
import { min } from '@/styles/mq';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { Button, Collapse, Divider, Input } from 'ui/elements';
|
||||||
|
|
||||||
|
const Wrapper = styled(Background)`
|
||||||
|
padding: 4px 6px;
|
||||||
|
width: 100vw;
|
||||||
|
|
||||||
|
${min('tablet')} {
|
||||||
|
min-height: 790px;
|
||||||
|
}
|
||||||
|
|
||||||
|
${min('laptop')} {
|
||||||
|
padding: 4px 18px 10px;
|
||||||
|
width: 1280px;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Flex = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ButtonWrapper = styled.div`
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export function Cache() {
|
||||||
|
const { filteredQueries, refetch, setFilterString } = useFilteredQueries();
|
||||||
|
|
||||||
|
function handleDeleteQuery() {
|
||||||
|
return reset().then(() => refetch());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!filteredQueries) {
|
||||||
|
return <div>Загрузка...</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Wrapper>
|
||||||
|
<Divider>Управление кэшем</Divider>
|
||||||
|
<Flex>
|
||||||
|
<Input
|
||||||
|
placeholder="Поиск по запросу"
|
||||||
|
allowClear
|
||||||
|
onChange={(e) => setFilterString(e.target.value)}
|
||||||
|
/>
|
||||||
|
<Collapse
|
||||||
|
accordion
|
||||||
|
items={Object.keys(filteredQueries).map((queryGroupName) => ({
|
||||||
|
children: <QueryList {...filteredQueries[queryGroupName]} />,
|
||||||
|
key: queryGroupName,
|
||||||
|
label: queryGroupName,
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
<ButtonWrapper>
|
||||||
|
<Button type="primary" danger disabled={false} onClick={() => handleDeleteQuery()}>
|
||||||
|
Очистить кэш
|
||||||
|
</Button>
|
||||||
|
</ButtonWrapper>
|
||||||
|
</Flex>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
30
apps/web/Components/Admin/Cache/lib/hooks.tsx
Normal file
30
apps/web/Components/Admin/Cache/lib/hooks.tsx
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { filterQueries } from './utils';
|
||||||
|
import * as cacheApi from '@/api/cache/query';
|
||||||
|
import type { ResponseQueries } from '@/api/cache/types';
|
||||||
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useDebounce } from 'use-debounce';
|
||||||
|
|
||||||
|
export function useFilteredQueries() {
|
||||||
|
const { data: queries, refetch } = useQuery({
|
||||||
|
enabled: false,
|
||||||
|
queryFn: ({ signal }) => signal && cacheApi.getQueries({ signal }),
|
||||||
|
queryKey: ['admin', 'cache', 'queries'],
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [filteredQueries, setFilteredQueries] = useState<ResponseQueries | undefined>(queries);
|
||||||
|
const [filterString, setFilterString] = useState('');
|
||||||
|
const [debouncedFilterString] = useDebounce(filterString, 350);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!debouncedFilterString) {
|
||||||
|
setFilteredQueries(queries);
|
||||||
|
}
|
||||||
|
if (queries && debouncedFilterString) {
|
||||||
|
setFilteredQueries(filterQueries(queries, debouncedFilterString));
|
||||||
|
}
|
||||||
|
}, [debouncedFilterString, queries]);
|
||||||
|
|
||||||
|
return { filteredQueries, queries, refetch, setFilterString };
|
||||||
|
}
|
||||||
23
apps/web/Components/Admin/Cache/lib/utils.tsx
Normal file
23
apps/web/Components/Admin/Cache/lib/utils.tsx
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import type { ResponseQueries } from '@/api/cache/types';
|
||||||
|
|
||||||
|
export function filterQueries(queriesObj: ResponseQueries, searchStr: string): ResponseQueries {
|
||||||
|
const filteredObj: ResponseQueries = {};
|
||||||
|
|
||||||
|
for (const key in queriesObj) {
|
||||||
|
if (key.includes(searchStr)) {
|
||||||
|
filteredObj[key] = queriesObj[key];
|
||||||
|
} else {
|
||||||
|
const queries: string[] = [];
|
||||||
|
queriesObj[key].queries.forEach((queryKey) => {
|
||||||
|
if (queryKey.toLowerCase().includes(searchStr.toLowerCase())) {
|
||||||
|
queries.push(queryKey);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (queries.length) {
|
||||||
|
filteredObj[key] = { ...queriesObj[key], queries };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return filteredObj;
|
||||||
|
}
|
||||||
17
apps/web/Components/Admin/Layout.tsx
Normal file
17
apps/web/Components/Admin/Layout.tsx
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { min } from '@/styles/mq';
|
||||||
|
import type { PropsWithChildren } from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const Flex = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
${min('laptop')} {
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export function Layout({ children }: PropsWithChildren) {
|
||||||
|
return <Flex>{children}</Flex>;
|
||||||
|
}
|
||||||
2
apps/web/Components/Admin/index.ts
Normal file
2
apps/web/Components/Admin/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from './Cache';
|
||||||
|
export * from './Layout';
|
||||||
@ -7,7 +7,7 @@ export const rows: FormTabRows = [
|
|||||||
{
|
{
|
||||||
title: 'Регистрация',
|
title: 'Регистрация',
|
||||||
},
|
},
|
||||||
[['radioObjectRegistration', 'radioTypePTS'], { gridTemplateColumns: ['1fr 1fr'] }],
|
[['radioObjectRegistration', 'radioTypePTS'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
||||||
[['selectRegionRegistration', 'selectTownRegistration', 'selectObjectRegionRegistration']],
|
[['selectRegionRegistration', 'selectTownRegistration', 'selectObjectRegionRegistration']],
|
||||||
[['selectObjectCategoryTax', 'selectObjectTypeTax', 'tbxVehicleTaxInYear']],
|
[['selectObjectCategoryTax', 'selectObjectTypeTax', 'tbxVehicleTaxInYear']],
|
||||||
[['tbxLeaseObjectYear', 'tbxLeaseObjectMotorPower', 'tbxVehicleTaxInLeasingPeriod']],
|
[['tbxLeaseObjectYear', 'tbxLeaseObjectMotorPower', 'tbxVehicleTaxInLeasingPeriod']],
|
||||||
|
|||||||
@ -12,5 +12,6 @@ export const rows: FormTabRows = [
|
|||||||
[['cbxInsurance', 'cbxRegistrationQuote'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
[['cbxInsurance', 'cbxRegistrationQuote'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
||||||
[['cbxTechnicalCardQuote', 'cbxNSIB'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
[['cbxTechnicalCardQuote', 'cbxNSIB'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
||||||
[['cbxQuoteRedemptionGraph', 'cbxShowFinGAP'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
[['cbxQuoteRedemptionGraph', 'cbxShowFinGAP'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
||||||
|
[['cbxQuoteShowAcceptLimit'], { gridTemplateColumns: ['1fr', '1fr 1fr'] }],
|
||||||
[['tbxQuoteName', 'radioQuoteContactGender'], { gridTemplateColumns: ['1fr', '2fr 1fr'] }],
|
[['tbxQuoteName', 'radioQuoteContactGender'], { gridTemplateColumns: ['1fr', '2fr 1fr'] }],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -7,16 +7,16 @@ import { Table } from 'ui/elements';
|
|||||||
|
|
||||||
export const PolicyTable = observer(
|
export const PolicyTable = observer(
|
||||||
({
|
({
|
||||||
storeSelector,
|
|
||||||
onSelectRow,
|
onSelectRow,
|
||||||
|
storeSelector,
|
||||||
...props
|
...props
|
||||||
}: {
|
}: {
|
||||||
columns: typeof columns;
|
columns: typeof columns;
|
||||||
onSelectRow: (row: Row) => void;
|
onSelectRow: (row: Row) => void;
|
||||||
storeSelector: StoreSelector;
|
storeSelector: StoreSelector;
|
||||||
}) => {
|
}) => {
|
||||||
const { $tables, $process } = useStore();
|
const { $process, $tables } = useStore();
|
||||||
const { getRows, setSelectedKey, getSelectedRow } = storeSelector($tables.elt);
|
const { getRows, getSelectedRow, setSelectedKey } = storeSelector($tables.elt);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table
|
<Table
|
||||||
@ -37,7 +37,12 @@ export const PolicyTable = observer(
|
|||||||
$process.add('ELT');
|
$process.add('ELT');
|
||||||
setSelectedKey(record.key);
|
setSelectedKey(record.key);
|
||||||
onSelectRow(record);
|
onSelectRow(record);
|
||||||
message.success({ content: 'Выбранный расчет ЭЛТ применен', key: record.key });
|
message.success({
|
||||||
|
content: 'Выбранный расчет ЭЛТ применен',
|
||||||
|
duration: 1,
|
||||||
|
key: record.key,
|
||||||
|
onClick: () => message.destroy(record.key),
|
||||||
|
});
|
||||||
$process.delete('ELT');
|
$process.delete('ELT');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,126 +1,41 @@
|
|||||||
/* eslint-disable sonarjs/cognitive-complexity */
|
/* eslint-disable sonarjs/cognitive-complexity */
|
||||||
import { PolicyTable, ReloadButton, Validation } from './Components';
|
import { PolicyTable, ReloadButton, Validation } from './Components';
|
||||||
import { columns } from './lib/config';
|
import { columns } from './lib/config';
|
||||||
import { makeEltKaskoRequest } from './lib/make-request';
|
import { resetRow } from './lib/tools';
|
||||||
import type { Row, StoreSelector } from './types';
|
import type { Row, StoreSelector } from './types';
|
||||||
import { getEltKasko } from '@/api/elt/query';
|
|
||||||
import { MAX_FRANCHISE, MAX_INSURANCE, MIN_INSURANCE } from '@/constants/values';
|
|
||||||
import helper from '@/process/elt/lib/helper';
|
|
||||||
import { useStore } from '@/stores/hooks';
|
import { useStore } from '@/stores/hooks';
|
||||||
import { defaultRow } from '@/stores/tables/elt/default-values';
|
import { trpcClient } from '@/trpc/client';
|
||||||
import { useApolloClient } from '@apollo/client';
|
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import { omit, sift } from 'radash';
|
|
||||||
import { useCallback } from 'react';
|
|
||||||
import { Flex } from 'ui/grid';
|
import { Flex } from 'ui/grid';
|
||||||
|
|
||||||
const storeSelector: StoreSelector = ({ kasko }) => kasko;
|
const storeSelector: StoreSelector = ({ kasko }) => kasko;
|
||||||
|
|
||||||
const initialData = {
|
|
||||||
...omit(defaultRow, ['name', 'key', 'id']),
|
|
||||||
error: null,
|
|
||||||
kaskoSum: 0,
|
|
||||||
paymentPeriods: [
|
|
||||||
{
|
|
||||||
kaskoSum: 0,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
export const Kasko = observer(() => {
|
export const Kasko = observer(() => {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { $tables, $calculation } = store;
|
const { $calculation, $tables } = store;
|
||||||
const apolloClient = useApolloClient();
|
|
||||||
const { init } = helper({ apolloClient, store });
|
|
||||||
|
|
||||||
const handleOnClick = useCallback(async () => {
|
const calculateKasko = trpcClient.eltKasko.useMutation({
|
||||||
$tables.elt.kasko.abortController?.abort();
|
onError() {
|
||||||
$tables.elt.kasko.abortController = new AbortController();
|
$tables.elt.kasko.setRows(
|
||||||
|
$tables.elt.kasko.getRows.map((row) => ({ ...row, status: 'error' }))
|
||||||
const { kasko } = await init();
|
|
||||||
$tables.elt.kasko.setRows(kasko);
|
|
||||||
const kaskoCompanyIds = sift(
|
|
||||||
$tables.insurance
|
|
||||||
.row('kasko')
|
|
||||||
.getOptions('insuranceCompany')
|
|
||||||
.map((x) => x.value)
|
|
||||||
);
|
);
|
||||||
const values = $calculation.$values.getValues();
|
},
|
||||||
|
onMutate: () => {
|
||||||
|
const rows = $tables.elt.kasko.getRows;
|
||||||
|
$tables.elt.kasko.setRows(rows.map((row) => ({ ...resetRow(row), status: 'fetching' })));
|
||||||
|
},
|
||||||
|
onSuccess: ({ rows }) => {
|
||||||
|
$tables.elt.kasko.setRows(rows);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
kaskoCompanyIds.forEach((key) => {
|
function handleOnClick() {
|
||||||
const row = $tables.elt.kasko.getRow(key);
|
calculateKasko.mutate({
|
||||||
if (row) {
|
calculation: {
|
||||||
$tables.elt.kasko.setRow({ key, status: 'fetching' });
|
values: store.$calculation.$values.getValues(),
|
||||||
makeEltKaskoRequest({ apolloClient, store }, row)
|
},
|
||||||
.then((payload) =>
|
|
||||||
getEltKasko(payload, { signal: $tables.elt.kasko.abortController?.signal })
|
|
||||||
)
|
|
||||||
.then((res) => {
|
|
||||||
if (res) {
|
|
||||||
const {
|
|
||||||
kaskoSum = 0,
|
|
||||||
message,
|
|
||||||
skCalcId,
|
|
||||||
totalFranchise = 0,
|
|
||||||
requestId,
|
|
||||||
paymentPeriods,
|
|
||||||
} = res;
|
|
||||||
let { error } = res;
|
|
||||||
|
|
||||||
if (totalFranchise > MAX_FRANCHISE) {
|
|
||||||
error ||= `Франшиза по страховке превышает максимально допустимое значение: ${Intl.NumberFormat(
|
|
||||||
'ru',
|
|
||||||
{
|
|
||||||
currency: 'RUB',
|
|
||||||
style: 'currency',
|
|
||||||
}
|
|
||||||
).format(MAX_FRANCHISE)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kaskoSum > MAX_INSURANCE) {
|
|
||||||
error ||= `Сумма по страховке превышает максимально допустимое значение по стоимости КАСКО: ${Intl.NumberFormat(
|
|
||||||
'ru',
|
|
||||||
{
|
|
||||||
currency: 'RUB',
|
|
||||||
style: 'currency',
|
|
||||||
}
|
|
||||||
).format(MAX_INSURANCE)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kaskoSum < MIN_INSURANCE) {
|
|
||||||
error ||= `Сумма по страховке не должна быть меньше допустимого значения по стоимости КАСКО: ${Intl.NumberFormat(
|
|
||||||
'ru',
|
|
||||||
{
|
|
||||||
currency: 'RUB',
|
|
||||||
style: 'currency',
|
|
||||||
}
|
|
||||||
).format(MIN_INSURANCE)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tables.elt.kasko.setRow({
|
|
||||||
key,
|
|
||||||
message: error || message,
|
|
||||||
numCalc: 0,
|
|
||||||
requestId,
|
|
||||||
skCalcId,
|
|
||||||
status: error ? 'error' : null,
|
|
||||||
sum: values.leasingPeriod <= 16 ? kaskoSum : paymentPeriods?.[0]?.kaskoSum || 0,
|
|
||||||
totalFranchise,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
const _err = error as Error;
|
|
||||||
$tables.elt.kasko.setRow({
|
|
||||||
...initialData,
|
|
||||||
key,
|
|
||||||
message: _err.message || String(error),
|
|
||||||
status: 'error',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, [$calculation.$values, $tables.elt.kasko, $tables.insurance, apolloClient, init, store]);
|
|
||||||
|
|
||||||
function handleOnSelectRow(row: Row) {
|
function handleOnSelectRow(row: Row) {
|
||||||
$tables.insurance.row('kasko').column('insuranceCompany').setValue(row.key);
|
$tables.insurance.row('kasko').column('insuranceCompany').setValue(row.key);
|
||||||
|
|||||||
@ -1,98 +1,42 @@
|
|||||||
|
/* eslint-disable no-negated-condition */
|
||||||
/* eslint-disable sonarjs/cognitive-complexity */
|
/* eslint-disable sonarjs/cognitive-complexity */
|
||||||
import { PolicyTable, ReloadButton, Validation } from './Components';
|
import { PolicyTable, ReloadButton, Validation } from './Components';
|
||||||
import { columns } from './lib/config';
|
import { columns } from './lib/config';
|
||||||
import { makeEltOsagoRequest } from './lib/make-request';
|
import { resetRow } from './lib/tools';
|
||||||
import type { Row, StoreSelector } from './types';
|
import type { Row, StoreSelector } from './types';
|
||||||
import { getEltOsago } from '@/api/elt/query';
|
|
||||||
import { MAX_INSURANCE, MIN_INSURANCE } from '@/constants/values';
|
|
||||||
import helper from '@/process/elt/lib/helper';
|
|
||||||
import { useStore } from '@/stores/hooks';
|
import { useStore } from '@/stores/hooks';
|
||||||
import { defaultRow } from '@/stores/tables/elt/default-values';
|
import { trpcClient } from '@/trpc/client';
|
||||||
import { useApolloClient } from '@apollo/client';
|
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import { omit, sift } from 'radash';
|
|
||||||
import { useCallback } from 'react';
|
|
||||||
import { Flex } from 'ui/grid';
|
import { Flex } from 'ui/grid';
|
||||||
|
|
||||||
const storeSelector: StoreSelector = ({ osago }) => osago;
|
const storeSelector: StoreSelector = ({ osago }) => osago;
|
||||||
|
|
||||||
const initialData = {
|
|
||||||
...omit(defaultRow, ['name', 'key', 'id']),
|
|
||||||
error: null,
|
|
||||||
premiumSum: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const Osago = observer(() => {
|
export const Osago = observer(() => {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { $tables } = store;
|
const { $tables } = store;
|
||||||
const apolloClient = useApolloClient();
|
|
||||||
const { init } = helper({ apolloClient, store });
|
|
||||||
|
|
||||||
const handleOnClick = useCallback(async () => {
|
const calculateOsago = trpcClient.eltOsago.useMutation({
|
||||||
$tables.elt.osago.abortController?.abort();
|
onError() {
|
||||||
$tables.elt.osago.abortController = new AbortController();
|
$tables.elt.osago.setRows(
|
||||||
|
$tables.elt.osago.getRows.map((row) => ({ ...row, status: 'error' }))
|
||||||
const { osago } = await init();
|
|
||||||
$tables.elt.osago.setRows(osago);
|
|
||||||
const osagoCompanyIds = sift(
|
|
||||||
$tables.insurance
|
|
||||||
.row('osago')
|
|
||||||
.getOptions('insuranceCompany')
|
|
||||||
.map((x) => x.value)
|
|
||||||
);
|
);
|
||||||
osagoCompanyIds.forEach((key) => {
|
},
|
||||||
const row = $tables.elt.osago.getRow(key);
|
onMutate: () => {
|
||||||
if (row) {
|
const rows = $tables.elt.osago.getRows;
|
||||||
row.status = 'fetching';
|
$tables.elt.osago.setRows(rows.map((row) => ({ ...resetRow(row), status: 'fetching' })));
|
||||||
$tables.elt.osago.setRow(row);
|
},
|
||||||
makeEltOsagoRequest({ apolloClient, store }, row)
|
onSuccess: ({ rows }) => {
|
||||||
.then((payload) =>
|
$tables.elt.osago.setRows(rows);
|
||||||
getEltOsago(payload, { signal: $tables.elt.osago.abortController.signal })
|
},
|
||||||
)
|
});
|
||||||
.then((res) => {
|
|
||||||
if (res) {
|
async function handleOnClick() {
|
||||||
const { numCalc, premiumSum = 0, message, skCalcId } = res;
|
calculateOsago.mutate({
|
||||||
let { error } = res;
|
calculation: {
|
||||||
if (premiumSum > MAX_INSURANCE) {
|
values: store.$calculation.$values.getValues(),
|
||||||
error ||= `Сумма по страховке превышает максимально допустимое значение по стоимости ОСАГО: ${Intl.NumberFormat(
|
},
|
||||||
'ru',
|
|
||||||
{
|
|
||||||
currency: 'RUB',
|
|
||||||
style: 'currency',
|
|
||||||
}
|
|
||||||
).format(MAX_INSURANCE)}`;
|
|
||||||
}
|
|
||||||
if (premiumSum < MIN_INSURANCE) {
|
|
||||||
error ||= `Сумма по страховке не должна быть меньше допустимого значения по стоимости ОСАГО: ${Intl.NumberFormat(
|
|
||||||
'ru',
|
|
||||||
{
|
|
||||||
currency: 'RUB',
|
|
||||||
style: 'currency',
|
|
||||||
}
|
|
||||||
).format(MIN_INSURANCE)}`;
|
|
||||||
}
|
|
||||||
$tables.elt.osago.setRow({
|
|
||||||
key,
|
|
||||||
message: error || message,
|
|
||||||
numCalc,
|
|
||||||
skCalcId,
|
|
||||||
status: error ? 'error' : null,
|
|
||||||
sum: premiumSum,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
const _err = error as Error;
|
|
||||||
$tables.elt.osago.setRow({
|
|
||||||
...initialData,
|
|
||||||
key,
|
|
||||||
message: _err.message || String(error),
|
|
||||||
status: 'error',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, [$tables.elt.osago, $tables.insurance, apolloClient, init, store]);
|
|
||||||
|
|
||||||
function handleOnSelectRow(row: Row) {
|
function handleOnSelectRow(row: Row) {
|
||||||
$tables.insurance.row('osago').column('insuranceCompany').setValue(row.key);
|
$tables.insurance.row('osago').column('insuranceCompany').setValue(row.key);
|
||||||
|
|||||||
@ -1,10 +1,7 @@
|
|||||||
import type { RowSchema } from '@/config/schema/elt';
|
import type { Row } from '../types';
|
||||||
import type { ColumnsType } from 'antd/lib/table';
|
import type { ColumnsType } from 'antd/lib/table';
|
||||||
import { CloseOutlined, LoadingOutlined } from 'ui/elements/icons';
|
import { CloseOutlined, LoadingOutlined } from 'ui/elements/icons';
|
||||||
import { Flex } from 'ui/grid';
|
import { Flex } from 'ui/grid';
|
||||||
import type { z } from 'zod';
|
|
||||||
|
|
||||||
type Row = z.infer<typeof RowSchema>;
|
|
||||||
|
|
||||||
const formatter = Intl.NumberFormat('ru', {
|
const formatter = Intl.NumberFormat('ru', {
|
||||||
currency: 'RUB',
|
currency: 'RUB',
|
||||||
|
|||||||
12
apps/web/Components/Calculation/Form/ELT/lib/tools.ts
Normal file
12
apps/web/Components/Calculation/Form/ELT/lib/tools.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import type { Row } from '@/Components/Calculation/Form/ELT/types';
|
||||||
|
import { defaultRow } from '@/stores/tables/elt/default-values';
|
||||||
|
|
||||||
|
export function resetRow(row: Row): Row {
|
||||||
|
return {
|
||||||
|
...defaultRow,
|
||||||
|
id: row.id,
|
||||||
|
key: row.key,
|
||||||
|
metodCalc: row.metodCalc,
|
||||||
|
name: row.name,
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -1,13 +1,14 @@
|
|||||||
import type { FormTabRows } from '../../lib/render-rows';
|
import type { FormTabRows } from '../../lib/render-rows';
|
||||||
|
import { transformRowsForMobile } from '../lib/utils';
|
||||||
|
|
||||||
export const id = 'insurance';
|
export const id = 'insurance';
|
||||||
export const title = 'Страхование';
|
export const title = 'Страхование';
|
||||||
|
|
||||||
export const rows: FormTabRows = [
|
export const rows: FormTabRows = [
|
||||||
[['tbxLeaseObjectYear', 'selectLeaseObjectUseFor', 'selectLegalClientRegion']],
|
[['tbxLeaseObjectYear', 'selectLeaseObjectUseFor', 'selectLegalClientRegion']],
|
||||||
[['selectEngineType', 'tbxInsFranchise', 'selectLegalClientTown']],
|
[['tbxMileage', 'tbxInsFranchise', 'selectLegalClientTown']],
|
||||||
[['selectLeaseObjectCategory', 'tbxMileage']],
|
[['selectGPSBrand', 'cbxWithTrailer', 'selectInsNSIB']],
|
||||||
[['tbxLeaseObjectMotorPower', 'cbxWithTrailer', 'selectGPSBrand']],
|
[['selectGPSModel', 'cbxInsDecentral', 'selectLeasingWithoutKasko']],
|
||||||
[['tbxEngineVolume', 'cbxInsDecentral', 'selectGPSModel']],
|
|
||||||
[['selectLeasingWithoutKasko', 'selectInsNSIB']],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const mobileRows = transformRowsForMobile(rows);
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
import renderFormRows from '../../lib/render-rows';
|
import renderFormRows from '../../lib/render-rows';
|
||||||
import { id, rows, title } from './config';
|
import { id, mobileRows, rows, title } from './config';
|
||||||
import FinGAPTable from './FinGAPTable';
|
import FinGAPTable from './FinGAPTable';
|
||||||
import InsuranceTable from './InsuranceTable';
|
import InsuranceTable from './InsuranceTable';
|
||||||
|
import { Media } from '@/styles/media';
|
||||||
import { Flex } from 'ui/grid';
|
import { Flex } from 'ui/grid';
|
||||||
|
|
||||||
function Insurance() {
|
function Insurance() {
|
||||||
const renderedRows = renderFormRows(rows);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex flexDirection="column">
|
<Flex flexDirection="column">
|
||||||
{renderedRows}
|
<Media lessThan="laptop">{renderFormRows(mobileRows)}</Media>
|
||||||
|
<Media greaterThanOrEqual="laptop">{renderFormRows(rows)}</Media>
|
||||||
<InsuranceTable />
|
<InsuranceTable />
|
||||||
<FinGAPTable />
|
<FinGAPTable />
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import type { FormTabRows } from '../../lib/render-rows';
|
import type { FormTabRows } from '../../lib/render-rows';
|
||||||
|
import { transformRowsForMobile } from '../lib/utils';
|
||||||
|
|
||||||
export const id = 'leasing-object';
|
export const id = 'leasing-object';
|
||||||
export const title = 'ПЛ';
|
export const title = 'ПЛ';
|
||||||
@ -16,3 +17,5 @@ export const rows: FormTabRows = [
|
|||||||
[['selectLeaseObjectCategory', 'tbxEngineVolume', 'tbxMileage']],
|
[['selectLeaseObjectCategory', 'tbxEngineVolume', 'tbxMileage']],
|
||||||
[['tbxMaxMass', 'tbxEngineHours', 'tbxVIN']],
|
[['tbxMaxMass', 'tbxEngineHours', 'tbxVIN']],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const mobileRows = transformRowsForMobile(rows);
|
||||||
|
|||||||
@ -1,8 +1,14 @@
|
|||||||
import renderFormRows from '../../lib/render-rows';
|
import renderFormRows from '../../lib/render-rows';
|
||||||
import { id, rows, title } from './config';
|
import { id, mobileRows, rows, title } from './config';
|
||||||
|
import { Media } from '@/styles/media';
|
||||||
|
|
||||||
function LeasingObject() {
|
function LeasingObject() {
|
||||||
return renderFormRows(rows);
|
return (
|
||||||
|
<>
|
||||||
|
<Media lessThan="laptop">{renderFormRows(mobileRows)}</Media>
|
||||||
|
<Media greaterThanOrEqual="laptop">{renderFormRows(rows)}</Media>
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import type { FormTabRows } from '../../lib/render-rows';
|
import type { FormTabRows } from '../../lib/render-rows';
|
||||||
|
import { transformRowsForMobile } from '../lib/utils';
|
||||||
|
|
||||||
export const id = 'supplier-agent';
|
export const id = 'supplier-agent';
|
||||||
export const title = 'Поставщик/агент';
|
export const title = 'Поставщик/агент';
|
||||||
@ -20,3 +21,5 @@ export const rows: FormTabRows = [
|
|||||||
[['selectCalcBrokerRewardCondition', 'selectFinDepartmentRewardCondtion'], defaultRowStyle],
|
[['selectCalcBrokerRewardCondition', 'selectFinDepartmentRewardCondtion'], defaultRowStyle],
|
||||||
[['tbxCalcBrokerRewardSum', 'tbxFinDepartmentRewardSumm'], defaultRowStyle],
|
[['tbxCalcBrokerRewardSum', 'tbxFinDepartmentRewardSumm'], defaultRowStyle],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const mobileRows = transformRowsForMobile(rows);
|
||||||
|
|||||||
@ -1,8 +1,14 @@
|
|||||||
import renderFormRows from '../../lib/render-rows';
|
import renderFormRows from '../../lib/render-rows';
|
||||||
import { id, rows, title } from './config';
|
import { id, mobileRows, rows, title } from './config';
|
||||||
|
import { Media } from '@/styles/media';
|
||||||
|
|
||||||
function Leasing() {
|
function Leasing() {
|
||||||
return renderFormRows(rows);
|
return (
|
||||||
|
<>
|
||||||
|
<Media lessThan="laptop">{renderFormRows(mobileRows)}</Media>
|
||||||
|
<Media greaterThanOrEqual="laptop">{renderFormRows(rows)}</Media>
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@ -8,7 +8,9 @@ import Payments from './Payments';
|
|||||||
import SupplierAgent from './SupplierAgent';
|
import SupplierAgent from './SupplierAgent';
|
||||||
import Unlimited from './Unlimited';
|
import Unlimited from './Unlimited';
|
||||||
import Background from '@/Components/Layout/Background';
|
import Background from '@/Components/Layout/Background';
|
||||||
|
import { useStore } from '@/stores/hooks';
|
||||||
import { min } from '@/styles/mq';
|
import { min } from '@/styles/mq';
|
||||||
|
import { memo } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { Tabs } from 'ui/elements';
|
import { Tabs } from 'ui/elements';
|
||||||
|
|
||||||
@ -44,13 +46,16 @@ const ComponentWrapper = styled.div`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function Form({ prune }) {
|
export const Form = memo(() => {
|
||||||
|
const { $process } = useStore();
|
||||||
|
|
||||||
|
const filteredTabs =
|
||||||
|
$process.has('Unlimited') === false ? formTabs.filter((x) => x.id !== 'unlimited') : formTabs;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Tabs type="card" tabBarGutter="5px">
|
<Tabs type="card" tabBarGutter="5px">
|
||||||
{formTabs
|
{filteredTabs.map(({ Component, id, title }) => (
|
||||||
.filter((tab) => !prune?.includes(tab.id))
|
|
||||||
.map(({ id, title, Component }) => (
|
|
||||||
<Tabs.TabPane tab={title} key={id}>
|
<Tabs.TabPane tab={title} key={id}>
|
||||||
<ComponentWrapper>
|
<ComponentWrapper>
|
||||||
<Component />
|
<Component />
|
||||||
@ -60,6 +65,4 @@ function Form({ prune }) {
|
|||||||
</Tabs>
|
</Tabs>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|
||||||
export default Form;
|
|
||||||
|
|||||||
32
apps/web/Components/Calculation/Form/lib/utils.js
Normal file
32
apps/web/Components/Calculation/Form/lib/utils.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {import('../../lib/render-rows').FormTabRows} rows
|
||||||
|
* @returns {import('../../lib/render-rows').FormTabRows}
|
||||||
|
*/
|
||||||
|
export function transformRowsForMobile(rows) {
|
||||||
|
const mobileRows = [];
|
||||||
|
let columnGroups = {};
|
||||||
|
|
||||||
|
rows.forEach((row) => {
|
||||||
|
if (Array.isArray(row)) {
|
||||||
|
row[0].forEach((item, index) => {
|
||||||
|
if (!columnGroups[index]) {
|
||||||
|
columnGroups[index] = [];
|
||||||
|
}
|
||||||
|
columnGroups[index].push(item);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Object.values(columnGroups).forEach((group) => {
|
||||||
|
mobileRows.push([group, { gridTemplateColumns: '1fr' }]);
|
||||||
|
});
|
||||||
|
columnGroups = {};
|
||||||
|
mobileRows.push(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.values(columnGroups).forEach((group) => {
|
||||||
|
mobileRows.push([group, { gridTemplateColumns: '1fr' }]);
|
||||||
|
});
|
||||||
|
|
||||||
|
return mobileRows;
|
||||||
|
}
|
||||||
@ -2,7 +2,7 @@ import { min } from '@/styles/mq';
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { Box } from 'ui/grid';
|
import { Box } from 'ui/grid';
|
||||||
|
|
||||||
export const Grid = styled(Box)`
|
export const Layout = styled(Box)`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
@ -17,8 +17,4 @@ export const Grid = styled(Box)`
|
|||||||
grid-template-columns: 2fr 1fr 1.5fr;
|
grid-template-columns: 2fr 1fr 1.5fr;
|
||||||
/* margin: 8px 5%; */
|
/* margin: 8px 5%; */
|
||||||
}
|
}
|
||||||
|
|
||||||
${min('desktop-xl')} {
|
|
||||||
margin: 8px 10% !important;
|
|
||||||
}
|
|
||||||
`;
|
`;
|
||||||
@ -7,6 +7,7 @@ export const titles: Record<keyof ResultValues, string> = {
|
|||||||
_resultContractEconomy: 'Экономика',
|
_resultContractEconomy: 'Экономика',
|
||||||
_resultContractEconomyWithVAT: 'Экономика, с НДС',
|
_resultContractEconomyWithVAT: 'Экономика, с НДС',
|
||||||
_resultPi: 'PI',
|
_resultPi: 'PI',
|
||||||
|
_resultPiRepayment: 'PI для досрочки',
|
||||||
_resultSumCredit: 'Сумма кредита',
|
_resultSumCredit: 'Сумма кредита',
|
||||||
_resultSumCreditPayment: 'Сумма платежей по кредиту',
|
_resultSumCreditPayment: 'Сумма платежей по кредиту',
|
||||||
_resultVatRecoverable: 'НДС к возмещению',
|
_resultVatRecoverable: 'НДС к возмещению',
|
||||||
@ -46,6 +47,7 @@ export const formatters = {
|
|||||||
_resultContractEconomy: moneyFormatter,
|
_resultContractEconomy: moneyFormatter,
|
||||||
_resultContractEconomyWithVAT: moneyFormatter,
|
_resultContractEconomyWithVAT: moneyFormatter,
|
||||||
_resultPi: percentFormatter,
|
_resultPi: percentFormatter,
|
||||||
|
_resultPiRepayment: percentFormatter,
|
||||||
_resultSumCredit: moneyFormatter,
|
_resultSumCredit: moneyFormatter,
|
||||||
_resultSumCreditPayment: moneyFormatter,
|
_resultSumCreditPayment: moneyFormatter,
|
||||||
_resultVatRecoverable: moneyFormatter,
|
_resultVatRecoverable: moneyFormatter,
|
||||||
@ -74,6 +76,7 @@ export const elements: Array<keyof ResultValues> = [
|
|||||||
'_resultContractEconomy',
|
'_resultContractEconomy',
|
||||||
'_resultContractEconomyWithVAT',
|
'_resultContractEconomyWithVAT',
|
||||||
'_resultPi',
|
'_resultPi',
|
||||||
|
'_resultPiRepayment',
|
||||||
'_resultSumCredit',
|
'_resultSumCredit',
|
||||||
'_resultSumCreditPayment',
|
'_resultSumCreditPayment',
|
||||||
'_resultVatRecoverable',
|
'_resultVatRecoverable',
|
||||||
@ -22,7 +22,7 @@ const Wrapper = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const Results = observer(() => {
|
const Results = observer(() => {
|
||||||
const { $results, $process } = useStore();
|
const { $process, $results } = useStore();
|
||||||
|
|
||||||
const resultsValues = toJS($results.values);
|
const resultsValues = toJS($results.values);
|
||||||
// eslint-disable-next-line no-negated-condition
|
// eslint-disable-next-line no-negated-condition
|
||||||
@ -23,73 +23,34 @@ const AlertWrapper = styled(Box)`
|
|||||||
margin: 0 0 5px 0;
|
margin: 0 0 5px 0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
function getAlerts(errors, title, $process) {
|
||||||
|
return errors.map(({ key, message }) => (
|
||||||
|
<AlertWrapper>
|
||||||
|
<Alert
|
||||||
|
key={key}
|
||||||
|
type={$process.has('Unlimited') ? 'warning' : 'error'}
|
||||||
|
showIcon
|
||||||
|
message={Message(title, message)}
|
||||||
|
/>
|
||||||
|
</AlertWrapper>
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
function getElementsErrors({ $calculation, $process }) {
|
function getElementsErrors({ $calculation, $process }) {
|
||||||
return Object.values($calculation.$validation).map((validation) => {
|
return Object.values($calculation.$validation).map((validation) => {
|
||||||
const elementErrors = validation.getErrors();
|
const elementErrors = validation.getErrors();
|
||||||
const elementTitle = validation.params.err_title;
|
const elementTitle = validation.params.err_title;
|
||||||
|
|
||||||
return elementErrors.map(({ key, message }) => (
|
return getAlerts(elementErrors, elementTitle, $process);
|
||||||
<AlertWrapper>
|
|
||||||
<Alert
|
|
||||||
key={key}
|
|
||||||
type={$process.has('Unlimited') ? 'warning' : 'error'}
|
|
||||||
showIcon
|
|
||||||
message={Message(elementTitle, message)}
|
|
||||||
/>
|
|
||||||
</AlertWrapper>
|
|
||||||
));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPaymentsTableErrors({ $tables, $process }) {
|
function getTableErrors(tableName, { $process, $tables }) {
|
||||||
const { payments } = $tables;
|
const table = $tables[tableName];
|
||||||
const errors = payments.validation.getErrors();
|
const errors = table.validation.getErrors();
|
||||||
const title = payments.validation.params.err_title;
|
const title = table.validation.params.err_title;
|
||||||
|
|
||||||
return errors.map(({ key, message }) => (
|
return getAlerts(errors, title, $process);
|
||||||
<AlertWrapper>
|
|
||||||
<Alert
|
|
||||||
key={key}
|
|
||||||
type={$process.has('Unlimited') ? 'warning' : 'error'}
|
|
||||||
showIcon
|
|
||||||
message={Message(title, message)}
|
|
||||||
/>
|
|
||||||
</AlertWrapper>
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
function getInsuranceTableErrors({ $tables, $process }) {
|
|
||||||
const { insurance } = $tables;
|
|
||||||
const errors = insurance.validation.getErrors();
|
|
||||||
const title = insurance.validation.params.err_title;
|
|
||||||
|
|
||||||
return errors.map(({ key, message }) => (
|
|
||||||
<AlertWrapper>
|
|
||||||
<Alert
|
|
||||||
key={key}
|
|
||||||
type={$process.has('Unlimited') ? 'warning' : 'error'}
|
|
||||||
showIcon
|
|
||||||
message={Message(title, message)}
|
|
||||||
/>
|
|
||||||
</AlertWrapper>
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFingapTableErrors({ $tables, $process }) {
|
|
||||||
const { fingap } = $tables;
|
|
||||||
const errors = fingap.validation.getErrors();
|
|
||||||
const title = fingap.validation.params.err_title;
|
|
||||||
|
|
||||||
return errors.map(({ key, message }) => (
|
|
||||||
<AlertWrapper>
|
|
||||||
<Alert
|
|
||||||
key={key}
|
|
||||||
type={$process.has('Unlimited') ? 'warning' : 'error'}
|
|
||||||
showIcon
|
|
||||||
message={Message(title, message)}
|
|
||||||
/>
|
|
||||||
</AlertWrapper>
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Errors = observer(() => {
|
const Errors = observer(() => {
|
||||||
@ -101,15 +62,16 @@ const Errors = observer(() => {
|
|||||||
);
|
);
|
||||||
const hasPaymentsErrors = $tables.payments.validation.hasErrors;
|
const hasPaymentsErrors = $tables.payments.validation.hasErrors;
|
||||||
const hasInsuranceErrors = $tables.insurance.validation.hasErrors;
|
const hasInsuranceErrors = $tables.insurance.validation.hasErrors;
|
||||||
|
const hasFingapErrors = $tables.fingap.validation.hasErrors;
|
||||||
|
|
||||||
if (!hasElementsErrors && !hasPaymentsErrors && !hasInsuranceErrors) {
|
if (!hasElementsErrors && !hasPaymentsErrors && !hasInsuranceErrors && !hasFingapErrors) {
|
||||||
return <Alert type="success" showIcon message="Ошибок нет 🙂" />;
|
return <Alert type="success" showIcon message="Ошибок нет 🙂" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const elementsErrors = getElementsErrors(store);
|
const elementsErrors = getElementsErrors(store);
|
||||||
const paymentsErrors = getPaymentsTableErrors(store);
|
const paymentsErrors = getTableErrors('payments', store);
|
||||||
const insuranceErrors = getInsuranceTableErrors(store);
|
const insuranceErrors = getTableErrors('insurance', store);
|
||||||
const fingapErrors = getFingapTableErrors(store);
|
const fingapErrors = getTableErrors('fingap', store);
|
||||||
|
|
||||||
const errors = [...elementsErrors, ...paymentsErrors, ...insuranceErrors, ...fingapErrors];
|
const errors = [...elementsErrors, ...paymentsErrors, ...insuranceErrors, ...fingapErrors];
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ const Wrapper = styled(Background)`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Output = observer(() => {
|
export const Output = observer(({ tabs }) => {
|
||||||
const { $results } = useStore();
|
const { $results } = useStore();
|
||||||
const [activeKey, setActiveKey] = useState(undefined);
|
const [activeKey, setActiveKey] = useState(undefined);
|
||||||
const { hasErrors } = useErrors();
|
const { hasErrors } = useErrors();
|
||||||
@ -52,15 +52,15 @@ const Output = observer(() => {
|
|||||||
setActiveKey('payments-table');
|
setActiveKey('payments-table');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasErrors) {
|
if (!tabs && hasErrors) {
|
||||||
setActiveKey('validation');
|
setActiveKey('validation');
|
||||||
}
|
}
|
||||||
}, [$results.payments.length, hasErrors]);
|
}, [$results.payments.length, hasErrors, tabs]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Tabs
|
<Tabs
|
||||||
items={items}
|
items={tabs ? items.filter((x) => x.key !== 'validation') : items}
|
||||||
activeKey={activeKey}
|
activeKey={activeKey}
|
||||||
onChange={(key) => {
|
onChange={(key) => {
|
||||||
setActiveKey(key);
|
setActiveKey(key);
|
||||||
@ -69,5 +69,3 @@ const Output = observer(() => {
|
|||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default Output;
|
|
||||||
@ -18,8 +18,8 @@ export const mainRows: FormTabRows = [
|
|||||||
[
|
[
|
||||||
['btnCreateKP', 'linkDownloadKp'],
|
['btnCreateKP', 'linkDownloadKp'],
|
||||||
{
|
{
|
||||||
gap: [0, '10px'],
|
gap: ['10px'],
|
||||||
gridTemplateColumns: ['1fr', '1fr 1fr'],
|
gridTemplateColumns: ['1fr 1fr'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@ -41,8 +41,8 @@ export const unlimitedMainRows: FormTabRows = [
|
|||||||
[
|
[
|
||||||
['btnCreateKP', 'linkDownloadKp'],
|
['btnCreateKP', 'linkDownloadKp'],
|
||||||
{
|
{
|
||||||
gap: [0, '10px'],
|
gap: ['10px'],
|
||||||
gridTemplateColumns: ['1fr', '1fr 1fr'],
|
gridTemplateColumns: ['1fr 1fr'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import * as config from './config';
|
|||||||
import Background from '@/Components/Layout/Background';
|
import Background from '@/Components/Layout/Background';
|
||||||
import { useStore } from '@/stores/hooks';
|
import { useStore } from '@/stores/hooks';
|
||||||
import { min } from '@/styles/mq';
|
import { min } from '@/styles/mq';
|
||||||
|
import { memo } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
const Wrapper = styled(Background)`
|
const Wrapper = styled(Background)`
|
||||||
@ -17,7 +18,7 @@ const Wrapper = styled(Background)`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default function Settings() {
|
export const Settings = memo(() => {
|
||||||
const { $process } = useStore();
|
const { $process } = useStore();
|
||||||
|
|
||||||
const mainRows = $process.has('Unlimited')
|
const mainRows = $process.has('Unlimited')
|
||||||
@ -33,4 +34,4 @@ export default function Settings() {
|
|||||||
{paramsRows}
|
{paramsRows}
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|||||||
19
apps/web/Components/Calculation/Validation/index.jsx
Normal file
19
apps/web/Components/Calculation/Validation/index.jsx
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import Validation from '../Output/Validation';
|
||||||
|
import Background from '@/Components/Layout/Background';
|
||||||
|
import { min } from '@/styles/mq';
|
||||||
|
import { memo } from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const Wrapper = styled(Background)`
|
||||||
|
padding: 4px 10px;
|
||||||
|
|
||||||
|
${min('laptop')} {
|
||||||
|
padding: 4px 18px;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const Component = memo(() => (
|
||||||
|
<Wrapper>
|
||||||
|
<Validation.Component />
|
||||||
|
</Wrapper>
|
||||||
|
));
|
||||||
@ -136,6 +136,7 @@ const components = wrapComponentsMap({
|
|||||||
cbxPartialVAT: e.Switch,
|
cbxPartialVAT: e.Switch,
|
||||||
cbxFloatingRate: e.Switch,
|
cbxFloatingRate: e.Switch,
|
||||||
cbxQuotePriceWithFullVAT: e.Switch,
|
cbxQuotePriceWithFullVAT: e.Switch,
|
||||||
|
cbxQuoteShowAcceptLimit: e.Switch,
|
||||||
|
|
||||||
/** Readonly Elements */
|
/** Readonly Elements */
|
||||||
labelLeaseObjectRisk: e.Text,
|
labelLeaseObjectRisk: e.Text,
|
||||||
|
|||||||
@ -332,7 +332,7 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
|
|
||||||
const RenderedComponent = observer(() => {
|
const RenderedComponent = observer(() => {
|
||||||
const { $calculation } = useStore();
|
const { $calculation } = useStore();
|
||||||
const { min, max } = $calculation.$values.getValue('irrInfo');
|
const { max, min } = $calculation.$values.getValue('irrInfo');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
@ -370,7 +370,7 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
<Element
|
<Element
|
||||||
{...props}
|
{...props}
|
||||||
id={elementName}
|
id={elementName}
|
||||||
addonBefore={isFetching && <LoadingOutlined spin rev="" />}
|
addonBefore={isFetching ? <LoadingOutlined spin rev="" /> : null}
|
||||||
/>
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@ -130,6 +130,7 @@ const titles: Record<ActionElements | ValuesElements, string> = {
|
|||||||
cbxPartialVAT: 'Частичный НДС',
|
cbxPartialVAT: 'Частичный НДС',
|
||||||
cbxFloatingRate: 'Плавающая ставка',
|
cbxFloatingRate: 'Плавающая ставка',
|
||||||
cbxQuotePriceWithFullVAT: 'Отображать Стоимость ПЛ с полным НДС',
|
cbxQuotePriceWithFullVAT: 'Отображать Стоимость ПЛ с полным НДС',
|
||||||
|
cbxQuoteShowAcceptLimit: 'Отображать одобренный лимит',
|
||||||
|
|
||||||
/** Link Elements */
|
/** Link Elements */
|
||||||
linkDownloadKp: '',
|
linkDownloadKp: '',
|
||||||
|
|||||||
@ -195,6 +195,7 @@ const types = wrapElementsTypes({
|
|||||||
cbxPartialVAT: t.Switch,
|
cbxPartialVAT: t.Switch,
|
||||||
cbxFloatingRate: t.Switch,
|
cbxFloatingRate: t.Switch,
|
||||||
cbxQuotePriceWithFullVAT: t.Switch,
|
cbxQuotePriceWithFullVAT: t.Switch,
|
||||||
|
cbxQuoteShowAcceptLimit: t.Switch,
|
||||||
|
|
||||||
labelLeaseObjectRisk: t.Readonly,
|
labelLeaseObjectRisk: t.Readonly,
|
||||||
tbxInsKaskoPriceLeasePeriod: t.Readonly,
|
tbxInsKaskoPriceLeasePeriod: t.Readonly,
|
||||||
|
|||||||
@ -133,6 +133,7 @@ const elementsToValues = wrapElementsMap({
|
|||||||
cbxPartialVAT: 'partialVAT',
|
cbxPartialVAT: 'partialVAT',
|
||||||
cbxFloatingRate: 'floatingRate',
|
cbxFloatingRate: 'floatingRate',
|
||||||
cbxQuotePriceWithFullVAT: 'quotePriceWithFullVAT',
|
cbxQuotePriceWithFullVAT: 'quotePriceWithFullVAT',
|
||||||
|
cbxQuoteShowAcceptLimit: 'quoteShowAcceptLimit',
|
||||||
|
|
||||||
/** Readonly Elements */
|
/** Readonly Elements */
|
||||||
labelLeaseObjectRisk: 'leaseObjectRiskName',
|
labelLeaseObjectRisk: 'leaseObjectRiskName',
|
||||||
|
|||||||
@ -1,2 +0,0 @@
|
|||||||
export { default as Form } from './Form';
|
|
||||||
export { default as Settings } from './Settings';
|
|
||||||
101
apps/web/Components/Calculation/index.tsx
Normal file
101
apps/web/Components/Calculation/index.tsx
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
import { Form } from './Form';
|
||||||
|
import { Layout } from './Layout';
|
||||||
|
import { Output } from './Output';
|
||||||
|
import { Settings } from './Settings';
|
||||||
|
import { Component as Validation } from './Validation';
|
||||||
|
import { Notification } from '@/Components/Common';
|
||||||
|
import { NavigationBar, Tabs } from '@/Components/Layout/Navigation';
|
||||||
|
import { NavigationProvider } from '@/context/navigation';
|
||||||
|
import { useErrors, useResults } from '@/stores/hooks';
|
||||||
|
import { Media } from '@/styles/media';
|
||||||
|
import { getPageTitle } from '@/utils/page';
|
||||||
|
import { observer } from 'mobx-react-lite';
|
||||||
|
import Head from 'next/head';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { Badge } from 'ui/elements';
|
||||||
|
import {
|
||||||
|
BarChartOutlined,
|
||||||
|
CalculatorOutlined,
|
||||||
|
ProfileOutlined,
|
||||||
|
WarningOutlined,
|
||||||
|
} from 'ui/elements/icons';
|
||||||
|
|
||||||
|
const defaultIconStyle = { fontSize: '1.2rem' };
|
||||||
|
|
||||||
|
const StyledBadge = styled(Badge)`
|
||||||
|
color: unset !important;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const tabs = [
|
||||||
|
{
|
||||||
|
Component: Settings,
|
||||||
|
Icon: () => <ProfileOutlined style={defaultIconStyle} />,
|
||||||
|
key: 'settings',
|
||||||
|
title: 'Интерес/Расчет',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Component: Form,
|
||||||
|
Icon: () => <CalculatorOutlined style={defaultIconStyle} />,
|
||||||
|
key: 'form',
|
||||||
|
title: 'Параметры',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Component: Output,
|
||||||
|
Icon: observer(() => {
|
||||||
|
const { hasResults } = useResults();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<StyledBadge status="success" dot={hasResults}>
|
||||||
|
<BarChartOutlined style={defaultIconStyle} />
|
||||||
|
</StyledBadge>
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
key: 'output',
|
||||||
|
title: 'Результаты',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Component: Validation,
|
||||||
|
Icon: observer(() => {
|
||||||
|
const { hasErrors } = useErrors();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<StyledBadge status="error" dot={hasErrors}>
|
||||||
|
<WarningOutlined style={defaultIconStyle} />
|
||||||
|
</StyledBadge>
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
key: 'errors',
|
||||||
|
title: 'Ошибки',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
type ContentProps = {
|
||||||
|
readonly initHooks: () => void;
|
||||||
|
readonly title: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function Content({ initHooks, title }: ContentProps) {
|
||||||
|
initHooks();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Head>
|
||||||
|
<title>{getPageTitle(title)}</title>
|
||||||
|
</Head>
|
||||||
|
<Notification />
|
||||||
|
<Media lessThan="laptop">
|
||||||
|
<NavigationProvider>
|
||||||
|
<Tabs tabs={tabs} />
|
||||||
|
<NavigationBar />
|
||||||
|
</NavigationProvider>
|
||||||
|
</Media>
|
||||||
|
<Media greaterThanOrEqual="laptop">
|
||||||
|
<Layout>
|
||||||
|
<Form />
|
||||||
|
<Settings />
|
||||||
|
<Output />
|
||||||
|
</Layout>
|
||||||
|
</Media>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
20
apps/web/Components/Common/Loading.jsx
Normal file
20
apps/web/Components/Common/Loading.jsx
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import getColors from '@/styles/colors';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { Result } from 'ui/elements';
|
||||||
|
import { LoadingOutlined } from 'ui/elements/icons';
|
||||||
|
|
||||||
|
const colors = getColors();
|
||||||
|
|
||||||
|
const Title = styled.span`
|
||||||
|
font-size: 1.25rem;
|
||||||
|
color: rgba(0, 0, 0, 0.88);
|
||||||
|
`;
|
||||||
|
|
||||||
|
export function Loading() {
|
||||||
|
return (
|
||||||
|
<Result
|
||||||
|
icon={<LoadingOutlined style={{ color: colors.COLOR_PRIMARY, fontSize: '60px' }} />}
|
||||||
|
title={<Title>Загрузка...</Title>}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -1,4 +1,7 @@
|
|||||||
/* eslint-disable import/no-mutable-exports */
|
/* eslint-disable import/no-mutable-exports */
|
||||||
|
import { ERROR_KEYS } from '@/@types/errors';
|
||||||
|
import { Media } from '@/styles/media';
|
||||||
|
import { getDevice } from '@/utils/device';
|
||||||
import type { MessageInstance } from 'antd/es/message/interface';
|
import type { MessageInstance } from 'antd/es/message/interface';
|
||||||
import type { NotificationInstance } from 'antd/es/notification/interface';
|
import type { NotificationInstance } from 'antd/es/notification/interface';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
@ -7,23 +10,61 @@ import { message as antdMessage, notification as antdNotification } from 'ui/ele
|
|||||||
export let message: Readonly<MessageInstance>;
|
export let message: Readonly<MessageInstance>;
|
||||||
export let notification: Readonly<NotificationInstance>;
|
export let notification: Readonly<NotificationInstance>;
|
||||||
|
|
||||||
export function Notification({ children }: { children: ReactNode }) {
|
function createWrapper<T extends NotificationInstance, M extends MessageInstance>(
|
||||||
|
notificationObj: T,
|
||||||
|
messageObj: M
|
||||||
|
): T {
|
||||||
|
const handler: ProxyHandler<T> = {
|
||||||
|
get(target, prop, receiver) {
|
||||||
|
const notificationMethod = target[prop as keyof T];
|
||||||
|
const messageMethod = messageObj[prop as keyof M];
|
||||||
|
|
||||||
|
if (typeof notificationMethod === 'function' && typeof messageMethod === 'function') {
|
||||||
|
return function (...args: any[]) {
|
||||||
|
const device = getDevice();
|
||||||
|
|
||||||
|
if (device?.isMobile) {
|
||||||
|
if (typeof args[0] === 'object') {
|
||||||
|
if (ERROR_KEYS.includes(args[0].key)) return;
|
||||||
|
args[0].content = args[0].description || args[0].message;
|
||||||
|
}
|
||||||
|
|
||||||
|
messageMethod.apply(messageObj, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
notificationMethod.apply(target, args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return Reflect.get(target, prop, receiver);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return new Proxy(notificationObj, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Notification({ children }: { readonly children?: ReactNode }) {
|
||||||
|
const device = getDevice();
|
||||||
|
|
||||||
const [messageApi, messageContextHolder] = antdMessage.useMessage({
|
const [messageApi, messageContextHolder] = antdMessage.useMessage({
|
||||||
|
duration: device?.isMobile ? 1.5 : 1.2,
|
||||||
maxCount: 3,
|
maxCount: 3,
|
||||||
top: 70,
|
top: 70,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [notificationApi, notificationContextHolder] = antdNotification.useNotification({
|
const [notificationApi, notificationContextHolder] = antdNotification.useNotification({
|
||||||
|
maxCount: 3,
|
||||||
placement: 'bottomRight',
|
placement: 'bottomRight',
|
||||||
|
stack: { threshold: 1 },
|
||||||
});
|
});
|
||||||
|
|
||||||
message = messageApi;
|
message = messageApi;
|
||||||
notification = notificationApi;
|
notification = createWrapper(notificationApi, messageApi);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{messageContextHolder}
|
{messageContextHolder}
|
||||||
{notificationContextHolder}
|
<Media greaterThanOrEqual="laptop">{notificationContextHolder}</Media>
|
||||||
{children}
|
{children}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
3
apps/web/Components/Common/index.ts
Normal file
3
apps/web/Components/Common/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export * from './Error';
|
||||||
|
export * from './Loading';
|
||||||
|
export * from './Notification';
|
||||||
@ -10,7 +10,7 @@ const UserText = styled.span`
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 0.5rem;
|
font-size: 0.55rem;
|
||||||
font-family: 'Montserrat';
|
font-family: 'Montserrat';
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
@ -45,13 +45,7 @@ const Logout = styled.a`
|
|||||||
|
|
||||||
function Auth() {
|
function Auth() {
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex flexDirection="column" alignItems="flex-end" justifyContent="flex-start" height="100%">
|
||||||
flexDirection="column"
|
|
||||||
alignItems="flex-end"
|
|
||||||
alignSelf={['flex-start']}
|
|
||||||
justifyContent="space-between"
|
|
||||||
height="100%"
|
|
||||||
>
|
|
||||||
<User />
|
<User />
|
||||||
<Logout href="/logout">Выход</Logout>
|
<Logout href="/logout">Выход</Logout>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import { Flex } from 'ui/grid';
|
|||||||
const HeaderContent = styled(Flex)`
|
const HeaderContent = styled(Flex)`
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
padding: 14px 12px;
|
||||||
|
|
||||||
background: linear-gradient(
|
background: linear-gradient(
|
||||||
90deg,
|
90deg,
|
||||||
@ -15,9 +16,7 @@ const HeaderContent = styled(Flex)`
|
|||||||
var(--color-tertiarty) 100%
|
var(--color-tertiarty) 100%
|
||||||
);
|
);
|
||||||
|
|
||||||
padding: 14px 12px;
|
|
||||||
${min('laptop')} {
|
${min('laptop')} {
|
||||||
padding: 14px 12px;
|
|
||||||
padding-left: 20px;
|
padding-left: 20px;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import getColors from '@/styles/colors';
|
|||||||
import { min } from '@/styles/mq';
|
import { min } from '@/styles/mq';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
|
import Link from 'next/link';
|
||||||
import logo from 'public/assets/images/logo-primary.svg';
|
import logo from 'public/assets/images/logo-primary.svg';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { Tag } from 'ui/elements';
|
import { Tag } from 'ui/elements';
|
||||||
@ -33,8 +34,9 @@ const LogoText = styled.h3`
|
|||||||
const TagWrapper = styled.div`
|
const TagWrapper = styled.div`
|
||||||
font-family: 'Montserrat';
|
font-family: 'Montserrat';
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
* {
|
|
||||||
font-size: 0.7rem;
|
${min('tablet')} {
|
||||||
|
margin: 0 5px;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -42,12 +44,11 @@ const { COLOR_PRIMARY } = getColors();
|
|||||||
|
|
||||||
const UnlimitedTag = observer(() => {
|
const UnlimitedTag = observer(() => {
|
||||||
const { $process } = useStore();
|
const { $process } = useStore();
|
||||||
|
|
||||||
if ($process.has('Unlimited')) {
|
if ($process.has('Unlimited')) {
|
||||||
return (
|
return (
|
||||||
<TagWrapper>
|
<TagWrapper>
|
||||||
<Tag color={COLOR_PRIMARY} style={{ margin: '0 5px' }}>
|
<Tag color={COLOR_PRIMARY}>без ограничений</Tag>
|
||||||
без ограничений
|
|
||||||
</Tag>
|
|
||||||
</TagWrapper>
|
</TagWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -59,9 +60,11 @@ function Logo() {
|
|||||||
return (
|
return (
|
||||||
<Flex flexDirection="column" alignItems="flex-start" justifyContent="space-between">
|
<Flex flexDirection="column" alignItems="flex-start" justifyContent="space-between">
|
||||||
<ImageWrapper>
|
<ImageWrapper>
|
||||||
|
<Link prefetch={false} href="/">
|
||||||
<Image priority className={styles.logo} alt="logo" src={logo} layout="responsive" />
|
<Image priority className={styles.logo} alt="logo" src={logo} layout="responsive" />
|
||||||
|
</Link>
|
||||||
</ImageWrapper>
|
</ImageWrapper>
|
||||||
<Flex justifyContent="space-between" alignItems="center">
|
<Flex flexDirection={['column', 'row']} alignItems={[undefined, 'center']}>
|
||||||
<LogoText>Лизинговый Калькулятор</LogoText>
|
<LogoText>Лизинговый Калькулятор</LogoText>
|
||||||
<UnlimitedTag />
|
<UnlimitedTag />
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
60
apps/web/Components/Layout/Menu.tsx
Normal file
60
apps/web/Components/Layout/Menu.tsx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import Background from './Background';
|
||||||
|
import type { MenuProps } from 'antd';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { useRouter } from 'next/router';
|
||||||
|
import { Menu } from 'ui/elements';
|
||||||
|
import { AppstoreOutlined, SettingOutlined } from 'ui/elements/icons';
|
||||||
|
|
||||||
|
const items: MenuProps['items'] = [
|
||||||
|
{
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
// icon: <HomeOutlined />,
|
||||||
|
key: '/',
|
||||||
|
label: (
|
||||||
|
<Link prefetch={false} href="/">
|
||||||
|
Главная
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// icon: <PlusSquareOutlined />,
|
||||||
|
key: '/unlimited',
|
||||||
|
label: (
|
||||||
|
<Link prefetch={false} href="/unlimited">
|
||||||
|
Без ограничений
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
icon: <AppstoreOutlined />,
|
||||||
|
key: 'home',
|
||||||
|
label: 'Приложение',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
// icon: <DatabaseOutlined />,
|
||||||
|
key: '/admin/cache',
|
||||||
|
label: (
|
||||||
|
<Link prefetch={false} href="/admin/cache">
|
||||||
|
Управление кэшем
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
icon: <SettingOutlined />,
|
||||||
|
key: 'admin',
|
||||||
|
label: 'Панель управления',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export function AppMenu() {
|
||||||
|
const { pathname } = useRouter();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Background>
|
||||||
|
<Menu selectedKeys={[pathname]} mode="horizontal" items={items} />
|
||||||
|
</Background>
|
||||||
|
);
|
||||||
|
}
|
||||||
64
apps/web/Components/Layout/Navigation.jsx
Normal file
64
apps/web/Components/Layout/Navigation.jsx
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
import { NavigationContext } from '@/context/navigation';
|
||||||
|
import { useContext, useEffect } from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { Flex } from 'ui/grid';
|
||||||
|
|
||||||
|
const Container = styled.div`
|
||||||
|
background-color: white;
|
||||||
|
bottom: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 10px;
|
||||||
|
height: 46px;
|
||||||
|
justify-content: space-around;
|
||||||
|
position: fixed;
|
||||||
|
width: 100%;
|
||||||
|
border-top: 1px solid rgba(5, 5, 5, 0.06);
|
||||||
|
z-index: 999999;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const TabButton = styled.button`
|
||||||
|
background: ${({ active }) => (active ? 'var(--color-primary)' : 'white')};
|
||||||
|
color: ${({ active }) => (active ? 'white' : 'black')};
|
||||||
|
border-radius: 2px 2px 0 0;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export function NavigationBar() {
|
||||||
|
const { currentTab, setCurrentTab, tabsList } = useContext(NavigationContext);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
{tabsList.map(({ Icon, key, title }) => (
|
||||||
|
<TabButton key={key} active={key === currentTab} onClick={() => setCurrentTab(key)}>
|
||||||
|
<Flex flexDirection="column" alignItems="center">
|
||||||
|
<Icon />
|
||||||
|
{title}
|
||||||
|
</Flex>
|
||||||
|
</TabButton>
|
||||||
|
))}
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Display = styled.div`
|
||||||
|
display: ${(props) => (props.visible ? 'block' : 'none')};
|
||||||
|
`;
|
||||||
|
|
||||||
|
export function Tabs({ tabs }) {
|
||||||
|
const { currentTab, setTabsList } = useContext(NavigationContext);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setTabsList(tabs);
|
||||||
|
}, [setTabsList, tabs]);
|
||||||
|
|
||||||
|
return tabs.map(({ Component, key }) => (
|
||||||
|
<Display key={key} visible={key === currentTab}>
|
||||||
|
<Component key={key} tabs />
|
||||||
|
</Display>
|
||||||
|
));
|
||||||
|
}
|
||||||
@ -1,11 +1,26 @@
|
|||||||
import Header from './Header';
|
import Header from './Header';
|
||||||
import { Flex } from 'ui/grid';
|
import { AppMenu } from './Menu';
|
||||||
|
import { max, min } from '@/styles/mq';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
export default function Layout({ children }) {
|
const Main = styled.main`
|
||||||
|
margin: 8px 0;
|
||||||
|
|
||||||
|
${max('laptop')} {
|
||||||
|
margin-bottom: calc(46px + 8px); // height of the navigation bar
|
||||||
|
}
|
||||||
|
|
||||||
|
${min('desktop-xl')} {
|
||||||
|
margin: 8px 10%;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default function Layout({ children, user }) {
|
||||||
return (
|
return (
|
||||||
<Flex flexDirection="column">
|
<>
|
||||||
<Header />
|
<Header />
|
||||||
<main>{children}</main>
|
{user?.admin ? <AppMenu /> : false}
|
||||||
</Flex>
|
<Main>{children}</Main>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,14 +2,14 @@
|
|||||||
# Make sure you update both files!
|
# Make sure you update both files!
|
||||||
|
|
||||||
FROM node:alpine AS builder
|
FROM node:alpine AS builder
|
||||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
RUN corepack enable && corepack prepare pnpm@8.9.0 --activate
|
||||||
ENV PNPM_HOME=/usr/local/bin
|
ENV PNPM_HOME=/usr/local/bin
|
||||||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
# 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
|
RUN apk add --no-cache libc6-compat
|
||||||
RUN apk update
|
RUN apk update
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN pnpm add -g turbo dotenv-cli
|
RUN pnpm add -g turbo@1.12.4 dotenv-cli
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN turbo prune --scope=web --docker
|
RUN turbo prune --scope=web --docker
|
||||||
|
|
||||||
@ -47,6 +47,9 @@ ARG URL_CORE_CALCULATE_DIRECT
|
|||||||
ARG URL_1C_TRANSTAX_DIRECT
|
ARG URL_1C_TRANSTAX_DIRECT
|
||||||
ARG URL_ELT_OSAGO_DIRECT
|
ARG URL_ELT_OSAGO_DIRECT
|
||||||
ARG URL_ELT_KASKO_DIRECT
|
ARG URL_ELT_KASKO_DIRECT
|
||||||
|
ARG USERNAME_1C_TRANSTAX
|
||||||
|
ARG PASSWORD_1C_TRANSTAX
|
||||||
|
RUN pnpm dotenv -v NODE_ENV=production -e .env turbo run prebuild --filter=web...
|
||||||
RUN pnpm dotenv -e .env turbo run build --filter=web...
|
RUN pnpm dotenv -e .env turbo run build --filter=web...
|
||||||
|
|
||||||
FROM node:alpine AS runner
|
FROM node:alpine AS runner
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
export type RequestTransTax = {
|
export type RequestTransTax = {
|
||||||
|
CalcDate: string;
|
||||||
|
CarCategory: string;
|
||||||
OKTMO: string;
|
OKTMO: string;
|
||||||
calcDate: Date;
|
Power: number;
|
||||||
carCategory: string;
|
Year: number;
|
||||||
power: number;
|
|
||||||
year: number;
|
|
||||||
};
|
};
|
||||||
export type ResponseTransTax = {
|
export type ResponseTransTax = {
|
||||||
error: string;
|
Error: string;
|
||||||
tax: number;
|
Tax: number;
|
||||||
|
TaxRate: number;
|
||||||
};
|
};
|
||||||
|
|||||||
42
apps/web/api/cache/query.ts
vendored
Normal file
42
apps/web/api/cache/query.ts
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import type { ResponseQueries } from './types';
|
||||||
|
import getUrls from '@/config/urls';
|
||||||
|
import { withHandleError } from '@/utils/axios';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
const {
|
||||||
|
URL_CACHE_GET_QUERIES,
|
||||||
|
URL_CACHE_DELETE_QUERY,
|
||||||
|
URL_CACHE_RESET_QUERIES,
|
||||||
|
URL_CACHE_GET_QUERY,
|
||||||
|
} = getUrls();
|
||||||
|
|
||||||
|
export function getQueries({ signal }: { signal: AbortSignal }) {
|
||||||
|
return withHandleError(axios.get<ResponseQueries>(URL_CACHE_GET_QUERIES, { signal })).then(
|
||||||
|
({ data }) => data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteQuery(queryKey: string) {
|
||||||
|
return withHandleError(
|
||||||
|
axios.delete(URL_CACHE_DELETE_QUERY, {
|
||||||
|
params: {
|
||||||
|
queryKey,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
).then(({ data }) => data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function reset() {
|
||||||
|
return withHandleError(axios.delete(URL_CACHE_RESET_QUERIES)).then(({ data }) => data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getQueryValue(queryKey: string, { signal }: { signal: AbortSignal }) {
|
||||||
|
return withHandleError(
|
||||||
|
axios.get<object>(URL_CACHE_GET_QUERY, {
|
||||||
|
params: {
|
||||||
|
queryKey,
|
||||||
|
},
|
||||||
|
signal,
|
||||||
|
})
|
||||||
|
).then(({ data }) => data);
|
||||||
|
}
|
||||||
3
apps/web/api/cache/types.ts
vendored
Normal file
3
apps/web/api/cache/types.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import type { QueryItem } from 'shared/types/cache';
|
||||||
|
|
||||||
|
export type ResponseQueries = Record<string, QueryItem>;
|
||||||
@ -111,6 +111,7 @@ export const PreparedValuesSchema = z.object({
|
|||||||
transTax: z.number(),
|
transTax: z.number(),
|
||||||
transportTaxGr: z.number(),
|
transportTaxGr: z.number(),
|
||||||
transportTaxGrYear: z.number(),
|
transportTaxGrYear: z.number(),
|
||||||
|
typeRepayment: z.number(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type PreparedValues = z.infer<typeof PreparedValuesSchema>;
|
export type PreparedValues = z.infer<typeof PreparedValuesSchema>;
|
||||||
@ -399,6 +400,7 @@ const ColumnsSchema = z.object({
|
|||||||
values: z.number().array(),
|
values: z.number().array(),
|
||||||
}),
|
}),
|
||||||
sumRepaymentColumn: z.object({
|
sumRepaymentColumn: z.object({
|
||||||
|
pi: z.number(),
|
||||||
values: z.number().array(),
|
values: z.number().array(),
|
||||||
}),
|
}),
|
||||||
sumVATCreditColumn: z.object({
|
sumVATCreditColumn: z.object({
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import ValuesSchema from '@/config/schema/values';
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
export const RequestCreateKPSchema = z.object({
|
export const RequestCreateKPSchema = z.object({
|
||||||
|
__info: z.record(z.any()).optional(),
|
||||||
calculation: z
|
calculation: z
|
||||||
.object({
|
.object({
|
||||||
calculationValues: ValuesSchema,
|
calculationValues: ValuesSchema,
|
||||||
|
|||||||
@ -6,24 +6,18 @@ import axios from 'axios';
|
|||||||
|
|
||||||
const { URL_ELT_KASKO, URL_ELT_OSAGO } = getUrls();
|
const { URL_ELT_KASKO, URL_ELT_OSAGO } = getUrls();
|
||||||
|
|
||||||
export async function getEltOsago(
|
export async function getEltOsago(payload: ELT.RequestEltOsago) {
|
||||||
payload: ELT.RequestEltOsago,
|
|
||||||
{ signal }: { signal: AbortSignal }
|
|
||||||
) {
|
|
||||||
return withHandleError(
|
return withHandleError(
|
||||||
axios
|
axios
|
||||||
.post<ELT.ResponseEltOsago>(URL_ELT_OSAGO, payload, { signal, timeout: TIMEOUT })
|
.post<ELT.ResponseEltOsago>(URL_ELT_OSAGO, payload, { timeout: TIMEOUT })
|
||||||
.then(({ data }) => data)
|
.then(({ data }) => data)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getEltKasko(
|
export async function getEltKasko(payload: ELT.RequestEltKasko) {
|
||||||
payload: ELT.RequestEltKasko,
|
|
||||||
{ signal }: { signal: AbortSignal }
|
|
||||||
) {
|
|
||||||
return withHandleError(
|
return withHandleError(
|
||||||
axios
|
axios
|
||||||
.post<ELT.ResponseEltKasko>(URL_ELT_KASKO, payload, { signal, timeout: TIMEOUT })
|
.post<ELT.ResponseEltKasko>(URL_ELT_KASKO, payload, { timeout: TIMEOUT })
|
||||||
.then(({ data }) => data)
|
.then(({ data }) => data)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,20 +1,24 @@
|
|||||||
import { link } from '@/config/apollo';
|
import { createLink } from './link';
|
||||||
import { ApolloClient, InMemoryCache } from '@apollo/client';
|
import { ApolloClient, InMemoryCache } from '@apollo/client';
|
||||||
import { isServer } from 'tools/common';
|
import { isServer } from 'tools/common';
|
||||||
|
|
||||||
/** @type {import('@apollo/client').ApolloClient<import('@apollo/client').NormalizedCacheObject>} */
|
/** @type {import('@apollo/client').ApolloClient<import('@apollo/client').NormalizedCacheObject>} */
|
||||||
let apolloClient;
|
let apolloClient;
|
||||||
|
|
||||||
function createApolloClient() {
|
function createApolloClient(headers) {
|
||||||
return new ApolloClient({
|
return new ApolloClient({
|
||||||
cache: new InMemoryCache(),
|
cache: new InMemoryCache(),
|
||||||
link,
|
link: createLink(headers),
|
||||||
ssrMode: isServer(),
|
ssrMode: isServer(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function initializeApollo(initialState = null) {
|
export default function initializeApollo(initialState, headers) {
|
||||||
const _apolloClient = apolloClient ?? createApolloClient();
|
if (isServer() && !headers) {
|
||||||
|
throw new Error('initializeApollo: headers must be provided in server side');
|
||||||
|
}
|
||||||
|
|
||||||
|
const _apolloClient = apolloClient ?? createApolloClient(headers);
|
||||||
|
|
||||||
// If your page has Next.js data fetching methods that use Apollo Client, the initial state
|
// If your page has Next.js data fetching methods that use Apollo Client, the initial state
|
||||||
// gets hydrated here
|
// gets hydrated here
|
||||||
|
|||||||
133
apps/web/apollo/link.js
Normal file
133
apps/web/apollo/link.js
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
/* eslint-disable sonarjs/cognitive-complexity */
|
||||||
|
import { message } from '@/Components/Common/Notification';
|
||||||
|
import { publicRuntimeConfigSchema } from '@/config/schema/runtime-config';
|
||||||
|
import getUrls from '@/config/urls';
|
||||||
|
import { ApolloLink, from, HttpLink } from '@apollo/client';
|
||||||
|
import { setContext } from '@apollo/client/link/context';
|
||||||
|
import { onError } from '@apollo/client/link/error';
|
||||||
|
import { getCurrentScope } from '@sentry/nextjs';
|
||||||
|
import getConfig from 'next/config';
|
||||||
|
import { isServer } from 'tools';
|
||||||
|
|
||||||
|
function isSovkom(account) {
|
||||||
|
return account.label.toLowerCase().includes('совком');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createLink(headers) {
|
||||||
|
const { URL_CRM_GRAPHQL } = getUrls();
|
||||||
|
|
||||||
|
const modifyDataLink = new ApolloLink((operation, forward) => {
|
||||||
|
const context = operation?.getContext();
|
||||||
|
|
||||||
|
return forward(operation).map((response) => {
|
||||||
|
if (!context?.disableModify) {
|
||||||
|
if (Object.keys(response?.data).includes('evo_addproduct_types')) {
|
||||||
|
response.data.evo_addproduct_types = response.data.evo_addproduct_types.map(
|
||||||
|
(evo_addproduct_type) => {
|
||||||
|
if (evo_addproduct_type.evo_graph_price)
|
||||||
|
return {
|
||||||
|
...evo_addproduct_type,
|
||||||
|
label: `${evo_addproduct_type.label} (${evo_addproduct_type.evo_graph_price} руб.)`,
|
||||||
|
};
|
||||||
|
|
||||||
|
return evo_addproduct_type;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(response?.data).includes('evo_equipments')) {
|
||||||
|
response.data.evo_equipments = response.data.evo_equipments.map((evo_equipment) => {
|
||||||
|
if (evo_equipment.evo_start_production_year)
|
||||||
|
return {
|
||||||
|
...evo_equipment,
|
||||||
|
label: `${evo_equipment.label} (${evo_equipment.evo_start_production_year})`,
|
||||||
|
};
|
||||||
|
|
||||||
|
return evo_equipment;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operation.operationName === 'GetInsuranceCompanies') {
|
||||||
|
response.data.accounts = response.data.accounts
|
||||||
|
.sort((a, b) => {
|
||||||
|
if (isSovkom(a)) return -1;
|
||||||
|
|
||||||
|
if (isSovkom(b)) return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
})
|
||||||
|
.map((account) => {
|
||||||
|
const substring = account.label.match(/"(.+)"/u);
|
||||||
|
if (substring)
|
||||||
|
return {
|
||||||
|
...account,
|
||||||
|
label: substring ? substring[1].replaceAll('"', '').trim() : account.label,
|
||||||
|
};
|
||||||
|
|
||||||
|
return account;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const httpLink = new HttpLink({
|
||||||
|
uri: URL_CRM_GRAPHQL,
|
||||||
|
});
|
||||||
|
|
||||||
|
const authLink = setContext((_, { headers: existingHeaders }) => {
|
||||||
|
if (process.env.NODE_ENV === 'development') {
|
||||||
|
const { publicRuntimeConfig } = getConfig();
|
||||||
|
const { DEV_AUTH_TOKEN } = publicRuntimeConfigSchema.parse(publicRuntimeConfig);
|
||||||
|
|
||||||
|
if (DEV_AUTH_TOKEN)
|
||||||
|
return {
|
||||||
|
headers: {
|
||||||
|
...existingHeaders,
|
||||||
|
authorization: `Bearer ${DEV_AUTH_TOKEN}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isServer()) {
|
||||||
|
return {
|
||||||
|
headers: {
|
||||||
|
...existingHeaders,
|
||||||
|
authorization: headers?.authorization,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
headers: {
|
||||||
|
...existingHeaders,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const key = 'APOLLO_GRAPHQL';
|
||||||
|
|
||||||
|
const errorLink = onError(({ graphQLErrors, networkError, operation, response }) => {
|
||||||
|
const scope = getCurrentScope();
|
||||||
|
scope.setTag('operationName', operation.operationName);
|
||||||
|
|
||||||
|
if (!isServer()) {
|
||||||
|
message.error({
|
||||||
|
content: `Ошибка во время загрузки данных из CRM`,
|
||||||
|
key,
|
||||||
|
onClick: () => message.destroy(key),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.setExtras({
|
||||||
|
graphQLErrors,
|
||||||
|
networkError,
|
||||||
|
operation,
|
||||||
|
response,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return from([authLink, errorLink, modifyDataLink, httpLink]);
|
||||||
|
}
|
||||||
@ -1,45 +0,0 @@
|
|||||||
import getUrls from './urls';
|
|
||||||
import { ApolloLink, HttpLink } from '@apollo/client';
|
|
||||||
|
|
||||||
const { URL_CRM_GRAPHQL } = getUrls();
|
|
||||||
|
|
||||||
const modifyDataLink = new ApolloLink((operation, forward) => {
|
|
||||||
const context = operation?.getContext();
|
|
||||||
|
|
||||||
return forward(operation).map((response) => {
|
|
||||||
if (!context?.disableModify) {
|
|
||||||
if (Object.keys(response?.data).includes('evo_addproduct_types')) {
|
|
||||||
response.data.evo_addproduct_types = response.data.evo_addproduct_types.map((x) => ({
|
|
||||||
...x,
|
|
||||||
label: `${x.label} (${x.evo_graph_price} руб.)`,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Object.keys(response?.data).includes('evo_equipments')) {
|
|
||||||
response.data.evo_equipments = response.data.evo_equipments.map((x) => ({
|
|
||||||
...x,
|
|
||||||
label: `${x.label} (${x.evo_start_production_year})`,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (operation.operationName === 'GetInsuranceCompanies') {
|
|
||||||
response.data.accounts = response.data.accounts.map((x) => {
|
|
||||||
const substring = x.label.match(/"(.+)"/u);
|
|
||||||
|
|
||||||
return {
|
|
||||||
...x,
|
|
||||||
label: substring ? substring[1].replaceAll('"', '').trim() : x.label,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const httpLink = new HttpLink({
|
|
||||||
uri: URL_CRM_GRAPHQL,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const link = modifyDataLink.concat(httpLink);
|
|
||||||
@ -104,7 +104,7 @@ export const selectObjectCategoryTax = [
|
|||||||
export const selectLeaseObjectUseFor = alphabetical(
|
export const selectLeaseObjectUseFor = alphabetical(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
label: 'Для представительских целей',
|
label: 'Для представительских целей / перевозки сотрудников ЛП',
|
||||||
value: 100_000_000,
|
value: 100_000_000,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -151,10 +151,10 @@ export const selectLeaseObjectUseFor = alphabetical(
|
|||||||
label: 'Для перевозки сотрудников других организаций (водитель ЛП)',
|
label: 'Для перевозки сотрудников других организаций (водитель ЛП)',
|
||||||
value: 100_000_011,
|
value: 100_000_011,
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
label: 'Для перевозки сотрудников ЛП',
|
// label: 'Для перевозки сотрудников ЛП',
|
||||||
value: 100_000_012,
|
// value: 100_000_012,
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
label: 'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.',
|
label: 'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.',
|
||||||
value: 100_000_013,
|
value: 100_000_013,
|
||||||
@ -183,6 +183,10 @@ export const selectLeaseObjectUseFor = alphabetical(
|
|||||||
label: 'Строительство',
|
label: 'Строительство',
|
||||||
value: 100_000_019,
|
value: 100_000_019,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Перевозка опасных и легковоспламеняющихся грузов',
|
||||||
|
value: 100_000_020,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
(objectUseFor) => objectUseFor.label.toLowerCase(),
|
(objectUseFor) => objectUseFor.label.toLowerCase(),
|
||||||
'asc'
|
'asc'
|
||||||
@ -507,6 +511,7 @@ const defaultOptions: CalculationOptions = {
|
|||||||
cbxPartialVAT: [],
|
cbxPartialVAT: [],
|
||||||
cbxFloatingRate: [],
|
cbxFloatingRate: [],
|
||||||
cbxQuotePriceWithFullVAT: [],
|
cbxQuotePriceWithFullVAT: [],
|
||||||
|
cbxQuoteShowAcceptLimit: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defaultOptions;
|
export default defaultOptions;
|
||||||
|
|||||||
@ -18,6 +18,7 @@ const defaultStatuses: CalculationStatuses = {
|
|||||||
cbxPriceWithDiscount: 'Default',
|
cbxPriceWithDiscount: 'Default',
|
||||||
cbxQuotePriceWithFullVAT: 'Default',
|
cbxQuotePriceWithFullVAT: 'Default',
|
||||||
cbxQuoteRedemptionGraph: 'Default',
|
cbxQuoteRedemptionGraph: 'Default',
|
||||||
|
cbxQuoteShowAcceptLimit: 'Default',
|
||||||
cbxRecalcWithRevision: 'Default',
|
cbxRecalcWithRevision: 'Default',
|
||||||
cbxRegistrationQuote: 'Default',
|
cbxRegistrationQuote: 'Default',
|
||||||
cbxShowFinGAP: 'Default',
|
cbxShowFinGAP: 'Default',
|
||||||
|
|||||||
@ -22,7 +22,7 @@ const defaultValues: CalculationValues = {
|
|||||||
comissionRub: 0,
|
comissionRub: 0,
|
||||||
configuration: null,
|
configuration: null,
|
||||||
costIncrease: true,
|
costIncrease: true,
|
||||||
countSeats: 0,
|
countSeats: 4,
|
||||||
creditRate: RATE,
|
creditRate: RATE,
|
||||||
dealer: null,
|
dealer: null,
|
||||||
dealerBroker: null,
|
dealerBroker: null,
|
||||||
@ -144,6 +144,7 @@ const defaultValues: CalculationValues = {
|
|||||||
partialVAT: false,
|
partialVAT: false,
|
||||||
floatingRate: false,
|
floatingRate: false,
|
||||||
quotePriceWithFullVAT: false,
|
quotePriceWithFullVAT: false,
|
||||||
|
quoteShowAcceptLimit: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defaultValues;
|
export default defaultValues;
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { withBasePath } from '@/config/urls';
|
|||||||
|
|
||||||
export const metaFavicon = (
|
export const metaFavicon = (
|
||||||
<>
|
<>
|
||||||
|
<link rel="icon" type="image/x-icon" href={withBasePath('/favicon.ico')} sizes="32x32" />
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href={withBasePath('/apple-touch-icon.png')} />
|
<link rel="apple-touch-icon" sizes="180x180" href={withBasePath('/apple-touch-icon.png')} />
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href={withBasePath('/favicon-32x32.png')} />
|
<link rel="icon" type="image/png" sizes="32x32" href={withBasePath('/favicon-32x32.png')} />
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href={withBasePath('/favicon-16x16.png')} />
|
<link rel="icon" type="image/png" sizes="16x16" href={withBasePath('/favicon-16x16.png')} />
|
||||||
|
|||||||
@ -215,7 +215,6 @@ export const RequestEltOsagoSchema = z.object({
|
|||||||
city: z.string(),
|
city: z.string(),
|
||||||
cityKladr: z.string(),
|
cityKladr: z.string(),
|
||||||
country: z.string(),
|
country: z.string(),
|
||||||
flat: z.string(),
|
|
||||||
house: z.string(),
|
house: z.string(),
|
||||||
region: z.string(),
|
region: z.string(),
|
||||||
resident: z.number(),
|
resident: z.number(),
|
||||||
@ -231,7 +230,6 @@ export const RequestEltOsagoSchema = z.object({
|
|||||||
city: z.string(),
|
city: z.string(),
|
||||||
cityKladr: z.string(),
|
cityKladr: z.string(),
|
||||||
country: z.string(),
|
country: z.string(),
|
||||||
flat: z.string(),
|
|
||||||
house: z.string(),
|
house: z.string(),
|
||||||
region: z.string(),
|
region: z.string(),
|
||||||
resident: z.number(),
|
resident: z.number(),
|
||||||
@ -272,10 +270,12 @@ export const ResultEltOsagoSchema = z.object({
|
|||||||
|
|
||||||
export const RowSchema = z.object({
|
export const RowSchema = z.object({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
|
insuranceCondition: z.string().nullable(),
|
||||||
key: z.string(),
|
key: z.string(),
|
||||||
message: z.string().nullable(),
|
message: z.string().nullable(),
|
||||||
|
metodCalc: z.union([z.literal('CRM'), z.literal('ELT')]),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
numCalc: z.number(),
|
numCalc: z.string(),
|
||||||
requestId: z.string(),
|
requestId: z.string(),
|
||||||
skCalcId: z.string(),
|
skCalcId: z.string(),
|
||||||
status: z.string().nullable(),
|
status: z.string().nullable(),
|
||||||
|
|||||||
@ -2,21 +2,28 @@ const { z } = require('zod');
|
|||||||
|
|
||||||
const envSchema = z.object({
|
const envSchema = z.object({
|
||||||
BASE_PATH: z.string().optional().default(''),
|
BASE_PATH: z.string().optional().default(''),
|
||||||
|
DEV_AUTH_TOKEN: z.string().optional(),
|
||||||
|
PASSWORD_1C_TRANSTAX: z.string(),
|
||||||
PORT: z.string().optional(),
|
PORT: z.string().optional(),
|
||||||
SENTRY_AUTH_TOKEN: z.string(),
|
SENTRY_AUTH_TOKEN: z.string(),
|
||||||
SENTRY_DSN: z.string(),
|
SENTRY_DSN: z.string(),
|
||||||
SENTRY_ENVIRONMENT: z.string(),
|
SENTRY_ENVIRONMENT: z.string(),
|
||||||
URL_1C_TRANSTAX_DIRECT: z.string(),
|
URL_1C_TRANSTAX_DIRECT: z.string(),
|
||||||
|
URL_CACHE_DELETE_QUERY_DIRECT: z.string().default('http://api:3001/proxy/delete-query'),
|
||||||
|
URL_CACHE_GET_QUERIES_DIRECT: z.string().default('http://api:3001/proxy/get-queries'),
|
||||||
|
URL_CACHE_GET_QUERY_DIRECT: z.string().default('http://api:3001/proxy/get-query'),
|
||||||
|
URL_CACHE_RESET_QUERIES_DIRECT: z.string().default('http://api:3001/proxy/reset'),
|
||||||
URL_CORE_CALCULATE_DIRECT: z.string(),
|
URL_CORE_CALCULATE_DIRECT: z.string(),
|
||||||
URL_CORE_FINGAP_DIRECT: z.string(),
|
URL_CORE_FINGAP_DIRECT: z.string(),
|
||||||
URL_CRM_CREATEKP_DIRECT: z.string(),
|
URL_CRM_CREATEKP_DIRECT: z.string(),
|
||||||
URL_CRM_DOWNLOADKP_BASE: z.string(),
|
URL_CRM_DOWNLOADKP_BASE: z.string(),
|
||||||
URL_CRM_GRAPHQL_DIRECT: z.string(),
|
URL_CRM_GRAPHQL_DIRECT: z.string(),
|
||||||
URL_CRM_GRAPHQL_PROXY: z.string(),
|
URL_CRM_GRAPHQL_PROXY: z.string().default('http://api:3001/proxy/graphql'),
|
||||||
URL_ELT_KASKO_DIRECT: z.string(),
|
URL_ELT_KASKO_DIRECT: z.string(),
|
||||||
URL_ELT_OSAGO_DIRECT: z.string(),
|
URL_ELT_OSAGO_DIRECT: z.string(),
|
||||||
URL_GET_USER_DIRECT: z.string(),
|
URL_GET_USER_DIRECT: z.string(),
|
||||||
USE_DEV_COLORS: z.unknown().optional().transform(Boolean),
|
USE_DEV_COLORS: z.unknown().optional().transform(Boolean),
|
||||||
|
USERNAME_1C_TRANSTAX: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = envSchema;
|
module.exports = envSchema;
|
||||||
|
|||||||
@ -4,6 +4,7 @@ export const ResultValuesSchema = z.object({
|
|||||||
_resultContractEconomy: z.number(),
|
_resultContractEconomy: z.number(),
|
||||||
_resultContractEconomyWithVAT: z.number(),
|
_resultContractEconomyWithVAT: z.number(),
|
||||||
_resultPi: z.number(),
|
_resultPi: z.number(),
|
||||||
|
_resultPiRepayment: z.number(),
|
||||||
_resultSumCredit: z.number(),
|
_resultSumCredit: z.number(),
|
||||||
_resultSumCreditPayment: z.number(),
|
_resultSumCreditPayment: z.number(),
|
||||||
_resultVatRecoverable: z.number(),
|
_resultVatRecoverable: z.number(),
|
||||||
|
|||||||
@ -2,6 +2,7 @@ const envSchema = require('./env');
|
|||||||
|
|
||||||
const publicRuntimeConfigSchema = envSchema.pick({
|
const publicRuntimeConfigSchema = envSchema.pick({
|
||||||
BASE_PATH: true,
|
BASE_PATH: true,
|
||||||
|
DEV_AUTH_TOKEN: true,
|
||||||
SENTRY_DSN: true,
|
SENTRY_DSN: true,
|
||||||
SENTRY_ENVIRONMENT: true,
|
SENTRY_ENVIRONMENT: true,
|
||||||
USE_DEV_COLORS: true,
|
USE_DEV_COLORS: true,
|
||||||
@ -9,10 +10,16 @@ const publicRuntimeConfigSchema = envSchema.pick({
|
|||||||
|
|
||||||
const serverRuntimeConfigSchema = envSchema.pick({
|
const serverRuntimeConfigSchema = envSchema.pick({
|
||||||
BASE_PATH: true,
|
BASE_PATH: true,
|
||||||
|
DEV_AUTH_TOKEN: true,
|
||||||
|
PASSWORD_1C_TRANSTAX: true,
|
||||||
PORT: true,
|
PORT: true,
|
||||||
SENTRY_DSN: true,
|
SENTRY_DSN: true,
|
||||||
SENTRY_ENVIRONMENT: true,
|
SENTRY_ENVIRONMENT: true,
|
||||||
URL_1C_TRANSTAX_DIRECT: true,
|
URL_1C_TRANSTAX_DIRECT: true,
|
||||||
|
URL_CACHE_DELETE_QUERY_DIRECT: true,
|
||||||
|
URL_CACHE_GET_QUERIES_DIRECT: true,
|
||||||
|
URL_CACHE_GET_QUERY_DIRECT: true,
|
||||||
|
URL_CACHE_RESET_QUERIES_DIRECT: true,
|
||||||
URL_CORE_CALCULATE_DIRECT: true,
|
URL_CORE_CALCULATE_DIRECT: true,
|
||||||
URL_CORE_FINGAP_DIRECT: true,
|
URL_CORE_FINGAP_DIRECT: true,
|
||||||
URL_CRM_CREATEKP_DIRECT: true,
|
URL_CRM_CREATEKP_DIRECT: true,
|
||||||
@ -21,6 +28,7 @@ const serverRuntimeConfigSchema = envSchema.pick({
|
|||||||
URL_ELT_KASKO_DIRECT: true,
|
URL_ELT_KASKO_DIRECT: true,
|
||||||
URL_ELT_OSAGO_DIRECT: true,
|
URL_ELT_OSAGO_DIRECT: true,
|
||||||
URL_GET_USER_DIRECT: true,
|
URL_GET_USER_DIRECT: true,
|
||||||
|
USERNAME_1C_TRANSTAX: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@ -129,6 +129,7 @@ const ValuesSchema = z.object({
|
|||||||
withTrailer: z.boolean(),
|
withTrailer: z.boolean(),
|
||||||
partialVAT: z.boolean(),
|
partialVAT: z.boolean(),
|
||||||
floatingRate: z.boolean(),
|
floatingRate: z.boolean(),
|
||||||
|
quoteShowAcceptLimit: z.boolean(),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Link Values
|
* Link Values
|
||||||
|
|||||||
@ -22,6 +22,10 @@ function getUrls() {
|
|||||||
URL_ELT_KASKO_DIRECT,
|
URL_ELT_KASKO_DIRECT,
|
||||||
URL_ELT_OSAGO_DIRECT,
|
URL_ELT_OSAGO_DIRECT,
|
||||||
URL_CRM_GRAPHQL_PROXY,
|
URL_CRM_GRAPHQL_PROXY,
|
||||||
|
URL_CACHE_GET_QUERIES_DIRECT,
|
||||||
|
URL_CACHE_DELETE_QUERY_DIRECT,
|
||||||
|
URL_CACHE_RESET_QUERIES_DIRECT,
|
||||||
|
URL_CACHE_GET_QUERY_DIRECT,
|
||||||
} = serverRuntimeConfigSchema.parse(serverRuntimeConfig);
|
} = serverRuntimeConfigSchema.parse(serverRuntimeConfig);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -29,6 +33,10 @@ function getUrls() {
|
|||||||
PORT,
|
PORT,
|
||||||
SENTRY_DSN,
|
SENTRY_DSN,
|
||||||
URL_1C_TRANSTAX: URL_1C_TRANSTAX_DIRECT,
|
URL_1C_TRANSTAX: URL_1C_TRANSTAX_DIRECT,
|
||||||
|
URL_CACHE_DELETE_QUERY: URL_CACHE_DELETE_QUERY_DIRECT,
|
||||||
|
URL_CACHE_GET_QUERIES: URL_CACHE_GET_QUERIES_DIRECT,
|
||||||
|
URL_CACHE_GET_QUERY: URL_CACHE_GET_QUERY_DIRECT,
|
||||||
|
URL_CACHE_RESET_QUERIES: URL_CACHE_RESET_QUERIES_DIRECT,
|
||||||
URL_CORE_CALCULATE: URL_CORE_CALCULATE_DIRECT,
|
URL_CORE_CALCULATE: URL_CORE_CALCULATE_DIRECT,
|
||||||
URL_CORE_FINGAP: URL_CORE_FINGAP_DIRECT,
|
URL_CORE_FINGAP: URL_CORE_FINGAP_DIRECT,
|
||||||
URL_CRM_CREATEKP: URL_CRM_CREATEKP_DIRECT,
|
URL_CRM_CREATEKP: URL_CRM_CREATEKP_DIRECT,
|
||||||
@ -44,6 +52,10 @@ function getUrls() {
|
|||||||
BASE_PATH,
|
BASE_PATH,
|
||||||
SENTRY_DSN,
|
SENTRY_DSN,
|
||||||
URL_1C_TRANSTAX: withBasePath(urls.URL_1C_TRANSTAX_PROXY),
|
URL_1C_TRANSTAX: withBasePath(urls.URL_1C_TRANSTAX_PROXY),
|
||||||
|
URL_CACHE_DELETE_QUERY: withBasePath(urls.URL_CACHE_DELETE_QUERY_PROXY),
|
||||||
|
URL_CACHE_GET_QUERIES: withBasePath(urls.URL_CACHE_GET_QUERIES_PROXY),
|
||||||
|
URL_CACHE_GET_QUERY: withBasePath(urls.URL_CACHE_GET_QUERY_PROXY),
|
||||||
|
URL_CACHE_RESET_QUERIES: withBasePath(urls.URL_CACHE_RESET_QUERIES_PROXY),
|
||||||
URL_CORE_CALCULATE: withBasePath(urls.URL_CORE_CALCULATE_PROXY),
|
URL_CORE_CALCULATE: withBasePath(urls.URL_CORE_CALCULATE_PROXY),
|
||||||
URL_CORE_FINGAP: withBasePath(urls.URL_CORE_FINGAP_PROXY),
|
URL_CORE_FINGAP: withBasePath(urls.URL_CORE_FINGAP_PROXY),
|
||||||
URL_CRM_CREATEKP: withBasePath(urls.URL_CRM_CREATEKP_PROXY),
|
URL_CRM_CREATEKP: withBasePath(urls.URL_CRM_CREATEKP_PROXY),
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
export const unlimitedRoles = ['Калькулятор без ограничений'];
|
export const unlimitedRoles = ['Калькулятор без ограничений'];
|
||||||
export const defaultRoles = ['Лизинговый калькулятор', 'МПЛ', 'Управляющий подразделением'];
|
export const defaultRoles = ['Лизинговый калькулятор', 'МПЛ', 'Управляющий подразделением'];
|
||||||
|
export const adminRoles = ['Калькулятор без ограничений', 'Системный администратор'];
|
||||||
export const usersSuper = ['akalinina', 'vchikalkin'];
|
export const usersSuper = ['akalinina', 'vchikalkin'];
|
||||||
|
|||||||
3
apps/web/constants/page.js
Normal file
3
apps/web/constants/page.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export const PAGE_TITLE = 'Лизинговый калькулятор - Эволюция';
|
||||||
|
export const PAGE_DESCRIPTION =
|
||||||
|
'Лизинговый калькулятор - Эволюция - Расчет лизинговых платежей - Создание КП';
|
||||||
@ -1,5 +1,9 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
URL_1C_TRANSTAX_PROXY: '/api/1c/transtax',
|
URL_1C_TRANSTAX_PROXY: '/api/1c/transtax',
|
||||||
|
URL_CACHE_DELETE_QUERY_PROXY: '/api/admin/cache/delete',
|
||||||
|
URL_CACHE_GET_QUERIES_PROXY: '/api/admin/cache/get-queries',
|
||||||
|
URL_CACHE_GET_QUERY_PROXY: '/api/admin/cache/get-query',
|
||||||
|
URL_CACHE_RESET_QUERIES_PROXY: '/api/admin/cache/reset',
|
||||||
URL_CORE_CALCULATE_PROXY: '/api/core/calculate',
|
URL_CORE_CALCULATE_PROXY: '/api/core/calculate',
|
||||||
URL_CORE_FINGAP_PROXY: '/api/core/fingap',
|
URL_CORE_FINGAP_PROXY: '/api/core/fingap',
|
||||||
URL_CRM_CREATEKP_PROXY: '/api/crm/create-kp',
|
URL_CRM_CREATEKP_PROXY: '/api/crm/create-kp',
|
||||||
|
|||||||
@ -12,3 +12,5 @@ export const VEHICLE_SEATS = 20;
|
|||||||
export const ESN = 1.3;
|
export const ESN = 1.3;
|
||||||
export const NSIB_MAX = 5_000_000;
|
export const NSIB_MAX = 5_000_000;
|
||||||
export const NDFL = 0.13;
|
export const NDFL = 0.13;
|
||||||
|
|
||||||
|
export const IRR_THRESHOLD = 0.001;
|
||||||
|
|||||||
34
apps/web/context/navigation.tsx
Normal file
34
apps/web/context/navigation.tsx
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { createContext, useEffect, useMemo, useState } from 'react';
|
||||||
|
|
||||||
|
type Tab = {
|
||||||
|
icon: JSX.Element;
|
||||||
|
key: string;
|
||||||
|
title: string;
|
||||||
|
useShowBadge?: () => boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
type NavigationContextType = {
|
||||||
|
currentTab: string;
|
||||||
|
setCurrentTab: (tab: string) => void;
|
||||||
|
setTabsList: (list: Tab[]) => void;
|
||||||
|
tabsList: Tab[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const NavigationContext = createContext<NavigationContextType>({} as NavigationContextType);
|
||||||
|
|
||||||
|
export function NavigationProvider({ children }: { readonly children: React.ReactNode }) {
|
||||||
|
const [currentTab, setCurrentTab] = useState('');
|
||||||
|
const [tabsList, setTabsList] = useState<Tab[]>([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const defaultTab = tabsList.at(0);
|
||||||
|
if (defaultTab) setCurrentTab(defaultTab.key);
|
||||||
|
}, [tabsList]);
|
||||||
|
|
||||||
|
const value = useMemo(
|
||||||
|
() => ({ currentTab, setCurrentTab, setTabsList, tabsList }),
|
||||||
|
[currentTab, setCurrentTab, setTabsList, tabsList]
|
||||||
|
);
|
||||||
|
|
||||||
|
return <NavigationContext.Provider value={value}>{children}</NavigationContext.Provider>;
|
||||||
|
}
|
||||||
@ -8,7 +8,7 @@ query GetTransactionCurrencies {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetTransactionCurrency($currencyid: Uuid!) {
|
query GetTransactionCurrency($currencyid: UUID!) {
|
||||||
transactioncurrency(transactioncurrencyid: $currencyid) {
|
transactioncurrency(transactioncurrencyid: $currencyid) {
|
||||||
currencysymbol
|
currencysymbol
|
||||||
isocurrencycode
|
isocurrencycode
|
||||||
@ -17,20 +17,33 @@ query GetTransactionCurrency($currencyid: Uuid!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetCurrencyChanges($currentDate: DateTime) {
|
query GetCurrencyChanges($currentDate: DateTime) {
|
||||||
evo_currencychanges(statecode: 0, evo_coursedate_param: { eq: $currentDate }) {
|
evo_currencychanges(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: [
|
||||||
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_coursedate", eq: $currentDate } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
) {
|
||||||
evo_currencychange
|
evo_currencychange
|
||||||
evo_ref_transactioncurrency
|
evo_ref_transactioncurrency
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetLeads($domainname: String) {
|
query GetLeads($domainname: String) {
|
||||||
leads(owner_domainname: $domainname) {
|
systemusers(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: { filterConditionString: { fieldName: "domainname", eq: $domainname } }
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
leads(orderby: { fieldName: "createdon", sortingType: DESC }) {
|
||||||
label: fullname
|
label: fullname
|
||||||
value: leadid
|
value: leadid
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetLead($leadid: Uuid!) {
|
query GetLead($leadid: UUID!) {
|
||||||
lead(leadid: $leadid) {
|
lead(leadid: $leadid) {
|
||||||
evo_agent_accountid
|
evo_agent_accountid
|
||||||
evo_double_agent_accountid
|
evo_double_agent_accountid
|
||||||
@ -52,7 +65,7 @@ query GetLead($leadid: Uuid!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetOpportunity($opportunityid: Uuid!) {
|
query GetOpportunity($opportunityid: UUID!) {
|
||||||
opportunity(opportunityid: $opportunityid) {
|
opportunity(opportunityid: $opportunityid) {
|
||||||
evo_leadid
|
evo_leadid
|
||||||
accountidData {
|
accountidData {
|
||||||
@ -67,14 +80,28 @@ query GetOpportunity($opportunityid: Uuid!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetOpportunities($domainname: String) {
|
query GetOpportunities($domainname: String) {
|
||||||
opportunities(owner_domainname: $domainname) {
|
systemusers(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: { filterConditionString: { fieldName: "domainname", eq: $domainname } }
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
opportunities(orderby: { fieldName: "createdon", sortingType: DESC }) {
|
||||||
label: name
|
label: name
|
||||||
value: opportunityid
|
value: opportunityid
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetQuotes($leadid: Uuid!) {
|
query GetQuotes($leadid: UUID!) {
|
||||||
quotes(evo_leadid: $leadid) {
|
quotes(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: [
|
||||||
|
{ filterConditionGuid: { fieldName: "evo_leadid", eq: $leadid } }
|
||||||
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
orderby: { fieldName: "createdon", sortingType: DESC }
|
||||||
|
) {
|
||||||
label: evo_quotename
|
label: evo_quotename
|
||||||
value: quoteid
|
value: quoteid
|
||||||
evo_recalc_limit
|
evo_recalc_limit
|
||||||
@ -85,8 +112,8 @@ query GetQuotes($leadid: Uuid!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetQuote($quoteId: Uuid!) {
|
query GetQuote($quoteId: UUID!) {
|
||||||
quote(quoteId: $quoteId) {
|
quote(quoteid: $quoteId) {
|
||||||
evo_baseproductid
|
evo_baseproductid
|
||||||
evo_one_year_insurance
|
evo_one_year_insurance
|
||||||
evo_min_change_price
|
evo_min_change_price
|
||||||
@ -110,11 +137,30 @@ query GetQuote($quoteId: Uuid!) {
|
|||||||
evo_promotion
|
evo_promotion
|
||||||
evo_sale_without_nds
|
evo_sale_without_nds
|
||||||
link
|
link
|
||||||
|
evo_committee_quote
|
||||||
|
evo_msfo_irr
|
||||||
|
evo_accept_quoteid
|
||||||
|
evo_power
|
||||||
|
evo_engine_volume
|
||||||
|
evo_nsib
|
||||||
|
evo_addproduct_types {
|
||||||
|
evo_product_type
|
||||||
|
}
|
||||||
|
evo_db_accept_registration
|
||||||
|
evo_product_risks {
|
||||||
|
evo_addproduct_typeid
|
||||||
|
}
|
||||||
|
evo_fingap_payer
|
||||||
|
evo_osago_payer
|
||||||
|
evo_kasko_payer
|
||||||
|
evo_leasing_bonus_summ
|
||||||
|
evo_card_bonus_summ
|
||||||
|
evo_nsib_bonus_summ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetQuoteData($quoteId: Uuid!) {
|
query GetQuoteData($quoteId: UUID!) {
|
||||||
quote(quoteId: $quoteId) {
|
quote(quoteid: $quoteId) {
|
||||||
evo_addproduct_types {
|
evo_addproduct_types {
|
||||||
evo_product_type
|
evo_product_type
|
||||||
evo_addproduct_typeid
|
evo_addproduct_typeid
|
||||||
@ -209,7 +255,7 @@ query GetQuoteData($quoteId: Uuid!) {
|
|||||||
evo_graphs {
|
evo_graphs {
|
||||||
createdon
|
createdon
|
||||||
evo_sumpay_withnds
|
evo_sumpay_withnds
|
||||||
evo_planpayments {
|
evo_planpayments(orderby: { fieldName: "evo_plandate", sortingType: ASC }) {
|
||||||
evo_payment_ratio
|
evo_payment_ratio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,14 +309,25 @@ query GetQuoteData($quoteId: Uuid!) {
|
|||||||
evo_transactioncurrencyid
|
evo_transactioncurrencyid
|
||||||
evo_equip_price
|
evo_equip_price
|
||||||
evo_coefficien_bonus_reducttion
|
evo_coefficien_bonus_reducttion
|
||||||
|
evo_accept_limit_quote
|
||||||
|
evo_kasko_insurance_rulesidData {
|
||||||
|
evo_id
|
||||||
|
}
|
||||||
|
evo_osago_insurance_rulesiddData {
|
||||||
|
evo_id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetTarifs($currentDate: DateTime) {
|
query GetTarifs($currentDate: DateTime) {
|
||||||
evo_tarifs(
|
evo_tarifs(
|
||||||
statecode: 0
|
filterConditionGroup: {
|
||||||
evo_datefrom_param: { lte: $currentDate }
|
andFilterConditions: [
|
||||||
evo_dateto_param: { gte: $currentDate }
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
]
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_tarifid
|
value: evo_tarifid
|
||||||
@ -293,7 +350,7 @@ query GetTarifs($currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetTarif($tarifId: Uuid!) {
|
query GetTarif($tarifId: UUID!) {
|
||||||
evo_tarif(evo_tarifid: $tarifId) {
|
evo_tarif(evo_tarifid: $tarifId) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_tarifid
|
value: evo_tarifid
|
||||||
@ -307,6 +364,8 @@ query GetTarif($tarifId: Uuid!) {
|
|||||||
evo_rates {
|
evo_rates {
|
||||||
evo_datefrom
|
evo_datefrom
|
||||||
evo_rateid
|
evo_rateid
|
||||||
|
evo_type
|
||||||
|
statecode
|
||||||
}
|
}
|
||||||
evo_irr_plan
|
evo_irr_plan
|
||||||
evo_margin_min
|
evo_margin_min
|
||||||
@ -315,9 +374,13 @@ query GetTarif($tarifId: Uuid!) {
|
|||||||
|
|
||||||
query GetRates($currentDate: DateTime) {
|
query GetRates($currentDate: DateTime) {
|
||||||
evo_rates(
|
evo_rates(
|
||||||
statecode: 0
|
filterConditionGroup: {
|
||||||
evo_datefrom_param: { lte: $currentDate }
|
andFilterConditions: [
|
||||||
evo_dateto_param: { gte: $currentDate }
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
]
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_rateid
|
value: evo_rateid
|
||||||
@ -329,7 +392,7 @@ query GetRates($currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetRate($rateId: Uuid!) {
|
query GetRate($rateId: UUID!) {
|
||||||
evo_rate(evo_rateid: $rateId) {
|
evo_rate(evo_rateid: $rateId) {
|
||||||
evo_base_rate
|
evo_base_rate
|
||||||
evo_credit_period
|
evo_credit_period
|
||||||
@ -340,10 +403,14 @@ query GetRate($rateId: Uuid!) {
|
|||||||
|
|
||||||
query GetProducts($currentDate: DateTime) {
|
query GetProducts($currentDate: DateTime) {
|
||||||
evo_baseproducts(
|
evo_baseproducts(
|
||||||
statecode: 0
|
filterConditionGroup: {
|
||||||
evo_relation: [100000000]
|
andFilterConditions: [
|
||||||
evo_datefrom_param: { lte: $currentDate }
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
evo_dateto_param: { gte: $currentDate }
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
{ filterConditionMultyPicklist: { fieldName: "evo_relation", oneof: [100000000] } }
|
||||||
|
]
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_baseproductid
|
value: evo_baseproductid
|
||||||
@ -354,7 +421,7 @@ query GetProducts($currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetProduct($productId: Uuid!) {
|
query GetProduct($productId: UUID!) {
|
||||||
evo_baseproduct(evo_baseproductid: $productId) {
|
evo_baseproduct(evo_baseproductid: $productId) {
|
||||||
evo_leasingobject_types {
|
evo_leasingobject_types {
|
||||||
evo_leasingobject_typeid
|
evo_leasingobject_typeid
|
||||||
@ -380,9 +447,13 @@ query GetProduct($productId: Uuid!) {
|
|||||||
|
|
||||||
query GetSubsidies($currentDate: DateTime) {
|
query GetSubsidies($currentDate: DateTime) {
|
||||||
evo_subsidies(
|
evo_subsidies(
|
||||||
statecode: 0
|
filterConditionGroup: {
|
||||||
evo_datefrom_param: { lte: $currentDate }
|
andFilterConditions: [
|
||||||
evo_dateto_param: { gte: $currentDate }
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
]
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_subsidyid
|
value: evo_subsidyid
|
||||||
@ -390,7 +461,7 @@ query GetSubsidies($currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetSubsidy($subsidyId: Uuid!) {
|
query GetSubsidy($subsidyId: UUID!) {
|
||||||
evo_subsidy(evo_subsidyid: $subsidyId) {
|
evo_subsidy(evo_subsidyid: $subsidyId) {
|
||||||
evo_leasingobject_types {
|
evo_leasingobject_types {
|
||||||
evo_leasingobject_typeid
|
evo_leasingobject_typeid
|
||||||
@ -412,7 +483,7 @@ query GetSubsidy($subsidyId: Uuid!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetImportProgram($importProgramId: Uuid!) {
|
query GetImportProgram($importProgramId: UUID!) {
|
||||||
importProgram: evo_subsidy(evo_subsidyid: $importProgramId) {
|
importProgram: evo_subsidy(evo_subsidyid: $importProgramId) {
|
||||||
evo_leasingobject_types {
|
evo_leasingobject_types {
|
||||||
evo_leasingobject_typeid
|
evo_leasingobject_typeid
|
||||||
@ -430,7 +501,7 @@ query GetImportProgram($importProgramId: Uuid!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetRegions {
|
query GetRegions {
|
||||||
evo_regions {
|
evo_regions(orderby: { fieldName: "evo_name", sortingType: ASC }) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_regionid
|
value: evo_regionid
|
||||||
evo_fias_id
|
evo_fias_id
|
||||||
@ -438,7 +509,7 @@ query GetRegions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetRegion($regionId: Uuid!) {
|
query GetRegion($regionId: UUID!) {
|
||||||
evo_region(evo_regionid: $regionId) {
|
evo_region(evo_regionid: $regionId) {
|
||||||
evo_oktmo
|
evo_oktmo
|
||||||
accounts {
|
accounts {
|
||||||
@ -448,8 +519,16 @@ query GetRegion($regionId: Uuid!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetTowns($regionId: Uuid!) {
|
query GetTowns($regionId: UUID!) {
|
||||||
evo_towns(evo_regionid: $regionId) {
|
evo_towns(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: [
|
||||||
|
{ filterConditionGuid: { fieldName: "evo_regionid", eq: $regionId } }
|
||||||
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
orderby: { fieldName: "evo_name", sortingType: ASC }
|
||||||
|
) {
|
||||||
evo_fias_id
|
evo_fias_id
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_townid
|
value: evo_townid
|
||||||
@ -457,22 +536,33 @@ query GetTowns($regionId: Uuid!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetTown($townId: Uuid!) {
|
query GetTown($townId: UUID!) {
|
||||||
evo_town(evo_townid: $townId) {
|
evo_town(evo_townid: $townId) {
|
||||||
evo_kladr_id
|
evo_kladr_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetGPSBrands {
|
query GetGPSBrands {
|
||||||
evo_gps_brands(statecode: 0) {
|
evo_gps_brands(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: { filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
}
|
||||||
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_gps_brandid
|
value: evo_gps_brandid
|
||||||
evo_id
|
evo_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetGPSModels($gpsBrandId: Uuid!) {
|
query GetGPSModels($gpsBrandId: UUID!) {
|
||||||
evo_gps_models(evo_gps_brandid: $gpsBrandId) {
|
evo_gps_models(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: [
|
||||||
|
{ filterConditionGuid: { fieldName: "evo_gps_brandid", eq: $gpsBrandId } }
|
||||||
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_gps_modelid
|
value: evo_gps_modelid
|
||||||
evo_id
|
evo_id
|
||||||
@ -480,14 +570,18 @@ query GetGPSModels($gpsBrandId: Uuid!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetLeaseObjectTypes {
|
query GetLeaseObjectTypes {
|
||||||
evo_leasingobject_types(statecode: 0) {
|
evo_leasingobject_types(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: { filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
}
|
||||||
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_leasingobject_typeid
|
value: evo_leasingobject_typeid
|
||||||
evo_leasingobject_typeid
|
evo_leasingobject_typeid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetLeaseObjectType($leaseObjectTypeId: Uuid!) {
|
query GetLeaseObjectType($leaseObjectTypeId: UUID!) {
|
||||||
evo_leasingobject_type(evo_leasingobject_typeid: $leaseObjectTypeId) {
|
evo_leasingobject_type(evo_leasingobject_typeid: $leaseObjectTypeId) {
|
||||||
evo_vehicle_type
|
evo_vehicle_type
|
||||||
evo_id
|
evo_id
|
||||||
@ -498,11 +592,21 @@ query GetLeaseObjectType($leaseObjectTypeId: Uuid!) {
|
|||||||
evo_expluatation_period2
|
evo_expluatation_period2
|
||||||
evo_depreciation_rate1
|
evo_depreciation_rate1
|
||||||
evo_depreciation_rate2
|
evo_depreciation_rate2
|
||||||
|
evo_trailer
|
||||||
|
evo_vehicle_body_type_option
|
||||||
|
evo_vehicle_body_types {
|
||||||
|
evo_vehicle_body_typeid
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetBrands {
|
query GetBrands {
|
||||||
evo_brands(statecode: 0) {
|
evo_brands(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: { filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
}
|
||||||
|
orderby: { fieldName: "evo_name", sortingType: ASC }
|
||||||
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_brandid
|
value: evo_brandid
|
||||||
evo_brandid
|
evo_brandid
|
||||||
@ -510,7 +614,7 @@ query GetBrands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetBrand($brandId: Uuid!) {
|
query GetBrand($brandId: UUID!) {
|
||||||
evo_brand(evo_brandid: $brandId) {
|
evo_brand(evo_brandid: $brandId) {
|
||||||
evo_id
|
evo_id
|
||||||
evo_importer_reward_perc
|
evo_importer_reward_perc
|
||||||
@ -520,16 +624,26 @@ query GetBrand($brandId: Uuid!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetModels($brandId: Uuid!) {
|
query GetModels($brandId: UUID!) {
|
||||||
evo_models(statecode: 0, evo_brandid: $brandId) {
|
evo_models(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: [
|
||||||
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
{ filterConditionGuid: { fieldName: "evo_brandid", eq: $brandId } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
orderby: { fieldName: "evo_name", sortingType: ASC }
|
||||||
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_modelid
|
value: evo_modelid
|
||||||
evo_modelid
|
evo_modelid
|
||||||
evo_vehicle_type
|
evo_vehicle_type
|
||||||
|
evo_trailer_sign
|
||||||
|
evo_vehicle_body_typeid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetModel($modelId: Uuid!) {
|
query GetModel($modelId: UUID!) {
|
||||||
evo_model(evo_modelid: $modelId) {
|
evo_model(evo_modelid: $modelId) {
|
||||||
evo_impairment_groupidData {
|
evo_impairment_groupidData {
|
||||||
evo_name
|
evo_name
|
||||||
@ -541,18 +655,27 @@ query GetModel($modelId: Uuid!) {
|
|||||||
evo_id_elt
|
evo_id_elt
|
||||||
}
|
}
|
||||||
evo_running_gear
|
evo_running_gear
|
||||||
|
evo_trailer_sign
|
||||||
|
evo_vehicle_body_typeid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetConfigurations($modelId: Uuid!) {
|
query GetConfigurations($modelId: UUID!) {
|
||||||
evo_equipments(statecode: 0, evo_modelid: $modelId) {
|
evo_equipments(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: [
|
||||||
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
{ filterConditionGuid: { fieldName: "evo_modelid", eq: $modelId } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_equipmentid
|
value: evo_equipmentid
|
||||||
evo_start_production_year
|
evo_start_production_year
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetConfiguration($configurationId: Uuid!) {
|
query GetConfiguration($configurationId: UUID!) {
|
||||||
evo_equipment(evo_equipmentid: $configurationId) {
|
evo_equipment(evo_equipmentid: $configurationId) {
|
||||||
evo_impairment_groupidData {
|
evo_impairment_groupidData {
|
||||||
evo_name
|
evo_name
|
||||||
@ -561,7 +684,7 @@ query GetConfiguration($configurationId: Uuid!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetDealers {
|
query GetDealers {
|
||||||
dealers: accounts(evo_account_type: [100000001], statecode: 0, evo_legal_form: 100000001) {
|
dealers {
|
||||||
label: name
|
label: name
|
||||||
value: accountid
|
value: accountid
|
||||||
accountid
|
accountid
|
||||||
@ -569,16 +692,16 @@ query GetDealers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetDealer($dealerId: Uuid!) {
|
query GetDealer($dealerId: UUID!) {
|
||||||
dealer: account(accountid: $dealerId) {
|
dealer(accountid: $dealerId) {
|
||||||
evo_return_leasing_dealer
|
evo_return_leasing_dealer
|
||||||
evo_broker_accountid
|
evo_broker_accountid
|
||||||
evo_supplier_financing_accept
|
evo_supplier_financing_accept
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetDealerPersons($dealerId: Uuid!) {
|
query GetDealerPersons($dealerId: UUID!) {
|
||||||
dealerPersons: salon_providers(statecode: 0, salonaccountid: $dealerId) {
|
dealerPersons: dealer_persons(salonaccountid: $dealerId) {
|
||||||
label: name
|
label: name
|
||||||
value: accountid
|
value: accountid
|
||||||
accountid
|
accountid
|
||||||
@ -588,27 +711,46 @@ query GetDealerPersons($dealerId: Uuid!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetDealerPerson($dealerPersonId: Uuid!) {
|
query GetDealerPerson($dealerPersonId: UUID!) {
|
||||||
account(accountid: $dealerPersonId) {
|
dealer_person(accountid: $dealerPersonId) {
|
||||||
evo_supplier_type
|
evo_supplier_type
|
||||||
evo_supplier_financing_accept
|
evo_supplier_financing_accept
|
||||||
|
evo_return_leasing_dealer
|
||||||
|
evo_broker_accountid
|
||||||
|
evo_supplier_financing_accept
|
||||||
|
evo_legal_form
|
||||||
|
evo_inn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetAgent($agentid: Uuid!) {
|
query GetAgent($agentid: UUID!) {
|
||||||
agent: account(accountid: $agentid) {
|
agent(accountid: $agentid) {
|
||||||
label: name
|
label: name
|
||||||
value: accountid
|
value: accountid
|
||||||
|
evo_inn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetRewardConditions($agentid: Uuid!, $currentDate: DateTime) {
|
query GetRewardConditions($agentid: UUID!, $currentDate: DateTime) {
|
||||||
evo_reward_conditions(
|
evo_reward_conditions(
|
||||||
evo_agent_accountid: $agentid
|
filterConditionGroup: {
|
||||||
evo_datefrom_param: { lte: $currentDate }
|
andFilterConditionGroup: [
|
||||||
evo_dateto_param: { gte: $currentDate }
|
{
|
||||||
statecode: 0
|
orFilterConditions: [
|
||||||
evo_agency_agreementid_param: { has: true }
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", eq: null } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
andFilterConditions: [
|
||||||
|
{ filterConditionGuid: { fieldName: "evo_agent_accountid", eq: $agentid } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
{ filterConditionGuid: { fieldName: "evo_agency_agreementid", neq: null } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
label: evo_name
|
label: evo_name
|
||||||
value: evo_reward_conditionid
|
value: evo_reward_conditionid
|
||||||
@ -617,7 +759,7 @@ query GetRewardConditions($agentid: Uuid!, $currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetRewardCondition($conditionId: Uuid!) {
|
query GetRewardCondition($conditionId: UUID!) {
|
||||||
evo_reward_condition(evo_reward_conditionid: $conditionId) {
|
evo_reward_condition(evo_reward_conditionid: $conditionId) {
|
||||||
evo_reward_summ
|
evo_reward_summ
|
||||||
evo_reduce_reward
|
evo_reduce_reward
|
||||||
@ -632,16 +774,27 @@ query GetRewardCondition($conditionId: Uuid!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetSotCoefficientType($evo_id: String) {
|
query GetSotCoefficientType($evo_id: String) {
|
||||||
evo_sot_coefficient_type(evo_id: $evo_id) {
|
evo_sot_coefficient_types(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: [
|
||||||
|
{ filterConditionString: { fieldName: "evo_id", eq: $evo_id } }
|
||||||
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
) {
|
||||||
evo_sot_coefficient_typeid
|
evo_sot_coefficient_typeid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetCoefficients($currentDate: DateTime) {
|
query GetCoefficients($currentDate: DateTime) {
|
||||||
evo_coefficients(
|
evo_coefficients(
|
||||||
statecode: 0
|
filterConditionGroup: {
|
||||||
evo_datefrom_param: { lte: $currentDate }
|
andFilterConditions: [
|
||||||
evo_dateto_param: { gte: $currentDate }
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
evo_job_titleid
|
evo_job_titleid
|
||||||
evo_sot_coefficient_typeid
|
evo_sot_coefficient_typeid
|
||||||
@ -667,7 +820,11 @@ query GetCoefficients($currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query GetSystemUser($domainname: String) {
|
query GetSystemUser($domainname: String) {
|
||||||
systemuser(domainname: $domainname) {
|
systemusers(
|
||||||
|
filterConditionGroup: {
|
||||||
|
filterCondition: { filterConditionString: { fieldName: "domainname", eq: $domainname } }
|
||||||
|
}
|
||||||
|
) {
|
||||||
evo_job_titleid
|
evo_job_titleid
|
||||||
businessunitid
|
businessunitid
|
||||||
roles {
|
roles {
|
||||||
@ -685,9 +842,13 @@ fragment CoreAddProductTypesFields on evo_addproduct_type {
|
|||||||
|
|
||||||
query GetAddproductTypes($currentDate: DateTime) {
|
query GetAddproductTypes($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
statecode: 0
|
filterConditionGroup: {
|
||||||
evo_datefrom_param: { lte: $currentDate }
|
andFilterConditions: [
|
||||||
evo_dateto_param: { gte: $currentDate }
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
]
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_product_type
|
evo_product_type
|
||||||
@ -701,7 +862,7 @@ query GetAddproductTypes($currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetAddProductType($addproductTypeId: Uuid!) {
|
query GetAddProductType($addproductTypeId: UUID!) {
|
||||||
evo_addproduct_type(evo_addproduct_typeid: $addproductTypeId) {
|
evo_addproduct_type(evo_addproduct_typeid: $addproductTypeId) {
|
||||||
evo_description
|
evo_description
|
||||||
evo_helpcard_type
|
evo_helpcard_type
|
||||||
@ -725,10 +886,14 @@ query GetAddProductType($addproductTypeId: Uuid!) {
|
|||||||
|
|
||||||
query GetRegistrationTypes($currentDate: DateTime) {
|
query GetRegistrationTypes($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
statecode: 0
|
filterConditionGroup: {
|
||||||
evo_datefrom_param: { lte: $currentDate }
|
andFilterConditions: [
|
||||||
evo_dateto_param: { gte: $currentDate }
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
evo_product_type: 100000001
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000001 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_leasingobject_types {
|
evo_leasingobject_types {
|
||||||
@ -744,10 +909,14 @@ query GetRegistrationTypes($currentDate: DateTime) {
|
|||||||
|
|
||||||
query GetTechnicalCards($currentDate: DateTime) {
|
query GetTechnicalCards($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
statecode: 0
|
filterConditionGroup: {
|
||||||
evo_datefrom_param: { lte: $currentDate }
|
andFilterConditions: [
|
||||||
evo_dateto_param: { gte: $currentDate }
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
evo_product_type: 100000000
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000000 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_min_period
|
evo_min_period
|
||||||
@ -761,10 +930,14 @@ query GetTechnicalCards($currentDate: DateTime) {
|
|||||||
|
|
||||||
query GetFuelCards($currentDate: DateTime) {
|
query GetFuelCards($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
statecode: 0
|
filterConditionGroup: {
|
||||||
evo_datefrom_param: { lte: $currentDate }
|
andFilterConditions: [
|
||||||
evo_dateto_param: { gte: $currentDate }
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
evo_product_type: 100000005
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000005 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_min_period
|
evo_min_period
|
||||||
@ -777,10 +950,14 @@ query GetFuelCards($currentDate: DateTime) {
|
|||||||
|
|
||||||
query GetTelematicTypes($currentDate: DateTime) {
|
query GetTelematicTypes($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
statecode: 0
|
filterConditionGroup: {
|
||||||
evo_datefrom_param: { lte: $currentDate }
|
andFilterConditions: [
|
||||||
evo_dateto_param: { gte: $currentDate }
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
evo_product_type: 100000004
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000004 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_controls_program
|
evo_controls_program
|
||||||
@ -790,10 +967,14 @@ query GetTelematicTypes($currentDate: DateTime) {
|
|||||||
|
|
||||||
query GetTrackerTypes($currentDate: DateTime) {
|
query GetTrackerTypes($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
statecode: 0
|
filterConditionGroup: {
|
||||||
evo_datefrom_param: { lte: $currentDate }
|
andFilterConditions: [
|
||||||
evo_dateto_param: { gte: $currentDate }
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
evo_product_type: 100000003
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000003 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_controls_program
|
evo_controls_program
|
||||||
@ -803,10 +984,14 @@ query GetTrackerTypes($currentDate: DateTime) {
|
|||||||
|
|
||||||
query GetInsNSIBTypes($currentDate: DateTime) {
|
query GetInsNSIBTypes($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
statecode: 0
|
filterConditionGroup: {
|
||||||
evo_datefrom_param: { lte: $currentDate }
|
andFilterConditions: [
|
||||||
evo_dateto_param: { gte: $currentDate }
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
evo_product_type: 100000002
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000002 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_max_period
|
evo_max_period
|
||||||
@ -824,10 +1009,14 @@ query GetInsNSIBTypes($currentDate: DateTime) {
|
|||||||
|
|
||||||
query GetLeasingWithoutKaskoTypes($currentDate: DateTime) {
|
query GetLeasingWithoutKaskoTypes($currentDate: DateTime) {
|
||||||
evo_addproduct_types(
|
evo_addproduct_types(
|
||||||
statecode: 0
|
filterConditionGroup: {
|
||||||
evo_product_type: 100000007
|
andFilterConditions: [
|
||||||
evo_datefrom_param: { lte: $currentDate }
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
evo_dateto_param: { gte: $currentDate }
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000007 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
...CoreAddProductTypesFields
|
...CoreAddProductTypesFields
|
||||||
evo_product_type
|
evo_product_type
|
||||||
@ -847,16 +1036,45 @@ query GetLeasingWithoutKaskoTypes($currentDate: DateTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetInsuranceCompany($accountId: Uuid!) {
|
query GetOsagoAddproductTypes($currentDate: DateTime) {
|
||||||
account(accountid: $accountId) {
|
evo_addproduct_types(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: [
|
||||||
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
{ filterConditionInt: { fieldName: "evo_product_type", eq: 100000008 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
evo_product_type
|
||||||
|
evo_visible_calc
|
||||||
|
evo_accountid
|
||||||
|
createdon
|
||||||
|
evo_category
|
||||||
|
evo_min_power
|
||||||
|
evo_max_power
|
||||||
|
evo_min_seats_count
|
||||||
|
evo_max_seats_count
|
||||||
|
evo_min_mass
|
||||||
|
evo_max_mass
|
||||||
|
evo_graph_price_withoutnds
|
||||||
|
evo_id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query GetInsuranceCompany($accountId: UUID!) {
|
||||||
|
account: insurance(accountid: $accountId) {
|
||||||
evo_osago_with_kasko
|
evo_osago_with_kasko
|
||||||
evo_legal_region_calc
|
evo_legal_region_calc
|
||||||
accountid
|
accountid
|
||||||
|
evo_kasko_fact_part
|
||||||
|
evo_kasko_plan_part
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetInsuranceCompanies {
|
query GetInsuranceCompanies {
|
||||||
accounts(evo_account_type: [100000002], statecode: 0) {
|
accounts: insurances {
|
||||||
evo_type_ins_policy
|
evo_type_ins_policy
|
||||||
evo_evokasko_access
|
evo_evokasko_access
|
||||||
evo_inn
|
evo_inn
|
||||||
@ -865,11 +1083,74 @@ query GetInsuranceCompanies {
|
|||||||
evo_id_elt_osago
|
evo_id_elt_osago
|
||||||
evo_id_elt
|
evo_id_elt
|
||||||
evo_id_elt_smr
|
evo_id_elt_smr
|
||||||
|
evo_osago_id
|
||||||
|
evo_kasko_category
|
||||||
|
evo_osago_category
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query GetEltInsuranceRules($currentDate: DateTime) {
|
||||||
|
evo_insurance_ruleses(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: [
|
||||||
|
{ filterConditionInt: { fieldName: "statecode", eq: 0 } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_datefrom", lte: $currentDate } }
|
||||||
|
{ filterConditionDateTime: { fieldName: "evo_dateto", gte: $currentDate } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
evo_id
|
||||||
|
evo_datefrom
|
||||||
|
evo_dateto
|
||||||
|
evo_risk
|
||||||
|
evo_category
|
||||||
|
evo_min_period
|
||||||
|
evo_max_period
|
||||||
|
evo_object_type
|
||||||
|
evo_use_for
|
||||||
|
evo_min_price
|
||||||
|
evo_max_price
|
||||||
|
evo_min_year
|
||||||
|
evo_max_year
|
||||||
|
evo_min_power
|
||||||
|
evo_max_power
|
||||||
|
evo_enginie_type
|
||||||
|
evo_opf
|
||||||
|
evo_min_mileage
|
||||||
|
evo_max_mileage
|
||||||
|
evo_brand
|
||||||
|
evo_model
|
||||||
|
evo_region
|
||||||
|
evo_dealer
|
||||||
|
evo_rules_type
|
||||||
|
evo_message
|
||||||
|
evo_discount
|
||||||
|
evo_insurer_accountid
|
||||||
|
evo_brand
|
||||||
|
evo_model
|
||||||
|
evo_region
|
||||||
|
evo_dealer
|
||||||
|
evo_brands {
|
||||||
|
evo_brandid
|
||||||
|
}
|
||||||
|
evo_models {
|
||||||
|
evo_modelid
|
||||||
|
}
|
||||||
|
accounts {
|
||||||
|
accountid
|
||||||
|
}
|
||||||
|
evo_regions {
|
||||||
|
evo_regionid
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query GetRoles($roleName: String) {
|
query GetRoles($roleName: String) {
|
||||||
roles(name: $roleName) {
|
roles(
|
||||||
|
filterConditionGroup: {
|
||||||
|
andFilterConditions: { filterConditionString: { fieldName: "name", eq: $roleName } }
|
||||||
|
}
|
||||||
|
) {
|
||||||
systemusers {
|
systemusers {
|
||||||
label: fullname
|
label: fullname
|
||||||
value: domainname
|
value: domainname
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,14 @@
|
|||||||
import type * as CRMTypes from '@/graphql/crm.types';
|
import type * as CRMTypes from '@/graphql/crm.types';
|
||||||
|
|
||||||
function evo_baseproducts(evo_baseproducts: CRMTypes.GetProductsQuery['evo_baseproducts']) {
|
type SystemUser = NonNullable<CRMTypes.GetSystemUserQuery['systemusers']>[number];
|
||||||
|
|
||||||
|
function evo_baseproducts(baseproducts: CRMTypes.GetProductsQuery['evo_baseproducts']) {
|
||||||
return {
|
return {
|
||||||
filterBy: {
|
filterBy: {
|
||||||
systemuser(systemuser: CRMTypes.GetSystemUserQuery['systemuser']) {
|
systemuser(systemuser: SystemUser) {
|
||||||
if (!evo_baseproducts?.length || !systemuser) return [];
|
if (!baseproducts?.length || !systemuser) return [];
|
||||||
|
|
||||||
return evo_baseproducts?.filter(
|
return baseproducts?.filter(
|
||||||
(evo_baseproduct) =>
|
(evo_baseproduct) =>
|
||||||
!evo_baseproduct?.systemusers?.length ||
|
!evo_baseproduct?.systemusers?.length ||
|
||||||
evo_baseproduct?.systemusers?.some(
|
evo_baseproduct?.systemusers?.some(
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
apps/web/hooks/index.ts
Normal file
1
apps/web/hooks/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './loading';
|
||||||
30
apps/web/hooks/loading.ts
Normal file
30
apps/web/hooks/loading.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { useRouter } from 'next/router';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
export function usePageLoading() {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
function handleStart() {
|
||||||
|
return setLoading(true);
|
||||||
|
}
|
||||||
|
function handleComplete() {
|
||||||
|
return setLoading(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
router.events.on('routeChangeStart', handleStart);
|
||||||
|
router.events.on('routeChangeComplete', handleComplete);
|
||||||
|
router.events.on('routeChangeError', handleComplete);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
router.events.off('routeChangeStart', handleStart);
|
||||||
|
router.events.off('routeChangeComplete', handleComplete);
|
||||||
|
router.events.off('routeChangeError', handleComplete);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return {
|
||||||
|
loading,
|
||||||
|
};
|
||||||
|
}
|
||||||
17
apps/web/hooks/worker.ts
Normal file
17
apps/web/hooks/worker.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/* eslint-disable no-console */
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
|
export function useServiceWorker() {
|
||||||
|
useEffect(() => {
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
navigator.serviceWorker
|
||||||
|
.register('/sw.js')
|
||||||
|
.then((registration) => {
|
||||||
|
console.log('Service Worker registered with scope:', registration.scope);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log('Service Worker registration failed:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
@ -39,20 +39,23 @@ export const handlers = [
|
|||||||
rest.post(URL_1C_TRANSTAX, (req, res, ctx) =>
|
rest.post(URL_1C_TRANSTAX, (req, res, ctx) =>
|
||||||
res(
|
res(
|
||||||
ctx.json({
|
ctx.json({
|
||||||
error: null,
|
Error: null,
|
||||||
tax: _.random(100000, 200000),
|
Tax: _.random(100000, 200000),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
rest.post(URL_ELT_OSAGO, async (req, res, ctx) => res(
|
rest.post(URL_ELT_OSAGO, async (req, res, ctx) =>
|
||||||
|
res(
|
||||||
ctx.json({
|
ctx.json({
|
||||||
numCalc: _.random(1000000, 3000000),
|
numCalc: _.random(1000000, 3000000),
|
||||||
skCalcId: _.random(50000000, 60000000).toString(),
|
skCalcId: _.random(50000000, 60000000).toString(),
|
||||||
premiumSum: _.random(10000, 20000),
|
premiumSum: _.random(10000, 20000),
|
||||||
message: 'OSAGO Message',
|
message: 'OSAGO Message',
|
||||||
})
|
})
|
||||||
)),
|
)
|
||||||
rest.post(URL_ELT_KASKO, async (req, res, ctx) => res(
|
),
|
||||||
|
rest.post(URL_ELT_KASKO, async (req, res, ctx) =>
|
||||||
|
res(
|
||||||
ctx.json({
|
ctx.json({
|
||||||
requestId: _.random(3000000, 4000000).toString(),
|
requestId: _.random(3000000, 4000000).toString(),
|
||||||
skCalcId: _.random(50000000, 60000000).toString(),
|
skCalcId: _.random(50000000, 60000000).toString(),
|
||||||
@ -67,7 +70,8 @@ export const handlers = [
|
|||||||
],
|
],
|
||||||
totalFranchise: _.random(20000, 40000),
|
totalFranchise: _.random(20000, 40000),
|
||||||
})
|
})
|
||||||
)),
|
)
|
||||||
|
),
|
||||||
|
|
||||||
// rest.post(URL_CRM_GRAPHQL, (req, res, ctx) => {
|
// rest.post(URL_CRM_GRAPHQL, (req, res, ctx) => {
|
||||||
// return res(ctx.status(503));
|
// return res(ctx.status(503));
|
||||||
|
|||||||
@ -29,6 +29,7 @@ module.exports = withSentryConfig(
|
|||||||
},
|
},
|
||||||
experimental: {
|
experimental: {
|
||||||
outputFileTracingRoot: path.join(__dirname, '../../'),
|
outputFileTracingRoot: path.join(__dirname, '../../'),
|
||||||
|
proxyTimeout: 1000 * 90,
|
||||||
},
|
},
|
||||||
images: {
|
images: {
|
||||||
deviceSizes: devices,
|
deviceSizes: devices,
|
||||||
@ -36,6 +37,17 @@ module.exports = withSentryConfig(
|
|||||||
output: 'standalone',
|
output: 'standalone',
|
||||||
publicRuntimeConfig: publicRuntimeConfigSchema.parse(env),
|
publicRuntimeConfig: publicRuntimeConfigSchema.parse(env),
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
|
|
||||||
|
async redirects() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
source: '/admin',
|
||||||
|
destination: '/admin/cache',
|
||||||
|
permanent: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
|
|
||||||
async rewrites() {
|
async rewrites() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -54,10 +66,10 @@ module.exports = withSentryConfig(
|
|||||||
destination: env.URL_CORE_FINGAP_DIRECT,
|
destination: env.URL_CORE_FINGAP_DIRECT,
|
||||||
source: urls.URL_CORE_FINGAP_PROXY,
|
source: urls.URL_CORE_FINGAP_PROXY,
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
destination: env.URL_1C_TRANSTAX_DIRECT,
|
// destination: env.URL_1C_TRANSTAX_DIRECT,
|
||||||
source: urls.URL_1C_TRANSTAX_PROXY,
|
// source: urls.URL_1C_TRANSTAX_PROXY,
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
destination: env.URL_ELT_KASKO_DIRECT,
|
destination: env.URL_ELT_KASKO_DIRECT,
|
||||||
source: urls.URL_ELT_KASKO_PROXY,
|
source: urls.URL_ELT_KASKO_PROXY,
|
||||||
@ -66,6 +78,22 @@ module.exports = withSentryConfig(
|
|||||||
destination: env.URL_ELT_OSAGO_DIRECT,
|
destination: env.URL_ELT_OSAGO_DIRECT,
|
||||||
source: urls.URL_ELT_OSAGO_PROXY,
|
source: urls.URL_ELT_OSAGO_PROXY,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
destination: env.URL_CACHE_GET_QUERIES_DIRECT,
|
||||||
|
source: urls.URL_CACHE_GET_QUERIES_PROXY,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
destination: env.URL_CACHE_DELETE_QUERY_DIRECT + '/:path*',
|
||||||
|
source: urls.URL_CACHE_DELETE_QUERY_PROXY + '/:path*',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
destination: env.URL_CACHE_RESET_QUERIES_DIRECT,
|
||||||
|
source: urls.URL_CACHE_RESET_QUERIES_PROXY,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
destination: env.URL_CACHE_GET_QUERY_DIRECT,
|
||||||
|
source: urls.URL_CACHE_GET_QUERY_PROXY,
|
||||||
|
},
|
||||||
...favicons.map((fileName) => buildFaviconRewrite(`/${fileName}`)),
|
...favicons.map((fileName) => buildFaviconRewrite(`/${fileName}`)),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|||||||
@ -4,7 +4,9 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
|
"prebuild": "NODE_ENV=production ts-node --project ./tsconfig.node.json ./scripts/generate-antd-css.ts",
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
"predev": "ts-node --project ./tsconfig.node.json ./scripts/generate-antd-css.ts",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"lint:fix": "next lint -- --fix",
|
"lint:fix": "next lint -- --fix",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
@ -14,6 +16,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apollo/client": "^3.9.5",
|
"@apollo/client": "^3.9.5",
|
||||||
|
"@artsy/fresnel": "^7.1.4",
|
||||||
"@fontsource/montserrat": "^4.5.14",
|
"@fontsource/montserrat": "^4.5.14",
|
||||||
"@sentry/nextjs": "^7.102.0",
|
"@sentry/nextjs": "^7.102.0",
|
||||||
"@sentry/node": "^7.102.0",
|
"@sentry/node": "^7.102.0",
|
||||||
@ -26,14 +29,15 @@
|
|||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.10",
|
||||||
"mobx": "^6.12.0",
|
"mobx": "^6.12.0",
|
||||||
"mobx-react-lite": "^4.0.5",
|
"mobx-react-lite": "^4.0.5",
|
||||||
"next": "^14.1.0",
|
"modern-normalize": "^2.0.0",
|
||||||
"normalize.css": "^8.0.1",
|
"next": "^14.2.5",
|
||||||
"radash": "^11.0.0",
|
"radash": "^11.0.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"styled-components": "^5.3.11",
|
"styled-components": "^5.3.11",
|
||||||
"superjson": "^2.2.1",
|
"superjson": "^2.2.1",
|
||||||
"tools": "workspace:*",
|
"tools": "workspace:*",
|
||||||
|
"ua-parser-js": "^1.0.38",
|
||||||
"ui": "workspace:*",
|
"ui": "workspace:*",
|
||||||
"use-debounce": "^9.0.4",
|
"use-debounce": "^9.0.4",
|
||||||
"zod": "^3.22.4"
|
"zod": "^3.22.4"
|
||||||
@ -51,14 +55,17 @@
|
|||||||
"@types/react": "^18.2.14",
|
"@types/react": "^18.2.14",
|
||||||
"@types/react-dom": "^18.2.6",
|
"@types/react-dom": "^18.2.6",
|
||||||
"@types/styled-components": "^5.1.26",
|
"@types/styled-components": "^5.1.26",
|
||||||
|
"@types/ua-parser-js": "^0.7.39",
|
||||||
"@vchikalkin/eslint-config-awesome": "^1.1.6",
|
"@vchikalkin/eslint-config-awesome": "^1.1.6",
|
||||||
"antd": "^5.14.2",
|
"antd": "^5.14.2",
|
||||||
"eslint": "^8.52.0",
|
"eslint": "^8.52.0",
|
||||||
"gql-sdl": "^1.0.0",
|
"gql-sdl": "^1.1.0",
|
||||||
"jest": "^29.4.3",
|
"jest": "^29.4.3",
|
||||||
"jest-environment-jsdom": "^29.3.1",
|
"jest-environment-jsdom": "^29.3.1",
|
||||||
"msw": "^1.1.0",
|
"msw": "^1.1.0",
|
||||||
|
"shared": "workspace:*",
|
||||||
"ts-jest": "^29.0.5",
|
"ts-jest": "^29.0.5",
|
||||||
|
"ts-node": "^10.9.1",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
},
|
},
|
||||||
"msw": {
|
"msw": {
|
||||||
|
|||||||
@ -1,15 +1,18 @@
|
|||||||
import 'normalize.css';
|
|
||||||
import '../styles/fonts.css';
|
import '../styles/fonts.css';
|
||||||
import '../styles/globals.css';
|
import '../styles/globals.css';
|
||||||
import '../styles/antd-fix.css';
|
import '../styles/antd-fix.css';
|
||||||
|
import '../styles/antd.min.css';
|
||||||
import initializeQueryClient from '@/api/client';
|
import initializeQueryClient from '@/api/client';
|
||||||
import initializeApollo from '@/apollo/client';
|
import initializeApollo from '@/apollo/client';
|
||||||
import { Notification } from '@/Components/Common/Notification';
|
import { Loading } from '@/Components/Common';
|
||||||
import Layout from '@/Components/Layout';
|
import Layout from '@/Components/Layout';
|
||||||
import { theme } from '@/config/ui';
|
import { theme } from '@/config/ui';
|
||||||
|
import { usePageLoading } from '@/hooks';
|
||||||
|
import { useServiceWorker } from '@/hooks/worker';
|
||||||
import StoreProvider from '@/stores/Provider';
|
import StoreProvider from '@/stores/Provider';
|
||||||
import getColors from '@/styles/colors';
|
import getColors from '@/styles/colors';
|
||||||
import { GlobalStyle } from '@/styles/global-style';
|
import { GlobalStyle } from '@/styles/global-style';
|
||||||
|
import { MediaContextProvider } from '@/styles/media';
|
||||||
import { trpcClient } from '@/trpc/client';
|
import { trpcClient } from '@/trpc/client';
|
||||||
import { ApolloProvider } from '@apollo/client';
|
import { ApolloProvider } from '@apollo/client';
|
||||||
import { QueryClientProvider } from '@tanstack/react-query';
|
import { QueryClientProvider } from '@tanstack/react-query';
|
||||||
@ -26,9 +29,15 @@ const colorPrimary = getColors().COLOR_PRIMARY;
|
|||||||
|
|
||||||
function App({ Component, pageProps }) {
|
function App({ Component, pageProps }) {
|
||||||
const { initialApolloState, initialQueryState } = pageProps;
|
const { initialApolloState, initialQueryState } = pageProps;
|
||||||
const apolloClient = useMemo(() => initializeApollo(initialApolloState), [initialApolloState]);
|
const apolloClient = useMemo(
|
||||||
|
() => initializeApollo(initialApolloState, {}),
|
||||||
|
[initialApolloState]
|
||||||
|
);
|
||||||
const queryClient = useMemo(() => initializeQueryClient(initialQueryState), [initialQueryState]);
|
const queryClient = useMemo(() => initializeQueryClient(initialQueryState), [initialQueryState]);
|
||||||
|
|
||||||
|
const { loading } = usePageLoading();
|
||||||
|
useServiceWorker();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeProvider theme={theme}>
|
<ThemeProvider theme={theme}>
|
||||||
<Head>
|
<Head>
|
||||||
@ -51,11 +60,11 @@ function App({ Component, pageProps }) {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Notification>
|
<MediaContextProvider>
|
||||||
<Layout>
|
<Layout {...pageProps}>
|
||||||
<Component {...pageProps} />
|
{loading ? <Loading /> : <Component {...pageProps} />}
|
||||||
</Layout>
|
</Layout>
|
||||||
</Notification>
|
</MediaContextProvider>
|
||||||
</AntdConfig>
|
</AntdConfig>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
</ApolloProvider>
|
</ApolloProvider>
|
||||||
|
|||||||
@ -1,36 +1,26 @@
|
|||||||
|
/* eslint-disable react/no-danger */
|
||||||
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
|
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
|
||||||
import { metaFavicon } from '@/config/meta';
|
import { metaFavicon } from '@/config/meta';
|
||||||
import { withBasePath } from '@/config/urls';
|
import { PAGE_DESCRIPTION } from '@/constants/page';
|
||||||
import Document, { Head, Html, Main, NextScript } from 'next/document';
|
import Document, { Head, Html, Main, NextScript } from 'next/document';
|
||||||
import { ServerStyleSheet } from 'styled-components';
|
import { ServerStyleSheet } from 'styled-components';
|
||||||
import { createCache, doExtraStyle, StyleProvider } from 'ui/tools';
|
|
||||||
|
|
||||||
export default class MyDocument extends Document {
|
export default class MyDocument extends Document {
|
||||||
static async getInitialProps(ctx) {
|
static async getInitialProps(ctx) {
|
||||||
const cache = createCache();
|
|
||||||
let fileName = '';
|
|
||||||
const originalRenderPage = ctx.renderPage;
|
const originalRenderPage = ctx.renderPage;
|
||||||
const sheet = new ServerStyleSheet();
|
const sheet = new ServerStyleSheet();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ctx.renderPage = () =>
|
ctx.renderPage = () =>
|
||||||
originalRenderPage({
|
originalRenderPage({
|
||||||
enhanceApp: (App) => (props) =>
|
enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />),
|
||||||
<StyleProvider cache={cache}>{sheet.collectStyles(<App {...props} />)}</StyleProvider>,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const initialProps = await Document.getInitialProps(ctx);
|
const initialProps = await Document.getInitialProps(ctx);
|
||||||
fileName = doExtraStyle({
|
|
||||||
cache,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...initialProps,
|
...initialProps,
|
||||||
styles: [
|
styles: [initialProps.styles, sheet.getStyleElement()],
|
||||||
initialProps.styles,
|
|
||||||
sheet.getStyleElement(),
|
|
||||||
fileName && <link rel="stylesheet" href={withBasePath(`/${fileName}`)} />,
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
} finally {
|
} finally {
|
||||||
sheet.seal();
|
sheet.seal();
|
||||||
@ -43,7 +33,7 @@ export default class MyDocument extends Document {
|
|||||||
<Head>
|
<Head>
|
||||||
<meta charSet="utf-8" />
|
<meta charSet="utf-8" />
|
||||||
<meta name="theme-color" content="#000000" />
|
<meta name="theme-color" content="#000000" />
|
||||||
<meta name="description" content="Лизинговый калькулятор - Эволюция" />
|
<meta name="description" content={PAGE_DESCRIPTION} />
|
||||||
{metaFavicon}
|
{metaFavicon}
|
||||||
</Head>
|
</Head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
69
apps/web/pages/admin/cache.jsx
Normal file
69
apps/web/pages/admin/cache.jsx
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
import { getQueries } from '@/api/cache/query';
|
||||||
|
import initializeApollo from '@/apollo/client';
|
||||||
|
import * as Admin from '@/Components/Admin';
|
||||||
|
import { Error } from '@/Components/Common/Error';
|
||||||
|
import { getPageTitle } from '@/utils/page';
|
||||||
|
import { makeGetUserType } from '@/utils/user';
|
||||||
|
import { dehydrate, QueryClient } from '@tanstack/react-query';
|
||||||
|
import Head from 'next/head';
|
||||||
|
|
||||||
|
function Content() {
|
||||||
|
return (
|
||||||
|
<Admin.Layout>
|
||||||
|
<Head>
|
||||||
|
<title>{getPageTitle('Управление кэшем')}</title>
|
||||||
|
</Head>
|
||||||
|
<Admin.Cache />
|
||||||
|
</Admin.Layout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Page(props) {
|
||||||
|
if (props.statusCode !== 200) return <Error {...props} />;
|
||||||
|
|
||||||
|
return <Content />;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @type {import('next').GetServerSideProps} */
|
||||||
|
export async function getServerSideProps({ req }) {
|
||||||
|
const { cookie = '' } = req.headers;
|
||||||
|
|
||||||
|
const queryClient = new QueryClient();
|
||||||
|
const apolloClient = initializeApollo(null, req.headers);
|
||||||
|
const getUserType = makeGetUserType({ apolloClient, queryClient });
|
||||||
|
|
||||||
|
try {
|
||||||
|
const user = await getUserType({ cookie });
|
||||||
|
|
||||||
|
if (!user.admin) {
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
initialQueryState: dehydrate(queryClient),
|
||||||
|
statusCode: 403,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
await queryClient.prefetchQuery(['admin', 'cache', 'queries'], ({ signal }) =>
|
||||||
|
getQueries({ signal })
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
calculation: {},
|
||||||
|
initialApolloState: apolloClient.cache.extract(),
|
||||||
|
initialQueryState: dehydrate(queryClient),
|
||||||
|
statusCode: 200,
|
||||||
|
user,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
error: JSON.stringify(error),
|
||||||
|
initialQueryState: dehydrate(queryClient),
|
||||||
|
statusCode: 500,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
38
apps/web/pages/api/1c/transtax.ts
Normal file
38
apps/web/pages/api/1c/transtax.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import type { ResponseTransTax } from '@/api/1c/types';
|
||||||
|
import { serverRuntimeConfigSchema } from '@/config/schema/runtime-config';
|
||||||
|
import { withHandleError } from '@/utils/axios';
|
||||||
|
import type { HttpError } from '@/utils/error';
|
||||||
|
import axios from 'axios';
|
||||||
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||||
|
import getConfig from 'next/config';
|
||||||
|
|
||||||
|
const { serverRuntimeConfig } = getConfig();
|
||||||
|
const { USERNAME_1C_TRANSTAX, PASSWORD_1C_TRANSTAX, URL_1C_TRANSTAX_DIRECT } =
|
||||||
|
serverRuntimeConfigSchema.parse(serverRuntimeConfig);
|
||||||
|
|
||||||
|
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
const abortController = new AbortController();
|
||||||
|
|
||||||
|
req.on('close', () => {
|
||||||
|
abortController.abort();
|
||||||
|
});
|
||||||
|
|
||||||
|
const params = req.body as ResponseTransTax;
|
||||||
|
|
||||||
|
withHandleError(
|
||||||
|
axios.get<ResponseTransTax>(URL_1C_TRANSTAX_DIRECT, {
|
||||||
|
auth: {
|
||||||
|
password: PASSWORD_1C_TRANSTAX,
|
||||||
|
username: USERNAME_1C_TRANSTAX,
|
||||||
|
},
|
||||||
|
params,
|
||||||
|
signal: abortController.signal,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(({ data }) => res.json(data))
|
||||||
|
.catch((error) => {
|
||||||
|
const _err = error as HttpError;
|
||||||
|
|
||||||
|
return res.json({ message: _err.message });
|
||||||
|
});
|
||||||
|
}
|
||||||
@ -1,67 +1,42 @@
|
|||||||
import { getUser } from '@/api/user/query';
|
|
||||||
import initializeApollo from '@/apollo/client';
|
import initializeApollo from '@/apollo/client';
|
||||||
import * as Calculation from '@/Components/Calculation';
|
import { Content } from '@/Components/Calculation';
|
||||||
import { Error } from '@/Components/Common/Error';
|
import { Error } from '@/Components/Common/Error';
|
||||||
import { Grid } from '@/Components/Layout/Page';
|
|
||||||
import Output from '@/Components/Output';
|
|
||||||
import { defaultRoles } from '@/config/users';
|
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
|
||||||
import * as hooks from '@/process/hooks';
|
import * as hooks from '@/process/hooks';
|
||||||
|
import { makeGetUserType } from '@/utils/user';
|
||||||
import { dehydrate, QueryClient } from '@tanstack/react-query';
|
import { dehydrate, QueryClient } from '@tanstack/react-query';
|
||||||
import Head from 'next/head';
|
|
||||||
|
|
||||||
export default function Home(props) {
|
export default function Page(props) {
|
||||||
|
if (props.statusCode !== 200) return <Error {...props} />;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Content
|
||||||
|
initHooks={() => {
|
||||||
hooks.useSentryScope();
|
hooks.useSentryScope();
|
||||||
hooks.useMainData();
|
hooks.useMainData();
|
||||||
hooks.useInsuranceData();
|
hooks.useInsuranceData();
|
||||||
hooks.useReactions();
|
hooks.useReactions();
|
||||||
|
}}
|
||||||
if (props.statusCode !== 200) return <Error {...props} />;
|
/>
|
||||||
|
|
||||||
return (
|
|
||||||
<Grid>
|
|
||||||
<Head>
|
|
||||||
<title>Лизинговый калькулятор - Эволюция</title>
|
|
||||||
</Head>
|
|
||||||
<Calculation.Form prune={['unlimited']} />
|
|
||||||
<Calculation.Settings />
|
|
||||||
<Output />
|
|
||||||
</Grid>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export const makeGetServerSideProps = ({ roles }) =>
|
|
||||||
/** @type {import('next').GetServerSideProps} */
|
/** @type {import('next').GetServerSideProps} */
|
||||||
(
|
export async function getServerSideProps({ req }) {
|
||||||
async function ({ req }) {
|
|
||||||
const { cookie = '' } = req.headers;
|
const { cookie = '' } = req.headers;
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
|
const apolloClient = initializeApollo(null, req.headers);
|
||||||
const user = await queryClient.fetchQuery(['user'], ({ signal }) =>
|
const getUserType = makeGetUserType({ apolloClient, queryClient });
|
||||||
getUser({
|
|
||||||
headers: {
|
|
||||||
cookie,
|
|
||||||
},
|
|
||||||
signal,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const apolloClient = initializeApollo();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {
|
const user = await getUserType({ cookie });
|
||||||
data: { systemuser },
|
|
||||||
} = await apolloClient.query({
|
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
query: CRMTypes.GetSystemUserDocument,
|
|
||||||
variables: {
|
|
||||||
domainname: user.domainName,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!systemuser?.roles?.some((x) => x?.name && roles.includes(x.name))) {
|
if (!user.default) {
|
||||||
return {
|
return {
|
||||||
props: { statusCode: 403 },
|
props: {
|
||||||
|
initialQueryState: dehydrate(queryClient),
|
||||||
|
statusCode: 403,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,17 +46,16 @@ export const makeGetServerSideProps = ({ roles }) =>
|
|||||||
initialApolloState: apolloClient.cache.extract(),
|
initialApolloState: apolloClient.cache.extract(),
|
||||||
initialQueryState: dehydrate(queryClient),
|
initialQueryState: dehydrate(queryClient),
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
|
user,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
error: JSON.stringify(error),
|
error: JSON.stringify(error),
|
||||||
|
initialQueryState: dehydrate(queryClient),
|
||||||
statusCode: 500,
|
statusCode: 500,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
export const getServerSideProps = makeGetServerSideProps({ roles: defaultRoles });
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user