diff --git a/.vscode/settings.json b/.vscode/settings.json
index a0e6f3e..b71cd0d 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -13,9 +13,9 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
- "source.fixAll": true,
- "source.fixAll.eslint": true,
- "source.removeUnusedImports": true
+ "source.fixAll": "explicit",
+ "source.fixAll.eslint": "explicit",
+ "source.removeUnusedImports": "explicit"
},
"workbench.editor.labelFormat": "short",
"eslint.workingDirectories": [{ "directory": "apps/web", "changeProcessCWD": true }],
diff --git a/apps/api/.dockerignore b/apps/api/.dockerignore
new file mode 100644
index 0000000..2d6b28a
--- /dev/null
+++ b/apps/api/.dockerignore
@@ -0,0 +1,6 @@
+Dockerfile
+.dockerignore
+node_modules
+npm-debug.log
+dist
+README.md
\ No newline at end of file
diff --git a/apps/api/.eslintrc.js b/apps/api/.eslintrc.js
new file mode 100644
index 0000000..86ca506
--- /dev/null
+++ b/apps/api/.eslintrc.js
@@ -0,0 +1,13 @@
+const { createConfig } = require('@vchikalkin/eslint-config-awesome');
+
+module.exports = createConfig('typescript', {
+ parserOptions: {
+ project: './tsconfig.json',
+ tsconfigRootDir: __dirname,
+ },
+ ignorePatterns: ['*.config.js', '.eslintrc.js'],
+ rules: {
+ 'import/no-duplicates': 'off',
+ 'import/consistent-type-specifier-style': 'off',
+ },
+});
diff --git a/apps/api/.gitignore b/apps/api/.gitignore
new file mode 100644
index 0000000..4b56acf
--- /dev/null
+++ b/apps/api/.gitignore
@@ -0,0 +1,56 @@
+# compiled output
+/dist
+/node_modules
+/build
+
+# Logs
+logs
+*.log
+npm-debug.log*
+pnpm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+lerna-debug.log*
+
+# OS
+.DS_Store
+
+# Tests
+/coverage
+/.nyc_output
+
+# IDEs and editors
+/.idea
+.project
+.classpath
+.c9/
+*.launch
+.settings/
+*.sublime-workspace
+
+# IDE - VSCode
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+
+# dotenv environment variable files
+.env
+.env.development.local
+.env.test.local
+.env.production.local
+.env.local
+
+# temp directory
+.temp
+.tmp
+
+# Runtime data
+pids
+*.pid
+*.seed
+*.pid.lock
+
+# Diagnostic reports (https://nodejs.org/api/report.html)
+report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
diff --git a/apps/api/.prettierrc b/apps/api/.prettierrc
new file mode 100644
index 0000000..dcb7279
--- /dev/null
+++ b/apps/api/.prettierrc
@@ -0,0 +1,4 @@
+{
+ "singleQuote": true,
+ "trailingComma": "all"
+}
\ No newline at end of file
diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile
new file mode 100644
index 0000000..ebd9cb5
--- /dev/null
+++ b/apps/api/Dockerfile
@@ -0,0 +1,41 @@
+# This Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
+# Make sure you update both files!
+
+FROM node:alpine AS builder
+# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
+RUN apk add --no-cache libc6-compat
+RUN apk update
+# Set working directory
+WORKDIR /app
+RUN yarn global add turbo
+COPY . .
+RUN turbo prune --scope=api --docker
+
+# Add lockfile and package.json's of isolated subworkspace
+FROM node:alpine AS installer
+RUN apk add --no-cache libc6-compat
+RUN apk update
+WORKDIR /app
+
+# First install dependencies (as they change less often)
+COPY .gitignore .gitignore
+COPY --from=builder /app/out/json/ .
+COPY --from=builder /app/out/yarn.lock ./yarn.lock
+RUN yarn install
+
+# Build the project and its dependencies
+COPY --from=builder /app/out/full/ .
+COPY turbo.json turbo.json
+# COPY .env .env
+RUN yarn turbo run build --filter=api...
+
+FROM node:alpine AS runner
+WORKDIR /app
+
+# Don't run production as root
+RUN addgroup --system --gid 1001 nestjs
+RUN adduser --system --uid 1001 nestjs
+USER nestjs
+COPY --from=installer /app .
+
+CMD node apps/api/dist/main.js
\ No newline at end of file
diff --git a/apps/api/README.md b/apps/api/README.md
new file mode 100644
index 0000000..8372941
--- /dev/null
+++ b/apps/api/README.md
@@ -0,0 +1,73 @@
+
+
+
+
+[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
+[circleci-url]: https://circleci.com/gh/nestjs/nest
+
+ A progressive Node.js framework for building efficient and scalable server-side applications.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+## Description
+
+[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
+
+## Installation
+
+```bash
+$ yarn install
+```
+
+## Running the app
+
+```bash
+# development
+$ yarn run start
+
+# watch mode
+$ yarn run start:dev
+
+# production mode
+$ yarn run start:prod
+```
+
+## Test
+
+```bash
+# unit tests
+$ yarn run test
+
+# e2e tests
+$ yarn run test:e2e
+
+# test coverage
+$ yarn run test:cov
+```
+
+## Support
+
+Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
+
+## Stay in touch
+
+- Author - [Kamil MyĆliwiec](https://kamilmysliwiec.com)
+- Website - [https://nestjs.com](https://nestjs.com/)
+- Twitter - [@nestframework](https://twitter.com/nestframework)
+
+## License
+
+Nest is [MIT licensed](LICENSE).
diff --git a/apps/api/nest-cli.json b/apps/api/nest-cli.json
new file mode 100644
index 0000000..f9aa683
--- /dev/null
+++ b/apps/api/nest-cli.json
@@ -0,0 +1,8 @@
+{
+ "$schema": "https://json.schemastore.org/nest-cli",
+ "collection": "@nestjs/schematics",
+ "sourceRoot": "src",
+ "compilerOptions": {
+ "deleteOutDir": true
+ }
+}
diff --git a/apps/api/package.json b/apps/api/package.json
new file mode 100644
index 0000000..26d2f30
--- /dev/null
+++ b/apps/api/package.json
@@ -0,0 +1,73 @@
+{
+ "name": "api",
+ "version": "0.0.1",
+ "description": "",
+ "author": "",
+ "private": true,
+ "license": "UNLICENSED",
+ "scripts": {
+ "build": "nest build",
+ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
+ "start": "nest start",
+ "dev": "nest start --watch",
+ "start:debug": "nest start --debug --watch",
+ "start:prod": "node dist/main",
+ "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
+ "test": "jest",
+ "test:watch": "jest --watch",
+ "test:cov": "jest --coverage",
+ "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
+ "test:e2e": "jest --config ./test/jest-e2e.json"
+ },
+ "dependencies": {
+ "@nestjs/cache-manager": "^2.2.1",
+ "@nestjs/common": "^10.0.0",
+ "@nestjs/config": "^3.2.0",
+ "@nestjs/core": "^10.0.0",
+ "@nestjs/platform-express": "^10.0.0",
+ "@nestjs/platform-fastify": "^10.3.3",
+ "cache-manager": "^5.4.0",
+ "cache-manager-ioredis": "^2.1.0",
+ "ioredis": "^5.3.2",
+ "reflect-metadata": "^0.2.0",
+ "rxjs": "^7.8.1",
+ "zod": "^3.22.4"
+ },
+ "devDependencies": {
+ "@nestjs/cli": "^10.0.0",
+ "@nestjs/schematics": "^10.0.0",
+ "@nestjs/testing": "^10.0.0",
+ "@types/jest": "^29.5.2",
+ "@types/node": "^20.3.1",
+ "@types/supertest": "^6.0.0",
+ "@vchikalkin/eslint-config-awesome": "^1.1.5",
+ "eslint": "^8.51.0",
+ "fastify": "^4.26.1",
+ "jest": "^29.5.0",
+ "prettier": "^3.0.0",
+ "source-map-support": "^0.5.21",
+ "supertest": "^6.3.3",
+ "ts-jest": "^29.1.0",
+ "ts-loader": "^9.4.3",
+ "ts-node": "^10.9.1",
+ "tsconfig-paths": "^4.2.0",
+ "typescript": "^5.1.3"
+ },
+ "jest": {
+ "moduleFileExtensions": [
+ "js",
+ "json",
+ "ts"
+ ],
+ "rootDir": "src",
+ "testRegex": ".*\\.spec\\.ts$",
+ "transform": {
+ "^.+\\.(t|j)s$": "ts-jest"
+ },
+ "collectCoverageFrom": [
+ "**/*.(t|j)s"
+ ],
+ "coverageDirectory": "../coverage",
+ "testEnvironment": "node"
+ }
+}
diff --git a/apps/api/src/app.module.ts b/apps/api/src/app.module.ts
new file mode 100644
index 0000000..72d471b
--- /dev/null
+++ b/apps/api/src/app.module.ts
@@ -0,0 +1,16 @@
+import { ProxyModule } from './proxy/proxy.module';
+import { Global, Module } from '@nestjs/common';
+import { ConfigModule } from '@nestjs/config';
+
+@Global()
+@Module({
+ imports: [
+ ConfigModule.forRoot({
+ isGlobal: true,
+ }),
+ ProxyModule,
+ ],
+ providers: [],
+})
+// eslint-disable-next-line @typescript-eslint/no-extraneous-class
+export class AppModule {}
diff --git a/apps/api/src/config/env.ts b/apps/api/src/config/env.ts
new file mode 100644
index 0000000..6dfb5a2
--- /dev/null
+++ b/apps/api/src/config/env.ts
@@ -0,0 +1,3 @@
+import envSchema from './schema/env';
+
+export const env = envSchema.parse(process.env);
diff --git a/apps/api/src/config/schema/env.ts b/apps/api/src/config/schema/env.ts
new file mode 100644
index 0000000..416e990
--- /dev/null
+++ b/apps/api/src/config/schema/env.ts
@@ -0,0 +1,16 @@
+import { z } from 'zod';
+
+const envSchema = z.object({
+ CACHE_TTL: z
+ .string()
+ .transform((val) => Number.parseInt(val, 10))
+ .default('900'),
+ REDIS_HOST: z.string(),
+ REDIS_PORT: z
+ .string()
+ .transform((val) => Number.parseInt(val, 10))
+ .default('6379'),
+ URL_CRM_GRAPHQL_DIRECT: z.string(),
+});
+
+export default envSchema;
diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts
new file mode 100644
index 0000000..43efeb9
--- /dev/null
+++ b/apps/api/src/main.ts
@@ -0,0 +1,13 @@
+import { AppModule } from './app.module';
+import { NestFactory } from '@nestjs/core';
+import type { NestFastifyApplication } from '@nestjs/platform-fastify';
+import { FastifyAdapter } from '@nestjs/platform-fastify';
+
+async function bootstrap() {
+ const app = await NestFactory.create(
+ AppModule,
+ new FastifyAdapter(),
+ );
+ await app.listen(3001);
+}
+bootstrap();
diff --git a/apps/api/src/proxy/proxy.controller.ts b/apps/api/src/proxy/proxy.controller.ts
new file mode 100644
index 0000000..fa8232b
--- /dev/null
+++ b/apps/api/src/proxy/proxy.controller.ts
@@ -0,0 +1,37 @@
+import type { GQLRequest } from './types';
+import { CACHE_MANAGER } from '@nestjs/cache-manager';
+import { All, Controller, Inject, Req, Res } from '@nestjs/common';
+import { Cache } from 'cache-manager';
+import { FastifyReply, FastifyRequest } from 'fastify';
+import { env } from 'src/config/env';
+
+@Controller('proxy')
+export class ProxyController {
+ constructor(@Inject(CACHE_MANAGER) private readonly cacheManager: Cache) {}
+ @All('/graphql')
+ public async graphql(@Req() req: FastifyRequest, @Res() reply: FastifyReply) {
+ const { operationName, query, variables } = req.body as GQLRequest;
+
+ const key = `${operationName} ${JSON.stringify(variables)}`;
+ const cached = await this.cacheManager.get(key);
+
+ if (cached) {
+ return reply.send(cached);
+ }
+
+ const response = await fetch(env.URL_CRM_GRAPHQL_DIRECT, {
+ body: JSON.stringify({ operationName, query, variables }),
+ headers: {
+ Authorization: req.headers.authorization,
+ 'Content-Type': 'application/json',
+ Cookie: req.headers.cookie,
+ },
+ method: req.method,
+ });
+
+ const data = await response.json();
+ if (data) await this.cacheManager.set(key, data);
+
+ return reply.send(data);
+ }
+}
diff --git a/apps/api/src/proxy/proxy.module.ts b/apps/api/src/proxy/proxy.module.ts
new file mode 100644
index 0000000..c160cdb
--- /dev/null
+++ b/apps/api/src/proxy/proxy.module.ts
@@ -0,0 +1,20 @@
+import { ProxyController } from './proxy.controller';
+import { CacheModule } from '@nestjs/cache-manager';
+import { Module } from '@nestjs/common';
+import * as redisStore from 'cache-manager-ioredis';
+import type { RedisOptions } from 'ioredis';
+import { env } from 'src/config/env';
+
+@Module({
+ controllers: [ProxyController],
+ imports: [
+ CacheModule.register({
+ host: env.REDIS_HOST,
+ port: env.REDIS_PORT,
+ store: redisStore,
+ ttl: env.CACHE_TTL,
+ }),
+ ],
+})
+// eslint-disable-next-line @typescript-eslint/no-extraneous-class
+export class ProxyModule {}
diff --git a/apps/api/src/proxy/types.ts b/apps/api/src/proxy/types.ts
new file mode 100644
index 0000000..bde0d91
--- /dev/null
+++ b/apps/api/src/proxy/types.ts
@@ -0,0 +1,5 @@
+export type GQLRequest = {
+ operationName: string;
+ query: string;
+ variables: string;
+};
diff --git a/apps/api/tsconfig.build.json b/apps/api/tsconfig.build.json
new file mode 100644
index 0000000..64f86c6
--- /dev/null
+++ b/apps/api/tsconfig.build.json
@@ -0,0 +1,4 @@
+{
+ "extends": "./tsconfig.json",
+ "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
+}
diff --git a/apps/api/tsconfig.json b/apps/api/tsconfig.json
new file mode 100644
index 0000000..a7f602d
--- /dev/null
+++ b/apps/api/tsconfig.json
@@ -0,0 +1,22 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "declaration": true,
+ "removeComments": true,
+ "emitDecoratorMetadata": true,
+ "experimentalDecorators": true,
+ "allowSyntheticDefaultImports": true,
+ "target": "ES2021",
+ "sourceMap": true,
+ "outDir": "./dist",
+ "baseUrl": "./",
+ "incremental": true,
+ "skipLibCheck": true,
+ "strictNullChecks": false,
+ "noImplicitAny": false,
+ "strictBindCallApply": false,
+ "forceConsistentCasingInFileNames": false,
+ "noFallthroughCasesInSwitch": false
+ },
+ "exclude": ["node_modules"]
+}
diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile
index a98154e..ae5b74e 100644
--- a/apps/web/Dockerfile
+++ b/apps/web/Dockerfile
@@ -32,6 +32,7 @@ ARG SENTRY_DSN
ARG SENTRYCLI_CDNURL
ARG URL_GET_USER_DIRECT
ARG URL_CRM_GRAPHQL_DIRECT
+ARG URL_CRM_GRAPHQL_PROXY
ARG URL_CRM_CREATEKP_DIRECT
ARG URL_CRM_DOWNLOADKP_BASE
ARG URL_CORE_FINGAP_DIRECT
diff --git a/apps/web/config/schema/env.js b/apps/web/config/schema/env.js
index f82636e..23b6240 100644
--- a/apps/web/config/schema/env.js
+++ b/apps/web/config/schema/env.js
@@ -10,6 +10,7 @@ const envSchema = z.object({
URL_CRM_CREATEKP_DIRECT: z.string(),
URL_CRM_DOWNLOADKP_BASE: z.string(),
URL_CRM_GRAPHQL_DIRECT: z.string(),
+ URL_CRM_GRAPHQL_PROXY: z.string(),
URL_ELT_KASKO_DIRECT: z.string(),
URL_ELT_OSAGO_DIRECT: z.string(),
URL_GET_USER_DIRECT: z.string(),
diff --git a/apps/web/config/schema/runtime-config.js b/apps/web/config/schema/runtime-config.js
index 73f0531..7cc6559 100644
--- a/apps/web/config/schema/runtime-config.js
+++ b/apps/web/config/schema/runtime-config.js
@@ -15,6 +15,7 @@ const serverRuntimeConfigSchema = envSchema.pick({
URL_CORE_FINGAP_DIRECT: true,
URL_CRM_CREATEKP_DIRECT: true,
URL_CRM_GRAPHQL_DIRECT: true,
+ URL_CRM_GRAPHQL_PROXY: true,
URL_ELT_KASKO_DIRECT: true,
URL_ELT_OSAGO_DIRECT: true,
URL_GET_USER_DIRECT: true,
diff --git a/apps/web/config/urls.ts b/apps/web/config/urls.ts
index 0b74f38..37f9a6c 100644
--- a/apps/web/config/urls.ts
+++ b/apps/web/config/urls.ts
@@ -13,7 +13,6 @@ export function withBasePath(path: string) {
function getUrls() {
if (isServer()) {
const {
- URL_CRM_GRAPHQL_DIRECT,
URL_GET_USER_DIRECT,
URL_CORE_FINGAP_DIRECT,
URL_1C_TRANSTAX_DIRECT,
@@ -22,6 +21,7 @@ function getUrls() {
PORT,
URL_ELT_KASKO_DIRECT,
URL_ELT_OSAGO_DIRECT,
+ URL_CRM_GRAPHQL_PROXY,
} = serverRuntimeConfigSchema.parse(serverRuntimeConfig);
return {
@@ -33,7 +33,7 @@ function getUrls() {
URL_CORE_FINGAP: URL_CORE_FINGAP_DIRECT,
URL_CRM_CREATEKP: URL_CRM_CREATEKP_DIRECT,
URL_CRM_DOWNLOADKP: withBasePath(urls.URL_CRM_DOWNLOADKP_PROXY),
- URL_CRM_GRAPHQL: URL_CRM_GRAPHQL_DIRECT,
+ URL_CRM_GRAPHQL: URL_CRM_GRAPHQL_PROXY,
URL_ELT_KASKO: URL_ELT_KASKO_DIRECT,
URL_ELT_OSAGO: URL_ELT_OSAGO_DIRECT,
URL_GET_USER: URL_GET_USER_DIRECT,
diff --git a/apps/web/next.config.js b/apps/web/next.config.js
index e6df328..e67ef05 100644
--- a/apps/web/next.config.js
+++ b/apps/web/next.config.js
@@ -38,8 +38,8 @@ module.exports = withSentryConfig({
async rewrites() {
return [
{
- destination: env.URL_CRM_GRAPHQL_DIRECT,
- source: urls.URL_CRM_GRAPHQL_PROXY,
+ destination: env.URL_CRM_GRAPHQL_PROXY + '/:path*',
+ source: urls.URL_CRM_GRAPHQL_PROXY + '/:path*',
},
{
destination: env.URL_CRM_DOWNLOADKP_BASE + '/:path*',
diff --git a/apps/web/process/add-product/reactions.ts b/apps/web/process/add-product/reactions.ts
index 80003ad..37a9087 100644
--- a/apps/web/process/add-product/reactions.ts
+++ b/apps/web/process/add-product/reactions.ts
@@ -4,14 +4,11 @@ import type { ProcessContext } from '../types';
import { createValidationSchema } from './validation';
import { selectRequirementTelematic } from '@/config/default-options';
import * as CRMTypes from '@/graphql/crm.types';
+import { getCurrentISODate } from '@/utils/date';
import { normalizeOptions } from '@/utils/entity';
import { debouncedReaction } from '@/utils/mobx';
-import dayjs from 'dayjs';
-import utc from 'dayjs/plugin/utc';
import { reaction, toJS } from 'mobx';
-dayjs.extend(utc);
-
export default function reactions({ store, apolloClient }: ProcessContext) {
const { $calculation, $tables } = store;
@@ -23,7 +20,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
return;
}
- const currentDate = dayjs().utc(false).toISOString();
+ const currentDate = getCurrentISODate();
const {
data: { evo_addproduct_types },
@@ -80,7 +77,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
reaction(
() => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType']),
async ({ leasingPeriod, leaseObjectType }) => {
- const currentDate = dayjs().utc(false).toISOString();
+ const currentDate = getCurrentISODate();
const {
data: { evo_addproduct_types },
@@ -164,7 +161,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
leasingPeriod,
plPriceRub,
}) => {
- const currentDate = dayjs().utc(false).toISOString();
+ const currentDate = getCurrentISODate();
const {
data: { evo_addproduct_types },
@@ -277,7 +274,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
leaseObjectType: leaseObjectTypeId,
engineType,
}) => {
- const currentDate = dayjs().utc(false).toISOString();
+ const currentDate = getCurrentISODate();
const {
data: { evo_addproduct_types: trackerTypes },
} = await apolloClient.query({
diff --git a/apps/web/process/bonuses/lib/helper.ts b/apps/web/process/bonuses/lib/helper.ts
index 902cc99..ae1c09e 100644
--- a/apps/web/process/bonuses/lib/helper.ts
+++ b/apps/web/process/bonuses/lib/helper.ts
@@ -1,7 +1,7 @@
import type { ValidationContext } from '../../types';
import type { ElementsTypes } from '@/Components/Calculation/config/map/values';
import * as CRMTypes from '@/graphql/crm.types';
-import dayjs from 'dayjs';
+import { getCurrentISODate } from '@/utils/date';
export type ProductId = ElementsTypes['selectProduct'];
@@ -25,7 +25,7 @@ export default function helper({ apolloClient, user }: ValidationContext) {
return null;
}
- const currentDate = dayjs().utc(false).toISOString();
+ const currentDate = getCurrentISODate();
const {
data: { evo_coefficients },
diff --git a/apps/web/process/bonuses/reactions/common.ts b/apps/web/process/bonuses/reactions/common.ts
index dae1f5e..da6f546 100644
--- a/apps/web/process/bonuses/reactions/common.ts
+++ b/apps/web/process/bonuses/reactions/common.ts
@@ -2,13 +2,9 @@ import type { ProcessContext } from '../../types';
import helper from '../lib/helper';
import * as CRMTypes from '@/graphql/crm.types';
import { disposableReaction } from '@/utils/mobx';
-import dayjs from 'dayjs';
-import utc from 'dayjs/plugin/utc';
import { reaction } from 'mobx';
import { round } from 'tools';
-dayjs.extend(utc);
-
export default function reactions(context: ProcessContext) {
const { store, apolloClient } = context;
const { $calculation, $process } = store;
diff --git a/apps/web/process/configurator/lib/helper.ts b/apps/web/process/configurator/lib/helper.ts
index f773a2d..e8b7307 100644
--- a/apps/web/process/configurator/lib/helper.ts
+++ b/apps/web/process/configurator/lib/helper.ts
@@ -3,6 +3,7 @@ import defaultValues from '@/config/default-values';
import * as CRMTypes from '@/graphql/crm.types';
import type { ProcessContext } from '@/process/types';
import type { CalculationValues } from '@/stores/calculation/values/types';
+import { getCurrentISODate } from '@/utils/date';
import dayjs from 'dayjs';
import { first, sort } from 'radash';
@@ -79,7 +80,7 @@ export default function helper({ apolloClient }: Pick $calculation.element('selectQuote').getValue(),
async (quoteId) => {
- const currentDate = dayjs().utc(false).toISOString();
+ const currentDate = getCurrentISODate();
let {
data: { evo_baseproducts },
diff --git a/apps/web/process/configurator/reactions/values.ts b/apps/web/process/configurator/reactions/values.ts
index a7b22f9..bc8f10b 100644
--- a/apps/web/process/configurator/reactions/values.ts
+++ b/apps/web/process/configurator/reactions/values.ts
@@ -4,12 +4,8 @@ import * as CRMTypes from '@/graphql/crm.types';
import type { ProcessContext } from '@/process/types';
import { normalizeOptions } from '@/utils/entity';
import { disposableDebouncedReaction, disposableReaction } from '@/utils/mobx';
-import dayjs from 'dayjs';
-import utc from 'dayjs/plugin/utc';
import { comparer, reaction } from 'mobx';
-dayjs.extend(utc);
-
export default function valuesReactions({ store, apolloClient, trpcClient }: ProcessContext) {
let abortController = new AbortController();
const { $calculation, $process } = store;
diff --git a/apps/web/process/fingap/lib/helper.ts b/apps/web/process/fingap/lib/helper.ts
index db3156a..a6ddb66 100644
--- a/apps/web/process/fingap/lib/helper.ts
+++ b/apps/web/process/fingap/lib/helper.ts
@@ -6,8 +6,8 @@ import { STALE_TIME } from '@/constants/request';
import * as CRMTypes from '@/graphql/crm.types';
import type { ProcessContext } from '@/process/types';
import type { CalculationValues } from '@/stores/calculation/values/types';
+import { getCurrentISODate } from '@/utils/date';
import type { QueryFunctionContext } from '@tanstack/react-query';
-import dayjs from 'dayjs';
import { flatten } from 'tools/object';
type GetFingapRisksInputValues = Pick<
@@ -38,7 +38,7 @@ export default function helper({
} = await apolloClient.query({
query: CRMTypes.GetAddproductTypesDocument,
variables: {
- currentDate: dayjs().utc(false).toISOString(),
+ currentDate: getCurrentISODate(),
},
});
diff --git a/apps/web/process/fingap/reactions/common.ts b/apps/web/process/fingap/reactions/common.ts
index 5012196..11d2fe2 100644
--- a/apps/web/process/fingap/reactions/common.ts
+++ b/apps/web/process/fingap/reactions/common.ts
@@ -1,12 +1,8 @@
import helper from '../lib/helper';
import type { ProcessContext } from '@/process/types';
import { disposableReaction } from '@/utils/mobx';
-import dayjs from 'dayjs';
-import utc from 'dayjs/plugin/utc';
import { comparer, reaction } from 'mobx';
-dayjs.extend(utc);
-
export default function reactions({ store, apolloClient, queryClient }: ProcessContext) {
const { getFingapRisks } = helper({ apolloClient, queryClient });
diff --git a/apps/web/process/gibdd/reactions.ts b/apps/web/process/gibdd/reactions.ts
index b41a24e..7bd56af 100644
--- a/apps/web/process/gibdd/reactions.ts
+++ b/apps/web/process/gibdd/reactions.ts
@@ -6,14 +6,12 @@ import { getTransTax } from '@/api/1c/query';
import { selectObjectCategoryTax } from '@/config/default-options';
import { STALE_TIME } from '@/constants/request';
import * as CRMTypes from '@/graphql/crm.types';
+import { getCurrentISODate } from '@/utils/date';
import { normalizeOptions } from '@/utils/entity';
import { disposableReaction } from '@/utils/mobx';
import dayjs from 'dayjs';
-import utc from 'dayjs/plugin/utc';
import { reaction } from 'mobx';
-dayjs.extend(utc);
-
export function common({ store, apolloClient, queryClient }: ProcessContext) {
const { $calculation, $process } = store;
@@ -239,8 +237,6 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
leaseObjectType,
// eslint-disable-next-line sonarjs/cognitive-complexity
}) => {
- const currentDate = dayjs().utc(false).toISOString();
-
let evo_region: CRMTypes.GetRegionQuery['evo_region'];
if (objectRegionRegistrationId) {
const { data } = await apolloClient.query({
@@ -254,7 +250,7 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
data: { evo_addproduct_types },
} = await apolloClient.query({
query: CRMTypes.GetRegistrationTypesDocument,
- variables: { currentDate },
+ variables: { currentDate: getCurrentISODate() },
});
const options = evo_addproduct_types?.filter((x) => {
diff --git a/apps/web/process/hooks/init/get-initial-data.ts b/apps/web/process/hooks/init/get-initial-data.ts
index ad75012..e929acb 100644
--- a/apps/web/process/hooks/init/get-initial-data.ts
+++ b/apps/web/process/hooks/init/get-initial-data.ts
@@ -1,8 +1,8 @@
import type { User } from '@/api/user/types';
import { crmTools } from '@/graphql/crm.tools';
import * as CRMTypes from '@/graphql/crm.types';
+import { getCurrentISODate } from '@/utils/date';
import type { ApolloClient } from '@apollo/client';
-import dayjs from 'dayjs';
export async function getInitialData({ query }: ApolloClient