diff --git a/Components/Calculation/config/map.ts b/Components/Calculation/config/map.ts index 3738b7c..8b78c67 100644 --- a/Components/Calculation/config/map.ts +++ b/Components/Calculation/config/map.ts @@ -1,5 +1,4 @@ import { Values, ValuesTypes } from 'stores/calculation/values/types'; -import { Elements } from '../types/elements'; function wrapElementsMap>(arg: T) { return arg; @@ -160,3 +159,5 @@ export type ElementsTypes = { export function getValueName(elementName: Elements) { return elementsToValues[elementName]; } + +export type Elements = keyof ElementsValues; diff --git a/Components/Calculation/types/elements.ts b/Components/Calculation/types/elements.ts deleted file mode 100644 index 66d4e86..0000000 --- a/Components/Calculation/types/elements.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { ElementsValues } from '../config/map'; - -export type Elements = keyof ElementsValues; diff --git a/Components/Layout/Logo.jsx b/Components/Layout/Logo.jsx index 14f8739..4dca148 100644 --- a/Components/Layout/Logo.jsx +++ b/Components/Layout/Logo.jsx @@ -25,11 +25,7 @@ const LogoText = styled.h3` function Logo() { return ( - + logo diff --git a/Components/Spinner.jsx b/Components/Spinner.jsx index 5c094f5..b067c41 100644 --- a/Components/Spinner.jsx +++ b/Components/Spinner.jsx @@ -6,7 +6,7 @@ export default Spin; const loadingOutlined = ( diff --git a/UIKit/mq.ts b/UIKit/mq.ts index 55bfa18..f697616 100644 --- a/UIKit/mq.ts +++ b/UIKit/mq.ts @@ -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`), }; diff --git a/UIKit/theme.js b/UIKit/theme.js index 93124c0..6fe084f 100644 --- a/UIKit/theme.js +++ b/UIKit/theme.js @@ -1,5 +1,7 @@ import { mediaQuery } from './mq'; -const theme = { ...mediaQuery }; +const theme = { + ...mediaQuery, +}; export default theme; diff --git a/pages/500.jsx b/pages/500.jsx index bcd6cf6..33b2de3 100644 --- a/pages/500.jsx +++ b/pages/500.jsx @@ -1,12 +1,5 @@ import { Result } from 'antd'; export default function NotFound(props) { - return ( - - ); + return ; } diff --git a/pages/_app.tsx b/pages/_app.tsx index 7ca4428..85c7711 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -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'; diff --git a/pages/_document.jsx b/pages/_document.jsx index fd7ee6d..756fd6f 100644 --- a/pages/_document.jsx +++ b/pages/_document.jsx @@ -32,16 +32,8 @@ export default class MyDocument extends Document { - - + + - +
diff --git a/pages/index.tsx b/pages/index.tsx index a4af239..c06c24a 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -9,9 +9,7 @@ function Home() { return
Home
; } -export const getServerSideProps: GetServerSideProps = async ( - ctx -) => { +export const getServerSideProps: GetServerSideProps = async (ctx) => { const user = await fetchUser({ headers: ctx?.req?.headers?.cookie ? { diff --git a/services/user/index.ts b/services/user/index.ts index 5fc7e51..1bac544 100644 --- a/services/user/index.ts +++ b/services/user/index.ts @@ -10,7 +10,7 @@ function love(user: User) { export async function fetchUser(config: AxiosRequestConfig) { const user = await axios .get(process.env.URL_GET_USER || '', config) - .then(res => love(res.data)); + .then((res) => love(res.data)); return user; } diff --git a/stores/Provider.jsx b/stores/Provider.jsx index e4f65e0..470eb54 100644 --- a/stores/Provider.jsx +++ b/stores/Provider.jsx @@ -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 ( - {children} - ); + return {children}; } diff --git a/stores/calculation/index.ts b/stores/calculation/index.ts index 6d0b3c6..5e3dd83 100644 --- a/stores/calculation/index.ts +++ b/stores/calculation/index.ts @@ -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; diff --git a/stores/calculation/options/index.ts b/stores/calculation/options/index.ts index 2ed3f15..9303c90 100644 --- a/stores/calculation/options/index.ts +++ b/stores/calculation/options/index.ts @@ -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 = {}; #filters: Partial = {}; @@ -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) { - 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); } } diff --git a/stores/calculation/options/types.ts b/stores/calculation/options/types.ts index 59c60f5..9eab488 100644 --- a/stores/calculation/options/types.ts +++ b/stores/calculation/options/types.ts @@ -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; diff --git a/stores/calculation/statuses/index.ts b/stores/calculation/statuses/index.ts index c825bb7..5fa7939 100644 --- a/stores/calculation/statuses/index.ts +++ b/stores/calculation/statuses/index.ts @@ -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 = {}; diff --git a/stores/calculation/statuses/types.ts b/stores/calculation/statuses/types.ts index 45538fa..cd71f1e 100644 --- a/stores/calculation/statuses/types.ts +++ b/stores/calculation/statuses/types.ts @@ -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'; diff --git a/stores/calculation/values/index.ts b/stores/calculation/values/index.ts index 03d679c..e33e732 100644 --- a/stores/calculation/values/index.ts +++ b/stores/calculation/values/index.ts @@ -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(valuesNames: readonly V[]) { return valuesNames.reduce((values, valueName) => { + // eslint-disable-next-line no-param-reassign values[valueName] = this.getValue(valueName); return values; }, {} as Pick); @@ -38,10 +40,7 @@ export class ValuesStore { this.#values[valueName] = value; } - setValueOfElement( - elementName: E, - value: ElementsTypes[E], - ) { + setValueOfElement(elementName: E, value: ElementsTypes[E]) { const valueName = getValueName(elementName); this.setValue(valueName, value); } diff --git a/stores/calculation/values/types.ts b/stores/calculation/values/types.ts index 27f01e1..41be73e 100644 --- a/stores/calculation/values/types.ts +++ b/stores/calculation/values/types.ts @@ -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; diff --git a/stores/hooks.js b/stores/hooks.js index f197550..9ef472e 100644 --- a/stores/hooks.js +++ b/stores/hooks.js @@ -1,3 +1,4 @@ +/* eslint-disable import/prefer-default-export */ import { useContext } from 'react'; import { StoreContext } from '.'; diff --git a/stores/index.js b/stores/index.js index 23f77b0..46f5643 100644 --- a/stores/index.js +++ b/stores/index.js @@ -1,5 +1,5 @@ import { createContext } from 'react'; -import { RootStore } from './root'; +import RootStore from './root'; /** @type{RootStore} */ let store; diff --git a/stores/root.ts b/stores/root.ts index 34030a6..0854ff0 100644 --- a/stores/root.ts +++ b/stores/root.ts @@ -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; diff --git a/stores/user.ts b/stores/user.ts index a171197..7e1545b 100644 --- a/stores/user.ts +++ b/stores/user.ts @@ -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 ''; } } diff --git a/styles/globals.css b/styles/globals.css index e24e821..99fcc36 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -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 {