merge branch upgrade/packages-2606
This commit is contained in:
parent
84de7a84e8
commit
c77f60fdc3
@ -1,8 +1,9 @@
|
|||||||
import type { columns } from '../lib/config';
|
import type { columns } from '../lib/config';
|
||||||
import type { Row, StoreSelector } from '../types';
|
import type { Row, StoreSelector } from '../types';
|
||||||
|
import { message } from '@/Components/Common/Notification';
|
||||||
import { useStore } from '@/stores/hooks';
|
import { useStore } from '@/stores/hooks';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import { message, Table } from 'ui/elements';
|
import { Table } from 'ui/elements';
|
||||||
|
|
||||||
export const PolicyTable = observer(
|
export const PolicyTable = observer(
|
||||||
({
|
({
|
||||||
|
|||||||
@ -19,7 +19,7 @@ export const ReloadButton = observer(
|
|||||||
disabled={hasErrors}
|
disabled={hasErrors}
|
||||||
loading={rows.some((x) => x.status === 'fetching')}
|
loading={rows.some((x) => x.status === 'fetching')}
|
||||||
shape="circle"
|
shape="circle"
|
||||||
icon={<ReloadOutlined />}
|
icon={<ReloadOutlined rev="" />}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -41,13 +41,13 @@ export const columns: ColumnsType<Row> = [
|
|||||||
if (record.status === 'fetching')
|
if (record.status === 'fetching')
|
||||||
return (
|
return (
|
||||||
<Flex justifyContent="center">
|
<Flex justifyContent="center">
|
||||||
<LoadingOutlined spin />
|
<LoadingOutlined spin rev="" />
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
if (record.status === 'error')
|
if (record.status === 'error')
|
||||||
return (
|
return (
|
||||||
<Flex justifyContent="center">
|
<Flex justifyContent="center">
|
||||||
<CloseOutlined />
|
<CloseOutlined rev="" />
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ export const columns: ColumnsType<Insurance.RowValues> = [
|
|||||||
(record.key === 'osago' && $tables.elt.osago.getSelectedRow?.key) ||
|
(record.key === 'osago' && $tables.elt.osago.getSelectedRow?.key) ||
|
||||||
(record.key === 'kasko' && $tables.elt.kasko.getSelectedRow?.key)
|
(record.key === 'kasko' && $tables.elt.kasko.getSelectedRow?.key)
|
||||||
) {
|
) {
|
||||||
return <CheckOutlined />;
|
return <CheckOutlined rev="" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -20,7 +20,7 @@ export function buildLink<T>(
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Component
|
<Component
|
||||||
href={value || undefined}
|
href={status === 'Disabled' ? undefined : value || undefined}
|
||||||
disabled={!value || status === 'Disabled'}
|
disabled={!value || status === 'Disabled'}
|
||||||
loading={status === 'Loading'}
|
loading={status === 'Loading'}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@ -4,12 +4,17 @@ import { useValue } from '@/stores/calculation/values/hooks';
|
|||||||
import type { Values } from '@/stores/calculation/values/types';
|
import type { Values } from '@/stores/calculation/values/types';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import type { ComponentType } from 'react';
|
import type { ComponentType } from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
type BuilderProps = {
|
type BuilderProps = {
|
||||||
elementName: Elements;
|
elementName: Elements;
|
||||||
valueName: Values;
|
valueName: Values;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const Wrapper = styled.div`
|
||||||
|
margin-bottom: 24px;
|
||||||
|
`;
|
||||||
|
|
||||||
export function buildReadonly<T>(
|
export function buildReadonly<T>(
|
||||||
Component: ComponentType<T>,
|
Component: ComponentType<T>,
|
||||||
{ elementName, valueName }: BuilderProps
|
{ elementName, valueName }: BuilderProps
|
||||||
@ -18,6 +23,10 @@ export function buildReadonly<T>(
|
|||||||
const [value] = useValue(valueName);
|
const [value] = useValue(valueName);
|
||||||
const status = useStatus(elementName);
|
const status = useStatus(elementName);
|
||||||
|
|
||||||
return <Component readOnly status={status} value={value} {...props} />;
|
return (
|
||||||
|
<Wrapper>
|
||||||
|
<Component readOnly status={status} value={value} {...props} />
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable jsdoc/multiline-blocks */
|
|
||||||
/* eslint-disable canonical/sort-keys */
|
/* eslint-disable canonical/sort-keys */
|
||||||
import type { Elements as ActionElements } from './map/actions';
|
import type { Elements as ActionElements } from './map/actions';
|
||||||
import type { Elements as ValuesElements } from './map/values';
|
import type { Elements as ValuesElements } from './map/values';
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable jsdoc/multiline-blocks */
|
|
||||||
/* eslint-disable canonical/sort-keys */
|
/* eslint-disable canonical/sort-keys */
|
||||||
import CurrencyAddon from '../addons/currency-addon';
|
import CurrencyAddon from '../addons/currency-addon';
|
||||||
import type { ElementsProps } from './elements-components';
|
import type { ElementsProps } from './elements-components';
|
||||||
@ -412,12 +411,12 @@ const props: Partial<ElementsProps> = {
|
|||||||
btnCreateKP: {
|
btnCreateKP: {
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
children: 'Создать КП',
|
children: 'Создать КП',
|
||||||
icon: <PlusOutlined />,
|
icon: <PlusOutlined rev="" />,
|
||||||
},
|
},
|
||||||
btnCreateKPMini: {
|
btnCreateKPMini: {
|
||||||
children: '',
|
children: '',
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
icon: <PlusOutlined />,
|
icon: <PlusOutlined rev="" />,
|
||||||
block: true,
|
block: true,
|
||||||
},
|
},
|
||||||
tbxCreditRate: {
|
tbxCreditRate: {
|
||||||
@ -504,7 +503,7 @@ const props: Partial<ElementsProps> = {
|
|||||||
width: '100%',
|
width: '100%',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
linkDownloadKp: { children: 'Скачать КП', icon: <DownloadOutlined />, type: 'primary' },
|
linkDownloadKp: { children: 'Скачать КП', icon: <DownloadOutlined rev="" />, type: 'primary' },
|
||||||
tbxMileage: {
|
tbxMileage: {
|
||||||
min: 0,
|
min: 0,
|
||||||
step: 100,
|
step: 100,
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import { useErrors, useStore } from '@/stores/hooks';
|
|||||||
import { useIsFetching } from '@tanstack/react-query';
|
import { useIsFetching } from '@tanstack/react-query';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import type { ComponentProps } from 'react';
|
import type { ComponentProps } from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
import { Link, Tooltip } from 'ui/elements';
|
import { Link, Tooltip } from 'ui/elements';
|
||||||
import { LoadingOutlined } from 'ui/elements/icons';
|
import { LoadingOutlined } from 'ui/elements/icons';
|
||||||
|
|
||||||
@ -24,6 +25,10 @@ const formatter = Intl.NumberFormat('ru', {
|
|||||||
minimumFractionDigits: 2,
|
minimumFractionDigits: 2,
|
||||||
}).format;
|
}).format;
|
||||||
|
|
||||||
|
const TextAddon = styled.span`
|
||||||
|
font-size: 14px;
|
||||||
|
`;
|
||||||
|
|
||||||
const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
||||||
btnCalculate: {
|
btnCalculate: {
|
||||||
render: () => {
|
render: () => {
|
||||||
@ -305,13 +310,11 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
const { $calculation } = useStore();
|
const { $calculation } = useStore();
|
||||||
const { min, max } = $calculation.$values.getValue('irrInfo');
|
const { min, max } = $calculation.$values.getValue('irrInfo');
|
||||||
|
|
||||||
|
const addon = <TextAddon>{`${formatter(min)}% - ${formatter(max)}%`}</TextAddon>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<Head
|
<Head htmlFor={elementName} title={title} addon={addon} />
|
||||||
htmlFor={elementName}
|
|
||||||
title={title}
|
|
||||||
addon={`${formatter(min)}% - ${formatter(max)}%`}
|
|
||||||
/>
|
|
||||||
<Element {...props} min={min > 0 ? min : undefined} max={max > 0 ? max : undefined} />
|
<Element {...props} min={min > 0 ? min : undefined} max={max > 0 ? max : undefined} />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
@ -345,7 +348,7 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
|
|||||||
<Element
|
<Element
|
||||||
{...props}
|
{...props}
|
||||||
id={elementName}
|
id={elementName}
|
||||||
addonBefore={isFetching && <LoadingOutlined spin />}
|
addonBefore={isFetching && <LoadingOutlined spin rev="" />}
|
||||||
/>
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable jsdoc/multiline-blocks */
|
|
||||||
/* eslint-disable canonical/sort-keys */
|
/* eslint-disable canonical/sort-keys */
|
||||||
import type { Elements as ActionElements } from './map/actions';
|
import type { Elements as ActionElements } from './map/actions';
|
||||||
import type { Elements as ValuesElements } from './map/values';
|
import type { Elements as ValuesElements } from './map/values';
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable jsdoc/multiline-blocks */
|
|
||||||
/* eslint-disable canonical/sort-keys */
|
/* eslint-disable canonical/sort-keys */
|
||||||
import * as b from '../builders';
|
import * as b from '../builders';
|
||||||
import type { Elements as ActionElements } from './map/actions';
|
import type { Elements as ActionElements } from './map/actions';
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable jsdoc/multiline-blocks */
|
|
||||||
/* eslint-disable canonical/sort-keys */
|
/* eslint-disable canonical/sort-keys */
|
||||||
import type { CalculationValues, Values } from '@/stores/calculation/values/types';
|
import type { CalculationValues, Values } from '@/stores/calculation/values/types';
|
||||||
|
|
||||||
|
|||||||
30
apps/web/Components/Common/Notification.tsx
Normal file
30
apps/web/Components/Common/Notification.tsx
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* eslint-disable import/no-mutable-exports */
|
||||||
|
import type { MessageInstance } from 'antd/es/message/interface';
|
||||||
|
import type { NotificationInstance } from 'antd/es/notification/interface';
|
||||||
|
import type { ReactNode } from 'react';
|
||||||
|
import { message as antdMessage, notification as antdNotification } from 'ui/elements';
|
||||||
|
|
||||||
|
export let message: Readonly<MessageInstance>;
|
||||||
|
export let notification: Readonly<NotificationInstance>;
|
||||||
|
|
||||||
|
export function Notification({ children }: { children: ReactNode }) {
|
||||||
|
const [messageApi, messageContextHolder] = antdMessage.useMessage({
|
||||||
|
maxCount: 3,
|
||||||
|
top: 70,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [notificationApi, notificationContextHolder] = antdNotification.useNotification({
|
||||||
|
placement: 'bottomRight',
|
||||||
|
});
|
||||||
|
|
||||||
|
message = messageApi;
|
||||||
|
notification = notificationApi;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{messageContextHolder}
|
||||||
|
{notificationContextHolder}
|
||||||
|
{children}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -13,6 +13,7 @@ const UserText = styled.span`
|
|||||||
font-size: 0.5rem;
|
font-size: 0.5rem;
|
||||||
font-family: 'Montserrat';
|
font-family: 'Montserrat';
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
line-height: 1;
|
||||||
|
|
||||||
${min('laptop')} {
|
${min('laptop')} {
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
@ -35,6 +36,7 @@ const Logout = styled.a`
|
|||||||
font-size: 0.45rem;
|
font-size: 0.45rem;
|
||||||
font-family: 'Montserrat';
|
font-family: 'Montserrat';
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
margin-top: 4px;
|
||||||
|
|
||||||
${min('laptop')} {
|
${min('laptop')} {
|
||||||
font-size: 0.55rem;
|
font-size: 0.55rem;
|
||||||
|
|||||||
@ -15,9 +15,9 @@ const HeaderContent = styled(Flex)`
|
|||||||
var(--color-tertiarty) 100%
|
var(--color-tertiarty) 100%
|
||||||
);
|
);
|
||||||
|
|
||||||
padding: 10px 12px;
|
padding: 14px 12px;
|
||||||
${min('laptop')} {
|
${min('laptop')} {
|
||||||
padding: 10px 12px;
|
padding: 14px 12px;
|
||||||
padding-left: 20px;
|
padding-left: 20px;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
@ -1,18 +1,12 @@
|
|||||||
import getUrls from '@/config/urls';
|
import { withBasePath } from '@/config/urls';
|
||||||
|
|
||||||
const { BASE_PATH } = getUrls();
|
|
||||||
|
|
||||||
function buildPath(filePath) {
|
|
||||||
return String.prototype.concat(BASE_PATH, filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const metaFavicon = (
|
export const metaFavicon = (
|
||||||
<>
|
<>
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href={buildPath('/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={buildPath('/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={buildPath('/favicon-16x16.png')} />
|
<link rel="icon" type="image/png" sizes="16x16" href={withBasePath('/favicon-16x16.png')} />
|
||||||
<link rel="manifest" href={buildPath('/site.webmanifest')} />
|
<link rel="manifest" href={withBasePath('/site.webmanifest')} />
|
||||||
<link rel="mask-icon" href={buildPath('/safari-pinned-tab.svg')} color="#5bbad5" />
|
<link rel="mask-icon" href={withBasePath('/safari-pinned-tab.svg')} color="#5bbad5" />
|
||||||
<meta name="theme-color" content="#ffffff" />
|
<meta name="theme-color" content="#ffffff" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -4,14 +4,13 @@ import getConfig from 'next/config';
|
|||||||
import { isServer } from 'tools/common';
|
import { isServer } from 'tools/common';
|
||||||
|
|
||||||
const { serverRuntimeConfig, publicRuntimeConfig } = getConfig();
|
const { serverRuntimeConfig, publicRuntimeConfig } = getConfig();
|
||||||
|
const { BASE_PATH } = publicRuntimeConfigSchema.parse(publicRuntimeConfig);
|
||||||
|
|
||||||
|
export function withBasePath(path: string) {
|
||||||
|
return String.prototype.concat(BASE_PATH, path);
|
||||||
|
}
|
||||||
|
|
||||||
function getUrls() {
|
function getUrls() {
|
||||||
const { BASE_PATH } = publicRuntimeConfigSchema.parse(publicRuntimeConfig);
|
|
||||||
|
|
||||||
function withBasePath(url: string) {
|
|
||||||
return BASE_PATH + url;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isServer()) {
|
if (isServer()) {
|
||||||
const {
|
const {
|
||||||
URL_CRM_GRAPHQL_DIRECT,
|
URL_CRM_GRAPHQL_DIRECT,
|
||||||
|
|||||||
@ -1,13 +1,11 @@
|
|||||||
const { withPlugins } = require('next-composed-plugins');
|
|
||||||
const withLess = require('next-with-less');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { COLORS_DEV, COLORS_PROD } = require('./constants/colors');
|
|
||||||
const envSchema = require('./config/schema/env');
|
const envSchema = require('./config/schema/env');
|
||||||
const urls = require('./constants/urls');
|
const urls = require('./constants/urls');
|
||||||
const { devices } = require('./config/ui');
|
const { devices } = require('./config/ui');
|
||||||
const { publicRuntimeConfigSchema } = require('./config/schema/runtime-config');
|
const { publicRuntimeConfigSchema } = require('./config/schema/runtime-config');
|
||||||
const { serverRuntimeConfigSchema } = require('./config/schema/runtime-config');
|
const { serverRuntimeConfigSchema } = require('./config/schema/runtime-config');
|
||||||
|
const { Config } = require('next-recompose-plugins');
|
||||||
|
|
||||||
const env = envSchema.parse(process.env);
|
const env = envSchema.parse(process.env);
|
||||||
|
|
||||||
@ -20,8 +18,7 @@ function buildFaviconRewrite(source) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {import('next').NextConfig} */
|
module.exports = new Config({
|
||||||
const nextConfig = {
|
|
||||||
basePath: env.BASE_PATH,
|
basePath: env.BASE_PATH,
|
||||||
compiler: {
|
compiler: {
|
||||||
styledComponents: true,
|
styledComponents: true,
|
||||||
@ -73,22 +70,5 @@ const nextConfig = {
|
|||||||
},
|
},
|
||||||
serverRuntimeConfig: serverRuntimeConfigSchema.parse(env),
|
serverRuntimeConfig: serverRuntimeConfigSchema.parse(env),
|
||||||
swcMinify: true,
|
swcMinify: true,
|
||||||
transpilePackages: ['ui', 'tools'],
|
transpilePackages: ['ui', 'tools', 'antd'],
|
||||||
};
|
}).build();
|
||||||
|
|
||||||
const plugins = [withLess];
|
|
||||||
|
|
||||||
const colorPrimary = env.USE_DEV_COLORS ? COLORS_DEV.COLOR_PRIMARY : COLORS_PROD.COLOR_PRIMARY;
|
|
||||||
|
|
||||||
const config = {
|
|
||||||
...nextConfig,
|
|
||||||
lessLoaderOptions: {
|
|
||||||
lessOptions: {
|
|
||||||
modifyVars: {
|
|
||||||
'primary-color': colorPrimary,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = withPlugins(config, plugins);
|
|
||||||
|
|||||||
@ -22,13 +22,10 @@
|
|||||||
"@trpc/server": "^10.13.0",
|
"@trpc/server": "^10.13.0",
|
||||||
"axios": "^1.3.4",
|
"axios": "^1.3.4",
|
||||||
"dayjs": "^1.11.7",
|
"dayjs": "^1.11.7",
|
||||||
"less": "^4.1.3",
|
|
||||||
"less-loader": "^11.1.0",
|
|
||||||
"mobx": "^6.8.0",
|
"mobx": "^6.8.0",
|
||||||
"mobx-react-lite": "^3.4.0",
|
"mobx-react-lite": "^3.4.0",
|
||||||
"next": "^13.2.1",
|
"next": "^13.4.7",
|
||||||
"next-composed-plugins": "^1.0.1",
|
"next-recompose-plugins": "^2.0.0",
|
||||||
"next-with-less": "^2.0.5",
|
|
||||||
"normalize.css": "^8.0.1",
|
"normalize.css": "^8.0.1",
|
||||||
"radash": "^10.7.0",
|
"radash": "^10.7.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
@ -50,10 +47,10 @@
|
|||||||
"@testing-library/jest-dom": "^5.16.5",
|
"@testing-library/jest-dom": "^5.16.5",
|
||||||
"@testing-library/react": "^14.0.0",
|
"@testing-library/react": "^14.0.0",
|
||||||
"@types/node": "^18.14.2",
|
"@types/node": "^18.14.2",
|
||||||
"@types/react": "^18.0.28",
|
"@types/react": "^18.2.14",
|
||||||
"@types/react-dom": "^18.0.11",
|
"@types/react-dom": "^18.2.6",
|
||||||
"@types/styled-components": "^5.1.26",
|
"@types/styled-components": "^5.1.26",
|
||||||
"eslint": "^8.35.0",
|
"eslint": "^8.43.0",
|
||||||
"eslint-config-custom": "*",
|
"eslint-config-custom": "*",
|
||||||
"gql-sdl": "^1.0.0",
|
"gql-sdl": "^1.0.0",
|
||||||
"jest": "^29.4.3",
|
"jest": "^29.4.3",
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
import 'normalize.css';
|
import 'normalize.css';
|
||||||
import 'ui/elements/styles/antd.less';
|
|
||||||
import '../styles/fonts.css';
|
import '../styles/fonts.css';
|
||||||
import '../styles/globals.css';
|
import '../styles/globals.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 Layout from '@/Components/Layout';
|
import Layout from '@/Components/Layout';
|
||||||
import { theme } from '@/config/ui';
|
import { theme } from '@/config/ui';
|
||||||
import StoreProvider from '@/stores/Provider';
|
import StoreProvider from '@/stores/Provider';
|
||||||
|
import getColors from '@/styles/colors';
|
||||||
import { GlobalStyle } from '@/styles/global-style';
|
import { GlobalStyle } from '@/styles/global-style';
|
||||||
import { trpcClient } from '@/trpc/client';
|
import { trpcClient } from '@/trpc/client';
|
||||||
import { ApolloProvider } from '@apollo/client';
|
import { ApolloProvider } from '@apollo/client';
|
||||||
@ -14,13 +15,15 @@ import { QueryClientProvider } from '@tanstack/react-query';
|
|||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { ThemeProvider } from 'styled-components';
|
import { ThemeProvider } from 'styled-components';
|
||||||
import { Config as AntdConfig } from 'ui/elements/Config';
|
import { Config as AntdConfig } from 'ui/elements';
|
||||||
|
|
||||||
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
require('../mocks');
|
require('../mocks');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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]);
|
||||||
@ -36,15 +39,26 @@ function App({ Component, pageProps }) {
|
|||||||
</Head>
|
</Head>
|
||||||
<GlobalStyle />
|
<GlobalStyle />
|
||||||
<StoreProvider {...pageProps}>
|
<StoreProvider {...pageProps}>
|
||||||
<AntdConfig>
|
<ApolloProvider client={apolloClient}>
|
||||||
<ApolloProvider client={apolloClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<QueryClientProvider client={queryClient}>
|
<AntdConfig
|
||||||
<Layout>
|
theme={{
|
||||||
<Component {...pageProps} />
|
token: {
|
||||||
</Layout>
|
borderRadius: 2,
|
||||||
</QueryClientProvider>
|
borderRadiusLG: 2,
|
||||||
</ApolloProvider>
|
colorLink: colorPrimary,
|
||||||
</AntdConfig>
|
colorPrimary,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Notification>
|
||||||
|
<Layout>
|
||||||
|
<Component {...pageProps} />
|
||||||
|
</Layout>
|
||||||
|
</Notification>
|
||||||
|
</AntdConfig>
|
||||||
|
</QueryClientProvider>
|
||||||
|
</ApolloProvider>
|
||||||
</StoreProvider>
|
</StoreProvider>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,29 +1,36 @@
|
|||||||
/* 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 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 sheet = new ServerStyleSheet();
|
const cache = createCache();
|
||||||
|
let fileName = '';
|
||||||
const originalRenderPage = ctx.renderPage;
|
const originalRenderPage = ctx.renderPage;
|
||||||
|
const sheet = new ServerStyleSheet();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ctx.renderPage = () =>
|
ctx.renderPage = () =>
|
||||||
originalRenderPage({
|
originalRenderPage({
|
||||||
enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />),
|
enhanceApp: (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,
|
||||||
{initialProps.styles}
|
sheet.getStyleElement(),
|
||||||
{sheet.getStyleElement()}
|
fileName && <link rel="stylesheet" href={withBasePath(`/${fileName}`)} />,
|
||||||
</>
|
],
|
||||||
),
|
|
||||||
};
|
};
|
||||||
} finally {
|
} finally {
|
||||||
sheet.seal();
|
sheet.seal();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import type { ProcessContext } from '../types';
|
import type { ProcessContext } from '../types';
|
||||||
|
import { notification } from '@/Components/Common/Notification';
|
||||||
import { toJS } from 'mobx';
|
import { toJS } from 'mobx';
|
||||||
import { notification } from 'ui/elements';
|
|
||||||
|
|
||||||
const key = 'ACTION_CALCULATE';
|
const key = 'ACTION_CALCULATE';
|
||||||
const errorMessage = 'Ошибка во время расчета графика!';
|
const errorMessage = 'Ошибка во время расчета графика!';
|
||||||
@ -36,6 +36,7 @@ export async function action({ store, trpcClient }: ProcessContext) {
|
|||||||
description: res.error,
|
description: res.error,
|
||||||
key,
|
key,
|
||||||
message: errorMessage,
|
message: errorMessage,
|
||||||
|
placement: 'bottomRight',
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$results.setPayments(res.data.resultPayments);
|
$results.setPayments(res.data.resultPayments);
|
||||||
@ -45,6 +46,7 @@ export async function action({ store, trpcClient }: ProcessContext) {
|
|||||||
notification.success({
|
notification.success({
|
||||||
key,
|
key,
|
||||||
message: successMessage,
|
message: successMessage,
|
||||||
|
placement: 'bottomRight',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -53,6 +55,7 @@ export async function action({ store, trpcClient }: ProcessContext) {
|
|||||||
description: JSON.stringify(error),
|
description: JSON.stringify(error),
|
||||||
key,
|
key,
|
||||||
message: errorMessage,
|
message: errorMessage,
|
||||||
|
placement: 'bottomRight',
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import type { ProcessContext } from '../types';
|
import type { ProcessContext } from '../types';
|
||||||
|
import { notification } from '@/Components/Common/Notification';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { toJS } from 'mobx';
|
import { toJS } from 'mobx';
|
||||||
import { notification } from 'ui/elements';
|
|
||||||
|
|
||||||
const key = 'ACTION_CREATEKP';
|
const key = 'ACTION_CREATEKP';
|
||||||
const errorMessage = 'Ошибка во время создания КП!';
|
const errorMessage = 'Ошибка во время создания КП!';
|
||||||
@ -47,6 +47,7 @@ export function action({ store, trpcClient, apolloClient }: ProcessContext) {
|
|||||||
description: res.error,
|
description: res.error,
|
||||||
key,
|
key,
|
||||||
message: errorMessage,
|
message: errorMessage,
|
||||||
|
placement: 'bottomRight',
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$results.setPayments(res.data.resultPayments);
|
$results.setPayments(res.data.resultPayments);
|
||||||
@ -56,6 +57,7 @@ export function action({ store, trpcClient, apolloClient }: ProcessContext) {
|
|||||||
notification.success({
|
notification.success({
|
||||||
key,
|
key,
|
||||||
message: successMessage,
|
message: successMessage,
|
||||||
|
placement: 'bottomRight',
|
||||||
});
|
});
|
||||||
|
|
||||||
const leadid = $calculation.element('selectLead').getValue();
|
const leadid = $calculation.element('selectLead').getValue();
|
||||||
@ -83,6 +85,7 @@ export function action({ store, trpcClient, apolloClient }: ProcessContext) {
|
|||||||
description: JSON.stringify(error),
|
description: JSON.stringify(error),
|
||||||
key,
|
key,
|
||||||
message: errorMessage,
|
message: errorMessage,
|
||||||
|
placement: 'bottomRight',
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
/* eslint-disable canonical/sort-keys */
|
/* eslint-disable canonical/sort-keys */
|
||||||
|
|
||||||
|
import { notification } from '@/Components/Common/Notification';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import type { ProcessContext } from '@/process/types';
|
import type { ProcessContext } from '@/process/types';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
@ -7,7 +8,6 @@ import dayjs from 'dayjs';
|
|||||||
import utc from 'dayjs/plugin/utc';
|
import utc from 'dayjs/plugin/utc';
|
||||||
import { reaction } from 'mobx';
|
import { reaction } from 'mobx';
|
||||||
import { uid } from 'radash';
|
import { uid } from 'radash';
|
||||||
import { notification } from 'ui/elements';
|
|
||||||
|
|
||||||
dayjs.extend(utc);
|
dayjs.extend(utc);
|
||||||
|
|
||||||
@ -24,6 +24,7 @@ export function common({ store, apolloClient }: ProcessContext) {
|
|||||||
key: NOTIFICATION_KEY,
|
key: NOTIFICATION_KEY,
|
||||||
message: 'Внимание',
|
message: 'Внимание',
|
||||||
description: 'Лизинг без КАСКО был сброшен',
|
description: 'Лизинг без КАСКО был сброшен',
|
||||||
|
placement: 'bottomRight',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
/* eslint-disable sonarjs/cognitive-complexity */
|
/* eslint-disable sonarjs/cognitive-complexity */
|
||||||
import eltHelper from '../elt/lib/helper';
|
import eltHelper from '../elt/lib/helper';
|
||||||
|
import { message } from '@/Components/Common/Notification';
|
||||||
import type { ProcessContext } from '@/process/types';
|
import type { ProcessContext } from '@/process/types';
|
||||||
import { reaction } from 'mobx';
|
import { reaction } from 'mobx';
|
||||||
import { omit } from 'radash';
|
import { omit } from 'radash';
|
||||||
import { message } from 'ui/elements';
|
|
||||||
|
|
||||||
const key = 'KP_LOADING_INFO';
|
const key = 'KP_LOADING_INFO';
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { defaultResultsValues } from './default-values';
|
import { defaultResultsValues } from './default-values';
|
||||||
import type { ResultPayment, ResultValues } from './types';
|
import type { ResultPayment, ResultValues } from './types';
|
||||||
|
import { notification } from '@/Components/Common/Notification';
|
||||||
import type RootStore from '@/stores/root';
|
import type RootStore from '@/stores/root';
|
||||||
import type { IObservableArray } from 'mobx';
|
import type { IObservableArray } from 'mobx';
|
||||||
import { makeAutoObservable, observable } from 'mobx';
|
import { makeAutoObservable, observable } from 'mobx';
|
||||||
import { notification } from 'ui/elements';
|
|
||||||
|
|
||||||
export default class Results {
|
export default class Results {
|
||||||
private root: RootStore;
|
private root: RootStore;
|
||||||
@ -40,6 +40,7 @@ export default class Results {
|
|||||||
description: 'Результаты расчета были сброшены',
|
description: 'Результаты расчета были сброшены',
|
||||||
key: 'ACTION_CALCULATE',
|
key: 'ACTION_CALCULATE',
|
||||||
message: 'Внимание',
|
message: 'Внимание',
|
||||||
|
placement: 'bottomRight',
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,9 +2,9 @@ import type RootStore from '../../root';
|
|||||||
import Validation from '../../validation';
|
import Validation from '../../validation';
|
||||||
import type { ValidationConfig } from '../../validation/types';
|
import type { ValidationConfig } from '../../validation/types';
|
||||||
import type * as ELT from '@/Components/Calculation/Form/ELT/types';
|
import type * as ELT from '@/Components/Calculation/Form/ELT/types';
|
||||||
|
import { notification } from '@/Components/Common/Notification';
|
||||||
import type { IObservableArray } from 'mobx';
|
import type { IObservableArray } from 'mobx';
|
||||||
import { makeAutoObservable, observable, reaction, toJS } from 'mobx';
|
import { makeAutoObservable, observable, reaction, toJS } from 'mobx';
|
||||||
import { notification } from 'ui/elements';
|
|
||||||
|
|
||||||
type ConstructorInput = {
|
type ConstructorInput = {
|
||||||
rootStore: RootStore;
|
rootStore: RootStore;
|
||||||
@ -38,6 +38,7 @@ export default class PolicyStore {
|
|||||||
description: 'Выбранный расчет ЭЛТ был сброшен',
|
description: 'Выбранный расчет ЭЛТ был сброшен',
|
||||||
key: validationConfig.err_key,
|
key: validationConfig.err_key,
|
||||||
message: validationConfig.err_title,
|
message: validationConfig.err_title,
|
||||||
|
placement: 'bottomRight',
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import type RootStore from '../root';
|
import type RootStore from '../root';
|
||||||
import type { RemoveError, ValidationConfig, ValidationError, ValidationParams } from './types';
|
import type { RemoveError, ValidationConfig, ValidationError, ValidationParams } from './types';
|
||||||
|
import { notification } from '@/Components/Common/Notification';
|
||||||
import { makeAutoObservable } from 'mobx';
|
import { makeAutoObservable } from 'mobx';
|
||||||
import { isServer } from 'tools';
|
import { isServer } from 'tools';
|
||||||
import { notification } from 'ui/elements';
|
|
||||||
|
|
||||||
export default class Validation {
|
export default class Validation {
|
||||||
private root: RootStore;
|
private root: RootStore;
|
||||||
@ -27,7 +27,7 @@ export default class Validation {
|
|||||||
public removeError = ({ key }: Pick<ValidationError, 'key'>) => {
|
public removeError = ({ key }: Pick<ValidationError, 'key'>) => {
|
||||||
const error = [...this.errors].find((x) => x.key === key);
|
const error = [...this.errors].find((x) => x.key === key);
|
||||||
if (error) this.errors.delete(error);
|
if (error) this.errors.delete(error);
|
||||||
if (this.errors.size === 0) notification.close(this.params.err_key);
|
if (this.errors.size === 0 && !isServer()) notification.destroy(this.params.err_key);
|
||||||
};
|
};
|
||||||
|
|
||||||
public setError = ({ key, message, silent }: ValidationParams) => {
|
public setError = ({ key, message, silent }: ValidationParams) => {
|
||||||
@ -41,6 +41,7 @@ export default class Validation {
|
|||||||
description: message,
|
description: message,
|
||||||
key: this.params.err_key,
|
key: this.params.err_key,
|
||||||
message: this.params.err_title,
|
message: this.params.err_title,
|
||||||
|
placement: 'bottomRight',
|
||||||
type: this.root.$process.has('Unlimited') ? 'warning' : 'error',
|
type: this.root.$process.has('Unlimited') ? 'warning' : 'error',
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -49,6 +50,6 @@ export default class Validation {
|
|||||||
|
|
||||||
public clearErrors = () => {
|
public clearErrors = () => {
|
||||||
this.errors.clear();
|
this.errors.clear();
|
||||||
notification.close(this.params.err_key);
|
notification.destroy(this.params.err_key);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
"lint-staged": "^13.2.0",
|
"lint-staged": "^13.2.0",
|
||||||
"prettier": "^2.8.4",
|
"prettier": "^2.8.4",
|
||||||
"tools": "*",
|
"tools": "*",
|
||||||
"turbo": "^1.8.5"
|
"turbo": "^1.10.6"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@1.22.17",
|
"packageManager": "yarn@1.22.17",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@ -18,7 +18,7 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
extends: ['canonical/typescript', 'canonical/zod'],
|
extends: ['canonical/typescript', 'canonical/zod', 'canonical/regexp'],
|
||||||
files: '*.ts',
|
files: '*.ts',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,16 +4,16 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@typescript-eslint/parser": "^5.54.0",
|
"@typescript-eslint/parser": "^5.60.0",
|
||||||
"eslint": "^8.35.0",
|
"eslint": "^8.43.0",
|
||||||
"eslint-config-canonical": "^40.0.8",
|
"eslint-config-canonical": "^41.0.5",
|
||||||
"eslint-config-next": "^13.2.1",
|
"eslint-config-next": "^13.4.7",
|
||||||
"eslint-config-prettier": "^8.6.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"eslint-config-turbo": "^0.0.9",
|
"eslint-config-turbo": "^1.10.6",
|
||||||
"eslint-plugin-canonical": "^4.2.0",
|
"eslint-plugin-canonical": "^4.2.2",
|
||||||
"eslint-plugin-prettier": "^4.2.1",
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
"eslint-plugin-sonarjs": "^0.18.0",
|
"eslint-plugin-sonarjs": "^0.19.0",
|
||||||
"eslint-plugin-testing-library": "^5.10.2"
|
"eslint-plugin-testing-library": "^5.11.0"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
"lint": "TIMING=1 eslint \"**/*.ts*\""
|
"lint": "TIMING=1 eslint \"**/*.ts*\""
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.35.0",
|
"eslint": "^8.43.0",
|
||||||
"eslint-config-custom": "*"
|
"eslint-config-custom": "*"
|
||||||
},
|
},
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
import { ConfigProvider } from 'antd';
|
|
||||||
import ru_RU from 'antd/lib/locale/ru_RU';
|
|
||||||
|
|
||||||
export function Config({ children }) {
|
|
||||||
return <ConfigProvider locale={ru_RU}>{children}</ConfigProvider>;
|
|
||||||
}
|
|
||||||
12
packages/ui/elements/Config.tsx
Normal file
12
packages/ui/elements/Config.tsx
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { ConfigProvider } from 'antd';
|
||||||
|
import type { ConfigProviderProps } from 'antd/es/config-provider';
|
||||||
|
import ru_RU from 'antd/lib/locale/ru_RU';
|
||||||
|
import type { ReactNode } from 'react';
|
||||||
|
|
||||||
|
export function Config({ children, ...config }: ConfigProviderProps & { children: ReactNode }) {
|
||||||
|
return (
|
||||||
|
<ConfigProvider {...config} locale={ru_RU}>
|
||||||
|
{children}
|
||||||
|
</ConfigProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -1,14 +1,3 @@
|
|||||||
import { message, notification } from 'antd';
|
|
||||||
|
|
||||||
message.config({
|
|
||||||
maxCount: 3,
|
|
||||||
top: 70,
|
|
||||||
});
|
|
||||||
|
|
||||||
notification.config({
|
|
||||||
placement: 'bottomRight',
|
|
||||||
});
|
|
||||||
|
|
||||||
export * from './Button';
|
export * from './Button';
|
||||||
export * from './Checkbox';
|
export * from './Checkbox';
|
||||||
export * from './Config';
|
export * from './Config';
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
@import 'antd/dist/antd.less';
|
|
||||||
@ -8,19 +8,20 @@
|
|||||||
"lint": "TIMING=1 eslint \"**/*.ts*\""
|
"lint": "TIMING=1 eslint \"**/*.ts*\""
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react": "^18.0.28",
|
"@types/react": "^18.2.14",
|
||||||
"@types/react-dom": "^18.0.11",
|
"@types/react-dom": "^18.2.6",
|
||||||
"@types/rebass": "^4.0.10",
|
"@types/rebass": "^4.0.10",
|
||||||
"@types/styled-components": "^5.1.26",
|
"@types/styled-components": "^5.1.26",
|
||||||
"eslint": "^8.35.0",
|
"eslint": "^8.43.0",
|
||||||
"eslint-config-custom": "*",
|
"eslint-config-custom": "*",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"tsconfig": "*",
|
"tsconfig": "*",
|
||||||
"typescript": "^4.9.5"
|
"typescript": "^4.9.5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ant-design/icons": "4.8.0",
|
"@ant-design/cssinjs": "^1.10.1",
|
||||||
"antd": "4.24.7",
|
"@ant-design/icons": "^5.1.4",
|
||||||
|
"antd": "^5.6.3",
|
||||||
"rebass": "^4.0.7",
|
"rebass": "^4.0.7",
|
||||||
"styled-components": "^5.3.6",
|
"styled-components": "^5.3.6",
|
||||||
"use-debounce": "^9.0.3"
|
"use-debounce": "^9.0.3"
|
||||||
|
|||||||
42
packages/ui/tools.ts
Normal file
42
packages/ui/tools.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import { extractStyle } from '@ant-design/cssinjs';
|
||||||
|
import type Entity from '@ant-design/cssinjs/lib/Cache';
|
||||||
|
import { createHash } from 'crypto';
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
export type DoExtraStyleOptions = {
|
||||||
|
baseFileName?: string;
|
||||||
|
cache: Entity;
|
||||||
|
dir?: string;
|
||||||
|
};
|
||||||
|
export function doExtraStyle({
|
||||||
|
cache,
|
||||||
|
dir = 'antd-output',
|
||||||
|
baseFileName = 'antd.min',
|
||||||
|
}: DoExtraStyleOptions) {
|
||||||
|
const baseDir = path.resolve(__dirname, '../../static/css');
|
||||||
|
|
||||||
|
const outputCssPath = path.join(baseDir, dir);
|
||||||
|
|
||||||
|
if (!fs.existsSync(outputCssPath)) {
|
||||||
|
fs.mkdirSync(outputCssPath, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const css = extractStyle(cache, true);
|
||||||
|
if (!css) return '';
|
||||||
|
|
||||||
|
const md5 = createHash('md5');
|
||||||
|
const hash = md5.update(css).digest('hex');
|
||||||
|
const fileName = `${baseFileName}.${hash.slice(0, 8)}.css`;
|
||||||
|
const fullpath = path.join(outputCssPath, fileName);
|
||||||
|
|
||||||
|
const res = `_next/static/css/${dir}/${fileName}`;
|
||||||
|
|
||||||
|
if (fs.existsSync(fullpath)) return res;
|
||||||
|
|
||||||
|
fs.writeFileSync(fullpath, css);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { createCache, StyleProvider } from '@ant-design/cssinjs';
|
||||||
Loading…
x
Reference in New Issue
Block a user