pages: add unlimited
This commit is contained in:
parent
8268ba3c26
commit
91f69e79e5
3
.env
3
.env
@ -2,9 +2,6 @@
|
||||
USE_DEV_COLORS=
|
||||
BASE_PATH=
|
||||
|
||||
####### USERS ########
|
||||
USERS_SUPER=["akalinina","vchikalkin"]
|
||||
|
||||
####### URLS ########
|
||||
URL_GET_USER_DIRECT=
|
||||
URL_CRM_GRAPHQL_DIRECT=
|
||||
|
||||
12
apps/web/Components/Calculation/Form/Unlimited/config.ts
Normal file
12
apps/web/Components/Calculation/Form/Unlimited/config.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import type { FormTabRows } from '../../lib/render-rows';
|
||||
|
||||
export const id = 'unlimited';
|
||||
export const title = 'Без ограничений';
|
||||
|
||||
export const rows: FormTabRows = [
|
||||
[['cbxDisableChecks', 'selectUser']],
|
||||
[['selectTarif', 'tbxCreditRate', 'selectRate']],
|
||||
[['tbxMinPriceChange', 'tbxMaxPriceChange']],
|
||||
[['tbxImporterRewardPerc', 'tbxImporterRewardRub']],
|
||||
[['tbxBonusCoefficient', 'tbxComissionRub', 'tbxComissionPerc']],
|
||||
];
|
||||
12
apps/web/Components/Calculation/Form/Unlimited/index.jsx
Normal file
12
apps/web/Components/Calculation/Form/Unlimited/index.jsx
Normal file
@ -0,0 +1,12 @@
|
||||
import renderFormRows from '../../lib/render-rows';
|
||||
import { id, rows, title } from './config';
|
||||
|
||||
function Unlimited() {
|
||||
return renderFormRows(rows);
|
||||
}
|
||||
|
||||
export default {
|
||||
Component: Unlimited,
|
||||
id,
|
||||
title,
|
||||
};
|
||||
@ -5,12 +5,22 @@ import Leasing from './Leasing';
|
||||
import LeasingObject from './LeasingObject';
|
||||
import Payments from './Payments';
|
||||
import SupplierAgent from './SupplierAgent';
|
||||
import Unlimited from './Unlimited';
|
||||
import Background from '@/Components/Layout/Background';
|
||||
import { min } from '@/styles/mq';
|
||||
import styled from 'styled-components';
|
||||
import Tabs from 'ui/elements/layout/Tabs';
|
||||
|
||||
const formTabs = [Leasing, Payments, LeasingObject, SupplierAgent, Insurance, AddProduct, CreateKP];
|
||||
const formTabs = [
|
||||
Leasing,
|
||||
Payments,
|
||||
LeasingObject,
|
||||
SupplierAgent,
|
||||
Insurance,
|
||||
AddProduct,
|
||||
CreateKP,
|
||||
Unlimited,
|
||||
];
|
||||
|
||||
const Wrapper = styled(Background)`
|
||||
padding: 4px 6px;
|
||||
@ -32,17 +42,19 @@ const ComponentWrapper = styled.div`
|
||||
}
|
||||
`;
|
||||
|
||||
function Form() {
|
||||
function Form({ prune }) {
|
||||
return (
|
||||
<Wrapper>
|
||||
<Tabs type="card" tabBarGutter="5px">
|
||||
{formTabs.map(({ id, title, Component }) => (
|
||||
<Tabs.TabPane tab={title} key={id}>
|
||||
<ComponentWrapper>
|
||||
<Component />
|
||||
</ComponentWrapper>
|
||||
</Tabs.TabPane>
|
||||
))}
|
||||
{formTabs
|
||||
.filter((tab) => !prune?.includes(tab.id))
|
||||
.map(({ id, title, Component }) => (
|
||||
<Tabs.TabPane tab={title} key={id}>
|
||||
<ComponentWrapper>
|
||||
<Component />
|
||||
</ComponentWrapper>
|
||||
</Tabs.TabPane>
|
||||
))}
|
||||
</Tabs>
|
||||
</Wrapper>
|
||||
);
|
||||
|
||||
@ -131,6 +131,7 @@ const components = wrapComponentsMap({
|
||||
tbxBonusCoefficient: e.InputNumber,
|
||||
selectLeasingWithoutKasko: e.Select,
|
||||
tbxVIN: e.Input,
|
||||
selectUser: e.Select,
|
||||
|
||||
/** Readonly Elements */
|
||||
labelLeaseObjectRisk: e.Text,
|
||||
|
||||
@ -444,6 +444,10 @@ const props: Partial<ElementsProps> = {
|
||||
direction: 'vertical',
|
||||
},
|
||||
},
|
||||
selectUser: {
|
||||
showSearch: true,
|
||||
optionFilterProp: 'label',
|
||||
},
|
||||
};
|
||||
|
||||
export default props;
|
||||
|
||||
@ -125,6 +125,7 @@ const titles: Record<ActionElements | ValuesElements, string> = {
|
||||
tbxBonusCoefficient: 'Коэффициент снижения бонуса',
|
||||
selectLeasingWithoutKasko: 'Лизинг без КАСКО',
|
||||
tbxVIN: 'VIN',
|
||||
selectUser: 'Пользователь',
|
||||
|
||||
/** Link Elements */
|
||||
linkDownloadKp: '',
|
||||
|
||||
@ -162,6 +162,7 @@ const types = wrapElementsTypes({
|
||||
tbxBonusCoefficient: t.Value,
|
||||
selectLeasingWithoutKasko: t.Options,
|
||||
tbxVIN: t.Value,
|
||||
selectUser: t.Options,
|
||||
|
||||
labelLeaseObjectRisk: t.Readonly,
|
||||
tbxInsKaskoPriceLeasePeriod: t.Readonly,
|
||||
|
||||
@ -128,6 +128,7 @@ const elementsToValues = wrapElementsMap({
|
||||
tbxMinPriceChange: 'minPriceChange',
|
||||
tbxBonusCoefficient: 'bonusCoefficient',
|
||||
tbxVIN: 'vin',
|
||||
selectUser: 'user',
|
||||
|
||||
/** Readonly Elements */
|
||||
labelLeaseObjectRisk: 'leaseObjectRiskName',
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
/* eslint-disable react/forbid-component-props */
|
||||
import styles from './Logo.module.css';
|
||||
import { useStore } from '@/stores/hooks';
|
||||
import getColors from '@/styles/colors';
|
||||
import { min } from '@/styles/mq';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import Image from 'next/image';
|
||||
import logo from 'public/assets/images/logo-primary.svg';
|
||||
import styled from 'styled-components';
|
||||
import { Flex } from 'ui';
|
||||
import { Flex, Tag } from 'ui';
|
||||
|
||||
const ImageWrapper = styled.div`
|
||||
width: 100px;
|
||||
@ -26,13 +29,41 @@ const LogoText = styled.h3`
|
||||
}
|
||||
`;
|
||||
|
||||
const TagWrapper = styled.div`
|
||||
font-family: 'Montserrat';
|
||||
font-weight: 500;
|
||||
* {
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
`;
|
||||
|
||||
const { COLOR_PRIMARY } = getColors();
|
||||
|
||||
const UnlimitedTag = observer(() => {
|
||||
const { $process } = useStore();
|
||||
if ($process.has('Unlimited')) {
|
||||
return (
|
||||
<TagWrapper>
|
||||
<Tag color={COLOR_PRIMARY} style={{ margin: '0 5px' }}>
|
||||
без ограничений
|
||||
</Tag>
|
||||
</TagWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
function Logo() {
|
||||
return (
|
||||
<Flex flexDirection="column" alignItems="flex-start" justifyContent="space-between">
|
||||
<ImageWrapper>
|
||||
<Image priority className={styles.logo} alt="logo" src={logo} layout="responsive" />
|
||||
</ImageWrapper>
|
||||
<LogoText>Лизинговый Калькулятор</LogoText>
|
||||
<Flex justifyContent="space-between" alignItems="center">
|
||||
<LogoText>Лизинговый Калькулятор</LogoText>
|
||||
<UnlimitedTag />
|
||||
</Flex>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
|
||||
27
apps/web/Components/Layout/Page.jsx
Normal file
27
apps/web/Components/Layout/Page.jsx
Normal file
@ -0,0 +1,27 @@
|
||||
import { min } from '@/styles/mq';
|
||||
import styled from 'styled-components';
|
||||
import { Box } from 'ui/grid';
|
||||
|
||||
export const Grid = styled(Box)`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
|
||||
${min('laptop')} {
|
||||
display: grid;
|
||||
align-items: flex-start;
|
||||
grid-template-columns: 2fr 1fr;
|
||||
}
|
||||
|
||||
${min('laptop-hd')} {
|
||||
grid-template-columns: 2fr 1fr 1.5fr;
|
||||
}
|
||||
|
||||
${min('desktop')} {
|
||||
margin: 8px 5%;
|
||||
}
|
||||
|
||||
${min('desktop-xl')} {
|
||||
margin: 8px 10%;
|
||||
}
|
||||
`;
|
||||
@ -138,8 +138,13 @@ const AdditionalDataSchema = z.object({
|
||||
|
||||
export type AdditionalData = z.infer<typeof AdditionalDataSchema>;
|
||||
|
||||
const flagsSchema = z.object({
|
||||
DISABLE_CHECKS_RESULTS: z.boolean(),
|
||||
});
|
||||
|
||||
export const RequestCalculateSchema = z.object({
|
||||
additionalData: AdditionalDataSchema,
|
||||
flags: flagsSchema.optional(),
|
||||
preparedPayments: PreparedPaymentSchema,
|
||||
preparedValues: PreparedValuesSchema,
|
||||
});
|
||||
|
||||
@ -1,13 +1,8 @@
|
||||
import type { User } from './types';
|
||||
import { publicRuntimeConfigSchema } from '@/config/schema/runtime-config';
|
||||
import getConfig from 'next/config';
|
||||
|
||||
const { publicRuntimeConfig } = getConfig();
|
||||
const { USERS_SUPER } = publicRuntimeConfigSchema.parse(publicRuntimeConfig);
|
||||
import { usersSuper } from '@/config/users';
|
||||
|
||||
export function love(user: User) {
|
||||
const superUsers: string[] = JSON.parse(USERS_SUPER);
|
||||
if (superUsers?.includes(user.username)) user.displayName += '🧡';
|
||||
if (usersSuper?.includes(user.username)) user.displayName += '🧡';
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
@ -493,6 +493,7 @@ const defaultOptions: CalculationOptions = {
|
||||
tbxBonusCoefficient: [],
|
||||
selectLeasingWithoutKasko: [],
|
||||
tbxVIN: [],
|
||||
selectUser: [],
|
||||
};
|
||||
|
||||
export default defaultOptions;
|
||||
|
||||
@ -86,6 +86,7 @@ const defaultStatuses: CalculationStatuses = {
|
||||
selectTelematic: 'Default',
|
||||
selectTownRegistration: 'Default',
|
||||
selectTracker: 'Default',
|
||||
selectUser: 'Default',
|
||||
tbxAddEquipmentPrice: 'Default',
|
||||
tbxBonusCoefficient: 'Default',
|
||||
tbxCalcBrokerRewardSum: 'Disabled',
|
||||
|
||||
@ -137,6 +137,7 @@ const defaultValues: CalculationValues = {
|
||||
vehicleTaxInYear: 0,
|
||||
withTrailer: false,
|
||||
vin: null,
|
||||
user: null,
|
||||
};
|
||||
|
||||
export default defaultValues;
|
||||
|
||||
@ -10,7 +10,6 @@ const envSchema = z.object({
|
||||
URL_CRM_GRAPHQL_DIRECT: z.string(),
|
||||
URL_GET_USER_DIRECT: z.string(),
|
||||
USE_DEV_COLORS: z.unknown().optional().transform(Boolean),
|
||||
USERS_SUPER: z.string().optional().default(''),
|
||||
});
|
||||
|
||||
module.exports = envSchema;
|
||||
|
||||
@ -3,7 +3,6 @@ const envSchema = require('./env');
|
||||
const publicRuntimeConfigSchema = envSchema.pick({
|
||||
BASE_PATH: true,
|
||||
USE_DEV_COLORS: true,
|
||||
USERS_SUPER: true,
|
||||
});
|
||||
|
||||
const serverRuntimeConfigSchema = envSchema.pick({
|
||||
|
||||
@ -123,6 +123,7 @@ const ValuesSchema = z.object({
|
||||
vehicleTaxInYear: z.number(),
|
||||
withTrailer: z.boolean(),
|
||||
vin: z.string().nullable(),
|
||||
user: z.string().nullable(),
|
||||
|
||||
/**
|
||||
* Link Values
|
||||
|
||||
3
apps/web/config/users.js
Normal file
3
apps/web/config/users.js
Normal file
@ -0,0 +1,3 @@
|
||||
export const unlimitedRoles = ['Калькулятор без ограничений'];
|
||||
export const defaultRoles = ['МПЛ'];
|
||||
export const usersSuper = ['akalinina', 'vchikalkin'];
|
||||
@ -639,3 +639,12 @@ query GetInsuranceCompanies {
|
||||
label: name
|
||||
}
|
||||
}
|
||||
|
||||
query GetRoles($roleName: String) {
|
||||
roles(name: $roleName) {
|
||||
systemusers {
|
||||
label: fullname
|
||||
value: domainname
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -470,6 +470,13 @@ export type GetInsuranceCompaniesQueryVariables = Exact<{ [key: string]: never;
|
||||
|
||||
export type GetInsuranceCompaniesQuery = { __typename?: 'Query', accounts: Array<{ __typename?: 'account', evo_type_ins_policy: Array<number> | null, evo_evokasko_access: boolean | null, evo_inn: string | null, value: string | null, label: string | null } | null> | null };
|
||||
|
||||
export type GetRolesQueryVariables = Exact<{
|
||||
roleName: InputMaybe<Scalars['String']>;
|
||||
}>;
|
||||
|
||||
|
||||
export type GetRolesQuery = { __typename?: 'Query', roles: Array<{ __typename?: 'role', systemusers: Array<{ __typename?: 'systemuser', label: string | null, value: string | null } | null> | null } | null> | null };
|
||||
|
||||
export type GetQuoteAddProductDataQueryVariables = Exact<{
|
||||
quoteId: Scalars['Uuid'];
|
||||
}>;
|
||||
@ -642,6 +649,7 @@ export const GetInsNsibTypesDocument = {"kind":"Document","definitions":[{"kind"
|
||||
export const GetLeasingWithoutKaskoTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeasingWithoutKaskoTypes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000007"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoreAddProductTypesFields"}},{"kind":"Field","name":{"kind":"Name","value":"evo_product_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_visible_calc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoreAddProductTypesFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"evo_addproduct_type"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_graph_price"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]} as unknown as DocumentNode<GetLeasingWithoutKaskoTypesQuery, GetLeasingWithoutKaskoTypesQueryVariables>;
|
||||
export const GetInsuranceCompanyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetInsuranceCompany"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"account"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_osago_with_kasko"}}]}}]}}]} as unknown as DocumentNode<GetInsuranceCompanyQuery, GetInsuranceCompanyQueryVariables>;
|
||||
export const GetInsuranceCompaniesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetInsuranceCompanies"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_account_type"},"value":{"kind":"ListValue","values":[{"kind":"IntValue","value":"100000002"}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_type_ins_policy"}},{"kind":"Field","name":{"kind":"Name","value":"evo_evokasko_access"}},{"kind":"Field","name":{"kind":"Name","value":"evo_inn"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}}]}}]}}]} as unknown as DocumentNode<GetInsuranceCompaniesQuery, GetInsuranceCompaniesQueryVariables>;
|
||||
export const GetRolesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRoles"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"roleName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"roles"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"name"},"value":{"kind":"Variable","name":{"kind":"Name","value":"roleName"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"systemusers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"fullname"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"domainname"}}]}}]}}]}}]} as unknown as DocumentNode<GetRolesQuery, GetRolesQueryVariables>;
|
||||
export const GetQuoteAddProductDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteAddProductData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_product_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]}}]}}]} as unknown as DocumentNode<GetQuoteAddProductDataQuery, GetQuoteAddProductDataQueryVariables>;
|
||||
export const GetQuoteBonusDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteBonusData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_sale_bonus"}}]}}]}}]} as unknown as DocumentNode<GetQuoteBonusDataQuery, GetQuoteBonusDataQueryVariables>;
|
||||
export const GetQuoteConfiguratorDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteConfiguratorData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_client_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_msfo_irr"}}]}}]}}]} as unknown as DocumentNode<GetQuoteConfiguratorDataQuery, GetQuoteConfiguratorDataQueryVariables>;
|
||||
|
||||
@ -36,7 +36,7 @@ export default class MyDocument extends Document {
|
||||
<Head>
|
||||
<meta charSet="utf-8" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta name="description" content="Лизинговый калькулятор Эволюция" />
|
||||
<meta name="description" content="Лизинговый калькулятор - Эволюция" />
|
||||
{metaFavicon}
|
||||
</Head>
|
||||
<body>
|
||||
|
||||
@ -2,41 +2,16 @@ import { getUser } from '@/api/user/query';
|
||||
import initializeApollo from '@/apollo/client';
|
||||
import * as Calculation from '@/Components/Calculation';
|
||||
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 { useInsuranceData, useMainData, useReactions } from '@/process/hooks';
|
||||
import { getInitialData } from '@/process/hooks/init';
|
||||
import { min } from '@/styles/mq';
|
||||
import { dehydrate, QueryClient } from '@tanstack/react-query';
|
||||
import Head from 'next/head';
|
||||
import styled from 'styled-components';
|
||||
import { Box } from 'ui/grid';
|
||||
|
||||
const Grid = styled(Box)`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
|
||||
${min('laptop')} {
|
||||
display: grid;
|
||||
align-items: flex-start;
|
||||
grid-template-columns: 2fr 1fr;
|
||||
}
|
||||
|
||||
${min('laptop-hd')} {
|
||||
grid-template-columns: 2fr 1fr 1.5fr;
|
||||
}
|
||||
|
||||
${min('desktop')} {
|
||||
margin: 8px 5%;
|
||||
}
|
||||
|
||||
${min('desktop-xl')} {
|
||||
margin: 8px 10%;
|
||||
}
|
||||
`;
|
||||
|
||||
function Home(props) {
|
||||
export default function Home(props) {
|
||||
useMainData();
|
||||
useInsuranceData();
|
||||
useReactions();
|
||||
@ -48,65 +23,69 @@ function Home(props) {
|
||||
<Head>
|
||||
<title>Лизинговый калькулятор - Эволюция</title>
|
||||
</Head>
|
||||
<Calculation.Form />
|
||||
<Calculation.Form prune={['unlimited']} />
|
||||
<Calculation.Settings />
|
||||
<Output />
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
/** @type {import('next').GetServerSideProps} */
|
||||
export const getServerSideProps = async ({ req }) => {
|
||||
const { cookie = '' } = req.headers;
|
||||
export const makeGetServerSideProps = ({ roles }) =>
|
||||
/** @type {import('next').GetServerSideProps} */
|
||||
(
|
||||
async function ({ req }) {
|
||||
const { cookie = '' } = req.headers;
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
const user = await queryClient.fetchQuery(['user'], ({ signal }) =>
|
||||
getUser({
|
||||
headers: {
|
||||
cookie,
|
||||
},
|
||||
signal,
|
||||
})
|
||||
const user = await queryClient.fetchQuery(['user'], ({ signal }) =>
|
||||
getUser({
|
||||
headers: {
|
||||
cookie,
|
||||
},
|
||||
signal,
|
||||
})
|
||||
);
|
||||
|
||||
const apolloClient = initializeApollo();
|
||||
|
||||
try {
|
||||
const {
|
||||
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))) {
|
||||
return {
|
||||
props: { statusCode: 403 },
|
||||
};
|
||||
}
|
||||
const { values, options } = await getInitialData(apolloClient, user);
|
||||
|
||||
return {
|
||||
props: {
|
||||
calculation: {
|
||||
options,
|
||||
values,
|
||||
},
|
||||
initialApolloState: apolloClient.cache.extract(),
|
||||
initialQueryState: dehydrate(queryClient),
|
||||
statusCode: 200,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
props: {
|
||||
error: JSON.stringify(error),
|
||||
statusCode: 500,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const apolloClient = initializeApollo();
|
||||
|
||||
try {
|
||||
const {
|
||||
data: { systemuser },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetSystemUserDocument,
|
||||
variables: {
|
||||
domainname: user.domainName,
|
||||
},
|
||||
});
|
||||
|
||||
if (!systemuser.roles.some((x) => x.name === 'МПЛ')) {
|
||||
return {
|
||||
props: { statusCode: 403 },
|
||||
};
|
||||
}
|
||||
const { values, options } = await getInitialData(apolloClient, user);
|
||||
|
||||
return {
|
||||
props: {
|
||||
calculation: {
|
||||
options,
|
||||
values,
|
||||
},
|
||||
initialApolloState: apolloClient.cache.extract(),
|
||||
initialQueryState: dehydrate(queryClient),
|
||||
statusCode: 200,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
props: {
|
||||
error: JSON.stringify(error),
|
||||
statusCode: 500,
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export default Home;
|
||||
export const getServerSideProps = makeGetServerSideProps({ roles: defaultRoles });
|
||||
|
||||
37
apps/web/pages/unlimited.jsx
Normal file
37
apps/web/pages/unlimited.jsx
Normal file
@ -0,0 +1,37 @@
|
||||
import { makeGetServerSideProps } from '.';
|
||||
import * as Calculation from '@/Components/Calculation';
|
||||
import { Error } from '@/Components/Common/Error';
|
||||
import { Grid } from '@/Components/Layout/Page';
|
||||
import Output from '@/Components/Output';
|
||||
import { unlimitedRoles } from '@/config/users';
|
||||
import { useGetUsers, useInsuranceData, useMainData, useReactions } from '@/process/hooks';
|
||||
import { useStore } from '@/stores/hooks';
|
||||
import Head from 'next/head';
|
||||
|
||||
export default function Unlimited(props) {
|
||||
const store = useStore();
|
||||
store.$process.add('Unlimited');
|
||||
|
||||
useMainData();
|
||||
useGetUsers();
|
||||
useInsuranceData();
|
||||
useReactions();
|
||||
|
||||
if (props.statusCode !== 200) return <Error {...props} />;
|
||||
|
||||
return (
|
||||
<Grid>
|
||||
<Head>
|
||||
<title>Лизинговый калькулятор без ограничений - Эволюция</title>
|
||||
<meta name="description" content="Лизинговый калькулятор без ограничений - Эволюция" />
|
||||
</Head>
|
||||
<Calculation.Form />
|
||||
<Calculation.Settings />
|
||||
<Output />
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
|
||||
export const getServerSideProps = makeGetServerSideProps({
|
||||
roles: unlimitedRoles,
|
||||
});
|
||||
@ -1,3 +1,4 @@
|
||||
export { default as filters } from './filters';
|
||||
export { default as unlimited } from './unlimited';
|
||||
export { default as validation } from './validation';
|
||||
export { default as values } from './values';
|
||||
|
||||
35
apps/web/process/configurator/reactions/unlimited.ts
Normal file
35
apps/web/process/configurator/reactions/unlimited.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import { reaction } from 'mobx';
|
||||
import { makeDisposable, normalizeOptions } from 'tools';
|
||||
|
||||
export default function unlimitedReactions({ store, apolloClient }: ProcessContext) {
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
makeDisposable(
|
||||
() =>
|
||||
reaction(
|
||||
() => $calculation.element('selectUser').getValue(),
|
||||
async (domainname) => {
|
||||
const {
|
||||
data: { leads },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetLeadsDocument,
|
||||
variables: { domainname },
|
||||
});
|
||||
|
||||
$calculation.element('selectLead').setOptions(normalizeOptions(leads));
|
||||
|
||||
const {
|
||||
data: { opportunities },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetOpportunitiesDocument,
|
||||
variables: { domainname },
|
||||
});
|
||||
|
||||
$calculation.element('selectOpportunity').setOptions(normalizeOptions(opportunities));
|
||||
}
|
||||
),
|
||||
() => !$process.has('Unlimited')
|
||||
);
|
||||
}
|
||||
37
apps/web/process/hooks/init/get-users.js
Normal file
37
apps/web/process/hooks/init/get-users.js
Normal file
@ -0,0 +1,37 @@
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { useStore } from '@/stores/hooks';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { useEffect } from 'react';
|
||||
import { normalizeOptions } from 'tools';
|
||||
|
||||
/**
|
||||
* @param {import('@apollo/client').ApolloClient} apolloClient
|
||||
* @param {*} onCompleted
|
||||
*/
|
||||
export function getUsers({ query }, onCompleted) {
|
||||
query({
|
||||
query: CRMTypes.GetRolesDocument,
|
||||
variables: { roleName: 'МПЛ' },
|
||||
}).then(({ data }) => {
|
||||
const users = data.roles?.flatMap((x) => x?.systemusers);
|
||||
onCompleted({
|
||||
selectUser: users,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function useGetUsers() {
|
||||
const { $calculation } = useStore();
|
||||
const apolloClient = useApolloClient();
|
||||
|
||||
function handleOnCompleted(options) {
|
||||
Object.keys(options).forEach((elementName) => {
|
||||
const elementOptions = options[elementName];
|
||||
$calculation.element(elementName).setOptions(normalizeOptions(elementOptions));
|
||||
});
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getUsers(apolloClient, handleOnCompleted);
|
||||
}, []);
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
export * from './get-initial-data';
|
||||
export * from './get-insurance-data';
|
||||
export * from './get-main-data';
|
||||
export * from './get-users';
|
||||
|
||||
@ -9,7 +9,7 @@ export type ProcessContext = {
|
||||
queryClient: QueryClient;
|
||||
store: RootStore;
|
||||
trpcClient: TRPCPureClient;
|
||||
user: User | undefined;
|
||||
user: Pick<User, 'domainName'> | undefined;
|
||||
};
|
||||
|
||||
export type Process = {
|
||||
|
||||
@ -1,19 +1,33 @@
|
||||
import { t } from './trpc';
|
||||
import initializeApollo from '@/apollo/client';
|
||||
import { unlimitedRoles } from '@/config/users';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { TRPCError } from '@trpc/server';
|
||||
|
||||
/**
|
||||
* @see https://trpc.io/docs/v10/middlewares
|
||||
*/
|
||||
export const userMiddleware = t.middleware(({ ctx, next }) => {
|
||||
export const userMiddleware = t.middleware(async ({ ctx, next }) => {
|
||||
if (process.env.NODE_ENV !== 'development' && !ctx.user) {
|
||||
throw new TRPCError({
|
||||
code: 'UNAUTHORIZED',
|
||||
});
|
||||
}
|
||||
|
||||
const apolloClient = initializeApollo();
|
||||
|
||||
const {
|
||||
data: { systemuser },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetSystemUserDocument,
|
||||
variables: {
|
||||
domainname: ctx.user.domainName,
|
||||
},
|
||||
});
|
||||
|
||||
return next({
|
||||
ctx: {
|
||||
isAdmin: false,
|
||||
unlimited: systemuser?.roles?.some((x) => x?.name && unlimitedRoles.includes(x.name)),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@ -4,6 +4,7 @@ import { transformCalculateResults } from './lib/transform';
|
||||
import { validate } from './lib/validation';
|
||||
import { CalculateInputSchema, CalculateOutputSchema } from './types';
|
||||
import { calculate } from '@/api/core/query';
|
||||
import type { User } from '@/api/user/types';
|
||||
import initializeApollo from '@/apollo/client';
|
||||
import { protectedProcedure } from '@/server/procedure';
|
||||
import { QueryClient } from '@tanstack/react-query';
|
||||
@ -16,30 +17,37 @@ export const calculateRouter = router({
|
||||
const apolloClient = initializeApollo();
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
const validationResult = await validate({
|
||||
context: {
|
||||
apolloClient,
|
||||
queryClient,
|
||||
user: ctx.user,
|
||||
},
|
||||
input,
|
||||
});
|
||||
if (ctx.unlimited === false) {
|
||||
const validationResult = await validate({
|
||||
context: {
|
||||
apolloClient,
|
||||
queryClient,
|
||||
user: ctx.user,
|
||||
},
|
||||
input,
|
||||
});
|
||||
|
||||
if (validationResult.success === false) {
|
||||
return {
|
||||
error: validationResult.error,
|
||||
success: false,
|
||||
};
|
||||
if (validationResult.success === false) {
|
||||
return {
|
||||
error: validationResult.error,
|
||||
success: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
let user: Pick<User, 'domainName'> = { domainName: ctx.user.domainName };
|
||||
if (ctx.unlimited && input.values.user) {
|
||||
user = { domainName: input.values.user };
|
||||
}
|
||||
|
||||
const requestData = await createRequestData({
|
||||
context: {
|
||||
apolloClient,
|
||||
queryClient,
|
||||
user: ctx.user,
|
||||
...ctx,
|
||||
user,
|
||||
},
|
||||
input,
|
||||
user: ctx.user,
|
||||
});
|
||||
|
||||
const calculateResult = await calculate(requestData);
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
/* eslint-disable sonarjs/cognitive-complexity */
|
||||
import type { CalculateInput, Context } from '../types';
|
||||
import type * as CoreTypes from '@/api/core/types';
|
||||
import type { User } from '@/api/user/types';
|
||||
import { ESN, NSIB_MAX, VAT } from '@/constants/values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import helper from '@/process/calculate/lib/helper';
|
||||
@ -13,9 +12,8 @@ import { max, sum } from 'radash';
|
||||
dayjs.extend(utc);
|
||||
|
||||
type Input = {
|
||||
context: Context;
|
||||
context: Context & { unlimited?: boolean };
|
||||
input: CalculateInput;
|
||||
user: User;
|
||||
};
|
||||
|
||||
type PreparedValuesGetters = {
|
||||
@ -29,9 +27,8 @@ type AdditionalDataGetters = {
|
||||
export async function createRequestData({
|
||||
context,
|
||||
input,
|
||||
user,
|
||||
}: Input): Promise<CoreTypes.RequestCalculate> {
|
||||
const { apolloClient } = context;
|
||||
const { apolloClient, user, unlimited } = context;
|
||||
const { values, insurance, payments } = input;
|
||||
|
||||
const { RUB } = createCurrencyUtility({ apolloClient });
|
||||
@ -1232,6 +1229,9 @@ export async function createRequestData({
|
||||
|
||||
return {
|
||||
additionalData,
|
||||
flags: {
|
||||
DISABLE_CHECKS_RESULTS: unlimited,
|
||||
},
|
||||
preparedPayments,
|
||||
preparedValues,
|
||||
};
|
||||
|
||||
@ -13,6 +13,7 @@ import {
|
||||
} from './types';
|
||||
import { calculate } from '@/api/core/query';
|
||||
import { createKP } from '@/api/crm/query';
|
||||
import type { User } from '@/api/user/types';
|
||||
import initializeApollo from '@/apollo/client';
|
||||
import defaultValues from '@/config/default-values';
|
||||
import * as insuranceTable from '@/config/tables/insurance-table';
|
||||
@ -88,30 +89,37 @@ export const quoteRouter = router({
|
||||
const apolloClient = initializeApollo();
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
const validationResult = await validate({
|
||||
context: {
|
||||
apolloClient,
|
||||
queryClient,
|
||||
user: ctx.user,
|
||||
},
|
||||
input,
|
||||
});
|
||||
if (ctx.unlimited === false) {
|
||||
const validationResult = await validate({
|
||||
context: {
|
||||
apolloClient,
|
||||
queryClient,
|
||||
user: ctx.user,
|
||||
},
|
||||
input,
|
||||
});
|
||||
|
||||
if (validationResult.success === false) {
|
||||
return {
|
||||
error: validationResult.error,
|
||||
success: false,
|
||||
};
|
||||
if (validationResult.success === false) {
|
||||
return {
|
||||
error: validationResult.error,
|
||||
success: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
let user: Pick<User, 'domainName'> = { domainName: ctx.user.domainName };
|
||||
if (ctx.unlimited && input.values.user) {
|
||||
user = { domainName: input.values.user };
|
||||
}
|
||||
|
||||
const requestData = await createRequestData({
|
||||
context: {
|
||||
apolloClient,
|
||||
queryClient,
|
||||
user: ctx.user,
|
||||
...ctx,
|
||||
user,
|
||||
},
|
||||
input,
|
||||
user: ctx.user,
|
||||
});
|
||||
|
||||
const calculateResult = await calculate(requestData);
|
||||
|
||||
@ -13,5 +13,6 @@ export { default as Segmented } from './Segmented';
|
||||
export { default as Select } from './Select';
|
||||
export { default as Switch } from './Switch';
|
||||
export { default as Table } from './Table';
|
||||
export * from './tag';
|
||||
export { default as Text } from './Text';
|
||||
export { default as Tooltip } from './Tooltip';
|
||||
|
||||
1
packages/ui/elements/tag.js
Normal file
1
packages/ui/elements/tag.js
Normal file
@ -0,0 +1 @@
|
||||
export { Tag } from 'antd';
|
||||
Loading…
x
Reference in New Issue
Block a user