code-style: prettier files
This commit is contained in:
parent
840eea78fd
commit
c476f42e45
@ -1,5 +1,4 @@
|
||||
import { Values, ValuesTypes } from 'stores/calculation/values/types';
|
||||
import { Elements } from '../types/elements';
|
||||
|
||||
function wrapElementsMap<T extends Record<string, Values>>(arg: T) {
|
||||
return arg;
|
||||
@ -160,3 +159,5 @@ export type ElementsTypes = {
|
||||
export function getValueName(elementName: Elements) {
|
||||
return elementsToValues[elementName];
|
||||
}
|
||||
|
||||
export type Elements = keyof ElementsValues;
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
import { ElementsValues } from '../config/map';
|
||||
|
||||
export type Elements = keyof ElementsValues;
|
||||
@ -25,11 +25,7 @@ const LogoText = styled.h3`
|
||||
|
||||
function Logo() {
|
||||
return (
|
||||
<Flex
|
||||
flexDirection="column"
|
||||
alignItems="flex-start"
|
||||
justifyContent="space-between"
|
||||
>
|
||||
<Flex flexDirection="column" alignItems="flex-start" justifyContent="space-between">
|
||||
<ImageWrapper>
|
||||
<Image alt="logo" src={logo} layout="responsive" objectFit="contain" />
|
||||
</ImageWrapper>
|
||||
|
||||
@ -6,7 +6,7 @@ export default Spin;
|
||||
const loadingOutlined = (
|
||||
<LoadingOutlined
|
||||
style={{
|
||||
fontSize: 24
|
||||
fontSize: 24,
|
||||
}}
|
||||
spin
|
||||
/>
|
||||
|
||||
@ -16,5 +16,5 @@ export function max(breakpoint: keyof typeof screens) {
|
||||
}
|
||||
|
||||
export const mediaQuery = {
|
||||
breakpoints: Object.values(screens).map(value => value + threshold + 'px'),
|
||||
breakpoints: Object.values(screens).map((value) => `${value + threshold}px`),
|
||||
};
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import { mediaQuery } from './mq';
|
||||
|
||||
const theme = { ...mediaQuery };
|
||||
const theme = {
|
||||
...mediaQuery,
|
||||
};
|
||||
|
||||
export default theme;
|
||||
|
||||
@ -1,12 +1,5 @@
|
||||
import { Result } from 'antd';
|
||||
|
||||
export default function NotFound(props) {
|
||||
return (
|
||||
<Result
|
||||
status="500"
|
||||
title=""
|
||||
subTitle="Ой! Что-то сломалось."
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
return <Result status="500" title="" subTitle="Ой! Что-то сломалось." {...props} />;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import { useApollo } from 'apollo/hooks';
|
||||
import Layout from 'Components/Layout';
|
||||
import type { AppProps } from 'next/app';
|
||||
import Head from 'next/head';
|
||||
import { StoreProvider } from 'stores/Provider';
|
||||
import StoreProvider from 'stores/Provider';
|
||||
import { ThemeProvider } from 'styled-components';
|
||||
import { GlobalStyle } from 'UIKit/colors';
|
||||
import theme from 'UIKit/theme';
|
||||
|
||||
@ -32,16 +32,8 @@ export default class MyDocument extends Document {
|
||||
<Head>
|
||||
<meta charSet="utf-8" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link
|
||||
rel="preconnect"
|
||||
href="https://fonts.gstatic.com"
|
||||
crossOrigin="true"
|
||||
/>
|
||||
<link
|
||||
rel="preconnect"
|
||||
href="https://cdnjs.cloudflare.com"
|
||||
crossOrigin="true"
|
||||
/>
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="true" />
|
||||
<link rel="preconnect" href="https://cdnjs.cloudflare.com" crossOrigin="true" />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap"
|
||||
rel="stylesheet"
|
||||
@ -54,21 +46,13 @@ export default class MyDocument extends Document {
|
||||
|
||||
<link
|
||||
rel="icon"
|
||||
href={
|
||||
process.env.NODE_ENV === 'production'
|
||||
? 'favicon.prod.ico'
|
||||
: 'favicon.ico'
|
||||
}
|
||||
href={process.env.NODE_ENV === 'production' ? 'favicon.prod.ico' : 'favicon.ico'}
|
||||
crossOrigin="use-credentials"
|
||||
/>
|
||||
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta name="description" content="Лизинговый калькулятор Эволюция" />
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
href="logo-100.png"
|
||||
crossOrigin="use-credentials"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="logo-100.png" crossOrigin="use-credentials" />
|
||||
</Head>
|
||||
<body>
|
||||
<Main />
|
||||
|
||||
@ -9,9 +9,7 @@ function Home() {
|
||||
return <div>Home</div>;
|
||||
}
|
||||
|
||||
export const getServerSideProps: GetServerSideProps<PageProps> = async (
|
||||
ctx
|
||||
) => {
|
||||
export const getServerSideProps: GetServerSideProps<PageProps> = async (ctx) => {
|
||||
const user = await fetchUser({
|
||||
headers: ctx?.req?.headers?.cookie
|
||||
? {
|
||||
|
||||
@ -10,7 +10,7 @@ function love(user: User) {
|
||||
export async function fetchUser(config: AxiosRequestConfig) {
|
||||
const user = await axios
|
||||
.get<User>(process.env.URL_GET_USER || '', config)
|
||||
.then(res => love(res.data));
|
||||
.then((res) => love(res.data));
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
/* eslint-disable react/prop-types */
|
||||
import { initializeStore, StoreContext } from '.';
|
||||
|
||||
export function StoreProvider({ children, ...initialData }) {
|
||||
export default function StoreProvider({ children, ...initialData }) {
|
||||
const store = initializeStore(initialData);
|
||||
return (
|
||||
<StoreContext.Provider value={store}>{children}</StoreContext.Provider>
|
||||
);
|
||||
return <StoreContext.Provider value={store}>{children}</StoreContext.Provider>;
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
import { RootStore } from 'stores/root';
|
||||
import { OptionsStore } from './options';
|
||||
import { StatusStore } from './statuses';
|
||||
import { ValuesStore } from './values';
|
||||
/* eslint-disable import/no-cycle */
|
||||
import RootStore from 'stores/root';
|
||||
import OptionsStore from './options';
|
||||
import StatusStore from './statuses';
|
||||
import ValuesStore from './values';
|
||||
|
||||
export class CalculationStore {
|
||||
export default class CalculationStore {
|
||||
$values: ValuesStore;
|
||||
$status: StatusStore;
|
||||
$options: OptionsStore;
|
||||
|
||||
@ -1,15 +1,17 @@
|
||||
import type { Elements } from 'Components/Calculation/types/elements';
|
||||
/* eslint-disable function-paren-newline */
|
||||
/* eslint-disable implicit-arrow-linebreak */
|
||||
/* eslint-disable no-confusing-arrow */
|
||||
/* eslint-disable object-curly-newline */
|
||||
/* eslint-disable import/no-cycle */
|
||||
import type { Elements } from 'Components/Calculation/config/map';
|
||||
import { mergeWith } from 'lodash';
|
||||
import { makeAutoObservable } from 'mobx';
|
||||
import { RootStore } from 'stores/root';
|
||||
import RootStore from 'stores/root';
|
||||
import { CalculationOptions, Filter, Options, OptionsFilters } from './types';
|
||||
|
||||
const _EXCLUDE_RESET_ELEMENTS: Elements[] = [
|
||||
'selectTechnicalCard',
|
||||
'selectTownRegistration',
|
||||
];
|
||||
const EXCLUDE_RESET_ELEMENTS: Elements[] = ['selectTechnicalCard', 'selectTownRegistration'];
|
||||
|
||||
const _AUTO_SET_VALUE_ELEMENTS: Elements[] = [
|
||||
const AUTO_SET_VALUE_ELEMENTS: Elements[] = [
|
||||
'selectProduct',
|
||||
'selectLeaseObjectType',
|
||||
'selectBrand',
|
||||
@ -23,7 +25,7 @@ const _AUTO_SET_VALUE_ELEMENTS: Elements[] = [
|
||||
'selectTownRegistration',
|
||||
];
|
||||
|
||||
export class OptionsStore {
|
||||
export default class OptionsStore {
|
||||
root: RootStore;
|
||||
#options: Partial<CalculationOptions> = {};
|
||||
#filters: Partial<OptionsFilters> = {};
|
||||
@ -41,17 +43,21 @@ export class OptionsStore {
|
||||
|
||||
getOption(elementName: Elements) {
|
||||
const value = this.root.$calculation.$values.getValueByElement(elementName);
|
||||
return this.#options[elementName]?.find(x => x.value === value);
|
||||
return this.#options[elementName]?.find((x) => x.value === value);
|
||||
}
|
||||
|
||||
getOptions(elementName: Elements, settings?: { filtered: true }) {
|
||||
getOptions(
|
||||
elementName: Elements,
|
||||
settings?: {
|
||||
filtered: true;
|
||||
}
|
||||
) {
|
||||
const options = this.#options[elementName];
|
||||
if (!options) return;
|
||||
|
||||
if (!settings?.filtered) return options;
|
||||
|
||||
const filter = this.#filters[elementName];
|
||||
return filter ? filter(options) : options;
|
||||
return filter ? options && filter(options) : options;
|
||||
}
|
||||
|
||||
setOptions(elementName: Elements, options: Options) {
|
||||
@ -59,9 +65,9 @@ export class OptionsStore {
|
||||
}
|
||||
|
||||
mergeOptions(options: Partial<CalculationOptions>) {
|
||||
mergeWith(this.#options, options, function (objValue, srcValue) {
|
||||
return objValue === undefined ? srcValue : objValue;
|
||||
});
|
||||
mergeWith(this.#options, options, (objValue, srcValue) =>
|
||||
objValue === undefined ? srcValue : objValue
|
||||
);
|
||||
}
|
||||
|
||||
clearOptions(elementName: Elements) {
|
||||
@ -84,34 +90,25 @@ export class OptionsStore {
|
||||
/**
|
||||
* Проверяем, что значение есть в отфильтрованном списке,
|
||||
* иначе сбрасываем значение
|
||||
* (кроме исключений {@link _EXCLUDE_RESET_ELEMENTS})
|
||||
* (кроме исключений {@link EXCLUDE_RESET_ELEMENTS})
|
||||
*/
|
||||
const filteredOptons = this.getOptions(elementName);
|
||||
|
||||
if (!_EXCLUDE_RESET_ELEMENTS.includes(elementName)) {
|
||||
const elementValue =
|
||||
this.root.$calculation.$values.getValueByElement(elementName);
|
||||
if (!EXCLUDE_RESET_ELEMENTS.includes(elementName)) {
|
||||
const elementValue = this.root.$calculation.$values.getValueByElement(elementName);
|
||||
|
||||
if (
|
||||
!filteredOptons?.length ||
|
||||
!filteredOptons.some(x => x.value === elementValue)
|
||||
)
|
||||
if (!filteredOptons?.length || !filteredOptons.some((x) => x.value === elementValue)) {
|
||||
this.root.$calculation.$values.clearValueOfElement(elementName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Если после фильтрации остается одна запись, то указываем ее
|
||||
* (для элементов из списка {@link _AUTO_SET_VALUE_ELEMENTS})
|
||||
* (для элементов из списка {@link AUTO_SET_VALUE_ELEMENTS})
|
||||
*/
|
||||
if (
|
||||
filteredOptons?.length === 1 &&
|
||||
_AUTO_SET_VALUE_ELEMENTS.includes(elementName)
|
||||
) {
|
||||
this.root.$calculation.$values.setValueOfElement(
|
||||
elementName,
|
||||
filteredOptons[0].value,
|
||||
);
|
||||
if (filteredOptons?.length === 1 && AUTO_SET_VALUE_ELEMENTS.includes(elementName)) {
|
||||
this.root.$calculation.$values.setValueOfElement(elementName, filteredOptons[0].value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { Elements } from 'Components/Calculation/types/elements';
|
||||
import type { Elements } from 'Components/Calculation/config/map';
|
||||
|
||||
export type BaseOption = {
|
||||
name: string;
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
/* eslint-disable object-curly-newline */
|
||||
/* eslint-disable import/no-cycle */
|
||||
import type { Elements } from 'Components/Calculation/types/elements';
|
||||
import { makeAutoObservable } from 'mobx';
|
||||
import { RootStore } from 'stores/root';
|
||||
import RootStore from 'stores/root';
|
||||
import type { CalculationStatuses, Status } from './types';
|
||||
|
||||
export class StatusStore {
|
||||
export default class StatusStore {
|
||||
root: RootStore;
|
||||
#statuses: CalculationStatuses = {};
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { Elements } from 'Components/Calculation/types/elements';
|
||||
import type { Elements } from 'Components/Calculation/config/map';
|
||||
|
||||
export type Status = 'Default' | 'Disabled' | 'Loading' | 'Hidden';
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import type { ElementsTypes } from 'Components/Calculation/config/map';
|
||||
/* eslint-disable object-curly-newline */
|
||||
/* eslint-disable import/no-cycle */
|
||||
import type { Elements, ElementsTypes } from 'Components/Calculation/config/map';
|
||||
import { getValueName } from 'Components/Calculation/config/map';
|
||||
import type { Elements } from 'Components/Calculation/types/elements';
|
||||
import { makeAutoObservable } from 'mobx';
|
||||
import { RootStore } from '../../root';
|
||||
import RootStore from '../../root';
|
||||
import type { CalculationValues, Values, ValuesTypes } from './types';
|
||||
|
||||
export class ValuesStore {
|
||||
export default class ValuesStore {
|
||||
root: RootStore;
|
||||
#values: CalculationValues = {};
|
||||
|
||||
@ -29,6 +30,7 @@ export class ValuesStore {
|
||||
|
||||
getValues<V extends Values>(valuesNames: readonly V[]) {
|
||||
return valuesNames.reduce((values, valueName) => {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
values[valueName] = this.getValue(valueName);
|
||||
return values;
|
||||
}, {} as Pick<CalculationValues, typeof valuesNames[number]>);
|
||||
@ -38,10 +40,7 @@ export class ValuesStore {
|
||||
this.#values[valueName] = value;
|
||||
}
|
||||
|
||||
setValueOfElement<E extends Elements>(
|
||||
elementName: E,
|
||||
value: ElementsTypes[E],
|
||||
) {
|
||||
setValueOfElement<E extends Elements>(elementName: E, value: ElementsTypes[E]) {
|
||||
const valueName = getValueName(elementName);
|
||||
this.setValue(valueName, value);
|
||||
}
|
||||
|
||||
@ -18,12 +18,7 @@ interface Types {
|
||||
lastPaymentRule: 100_000_000 | 100_000_001 | 100_000_002;
|
||||
redemptionPaymentSum: number;
|
||||
balanceHolder: 100_000_000 | 100_000_001;
|
||||
graphType:
|
||||
| 100_000_000
|
||||
| 100_000_001
|
||||
| 100_000_002
|
||||
| 100_000_003
|
||||
| 100_000_004;
|
||||
graphType: 100_000_000 | 100_000_001 | 100_000_002 | 100_000_003 | 100_000_004;
|
||||
|
||||
parmentsDecreasePercent: number;
|
||||
seasonType:
|
||||
@ -79,18 +74,8 @@ interface Types {
|
||||
model: string;
|
||||
configuration: string;
|
||||
leaseObjectYear: number;
|
||||
engineType:
|
||||
| 100_000_000
|
||||
| 100_000_001
|
||||
| 100_000_002
|
||||
| 100_000_003
|
||||
| 100_000_004;
|
||||
leaseObjectCategory:
|
||||
| 100_000_000
|
||||
| 100_000_001
|
||||
| 100_000_002
|
||||
| 100_000_003
|
||||
| 100_000_004;
|
||||
engineType: 100_000_000 | 100_000_001 | 100_000_002 | 100_000_003 | 100_000_004;
|
||||
leaseObjectCategory: 100_000_000 | 100_000_001 | 100_000_002 | 100_000_003 | 100_000_004;
|
||||
leaseObjectMotorPower: number;
|
||||
engineVolume: number;
|
||||
leaseObjectUseFor:
|
||||
@ -208,13 +193,7 @@ interface Types {
|
||||
| 100_000_018
|
||||
| 100_000_019
|
||||
| 100_000_020;
|
||||
objectTypeTax:
|
||||
| 100_000_000
|
||||
| 100_000_001
|
||||
| 100_000_002
|
||||
| 100_000_003
|
||||
| 100_000_004
|
||||
| 100_000_005;
|
||||
objectTypeTax: 100_000_000 | 100_000_001 | 100_000_002 | 100_000_003 | 100_000_004 | 100_000_005;
|
||||
typePTS: 100_000_000 | 100_000_001;
|
||||
legalClientRegion: string;
|
||||
legalClientTown: string;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import { useContext } from 'react';
|
||||
import { StoreContext } from '.';
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { createContext } from 'react';
|
||||
import { RootStore } from './root';
|
||||
import RootStore from './root';
|
||||
|
||||
/** @type{RootStore} */
|
||||
let store;
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
/* eslint-disable import/no-cycle */
|
||||
import { enableStaticRendering } from 'mobx-react-lite';
|
||||
import { CalculationStore } from './calculation';
|
||||
import { UserStore } from './user';
|
||||
import CalculationStore from './calculation';
|
||||
import UserStore from './user';
|
||||
|
||||
enableStaticRendering(typeof window === 'undefined');
|
||||
|
||||
export class RootStore {
|
||||
export default class RootStore {
|
||||
$user: UserStore;
|
||||
$calculation: CalculationStore;
|
||||
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
/* eslint-disable import/no-cycle */
|
||||
import { makeAutoObservable } from 'mobx';
|
||||
import type { User } from 'services/user/types';
|
||||
import { RootStore } from './root';
|
||||
import RootStore from './root';
|
||||
|
||||
export class UserStore {
|
||||
export default class UserStore {
|
||||
root: RootStore;
|
||||
user?: User = undefined;
|
||||
|
||||
@ -19,5 +20,6 @@ export class UserStore {
|
||||
const { username, domain } = this.user;
|
||||
return `${domain}\\${username}`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,8 +3,8 @@ body {
|
||||
background-color: var(--color-background);
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
|
||||
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
|
||||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell,
|
||||
Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user