eslint: apply fixes to code in project

This commit is contained in:
Chika 2022-05-29 15:12:03 +03:00
parent 63ac9958f1
commit b0a3307700
11 changed files with 19 additions and 9 deletions

View File

@ -20,6 +20,7 @@ const UserText = styled.span`
const User = observer(() => {
const { $user } = useStore();
return <UserText>{$user?.user?.displayName}</UserText>;
});

View File

@ -1,2 +1,3 @@
import { Box, Flex } from 'rebass/styled-components';
export { Box, Flex };

View File

@ -5,8 +5,7 @@ import { ApolloClient, InMemoryCache } from '@apollo/client';
/** @type {import('@apollo/client').ApolloClient<NormalizedCacheObject>} */
let apolloClient;
const uri =
typeof window === 'undefined'
const uri = typeof window === 'undefined'
? process.env.URL_CRM_GRAPHQL_DIRECT
: process.env.NEXT_PUBLIC_URL_CRM_GRAPHQL_PROXY;

View File

@ -4,5 +4,6 @@ import initializeApollo from './client';
export function useApollo(initialState) {
const client = useMemo(() => initializeApollo(initialState), [initialState]);
return client;
}

View File

@ -7,8 +7,7 @@ export default class MyDocument extends Document {
const originalRenderPage = ctx.renderPage;
try {
ctx.renderPage = () =>
originalRenderPage({
ctx.renderPage = () => originalRenderPage({
enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />),
});

View File

@ -1,10 +1,13 @@
/* eslint-disable import/prefer-default-export */
import axios, { AxiosRequestConfig } from 'axios';
import type { AxiosRequestConfig } from 'axios';
import axios from 'axios';
import type { User } from './types';
function love(user: User) {
const superUsers: string[] = JSON.parse(process.env.USERS_SUPER || '');
// eslint-disable-next-line no-param-reassign
if (superUsers?.includes(user.username)) user.displayName += '🧡';
return user;
}

View File

@ -3,5 +3,6 @@ import { initializeStore, StoreContext } from '.';
export default function StoreProvider({ children, ...initialData }) {
const store = initializeStore(initialData);
return <StoreContext.Provider value={store}>{children}</StoreContext.Provider>;
}

View File

@ -7,7 +7,7 @@ import type { Elements } from 'Components/Calculation/config/map-values';
import type { BaseOption } from 'Elements/types';
import { mergeWith } from 'lodash';
import { makeAutoObservable } from 'mobx';
import RootStore from 'stores/root';
import type RootStore from 'stores/root';
import type { CalculationOptions, Filter, OptionsFilters } from './types';
const EXCLUDE_RESET_ELEMENTS: Elements[] = ['selectTechnicalCard', 'selectTownRegistration'];
@ -43,6 +43,7 @@ export default class OptionsStore {
/** **************** OPTIONS **************** */
getOption(elementName: Elements) {
const value = this.root.$calculation.$values.getValueByElement(elementName);
return this.options[elementName]?.find((x) => x.value === value);
}
@ -57,6 +58,7 @@ export default class OptionsStore {
if (!settings?.filtered) return options;
const filter = this.filters[elementName];
return filter ? options && filter(options) : options;
}
@ -97,6 +99,7 @@ export default class OptionsStore {
if (!filteredOptons?.length || !filteredOptons.some((x) => x.value === elementValue)) {
this.root.$calculation.$values.clearValueOfElement(elementName);
}
return;
}

View File

@ -3,7 +3,7 @@
import type { Elements } from 'Components/Calculation/config/map-values';
import type { Status } from 'Elements/types';
import { makeAutoObservable } from 'mobx';
import RootStore from 'stores/root';
import type RootStore from 'stores/root';
import type { CalculationStatuses } from './types';
export default class StatusStore {

View File

@ -3,7 +3,7 @@
/* eslint-disable object-curly-newline */
import type { Elements } from 'Components/Calculation/config/map-values';
import { makeAutoObservable, observable } from 'mobx';
import RootStore from 'stores/root';
import type RootStore from 'stores/root';
import type { Error, Messages } from './types';
export default class ValidationStore {

View File

@ -1,7 +1,7 @@
/* eslint-disable import/no-cycle */
import { makeAutoObservable } from 'mobx';
import type { User } from 'services/user/types';
import RootStore from './root';
import type RootStore from './root';
export default class UserStore {
root: RootStore;
@ -18,8 +18,10 @@ export default class UserStore {
getDomainName() {
if (this.user) {
const { username, domain } = this.user;
return `${domain}\\${username}`;
}
return '';
}
}