From 2b1820f78d37e015ae2f2cfebfec8802813c3c18 Mon Sep 17 00:00:00 2001 From: Rinat Arsaev <11846445+A77AY@users.noreply.github.com> Date: Wed, 10 Jan 2024 17:49:48 +0700 Subject: [PATCH] TD-835: Remove swag-questionary-aggr-proxy (#160) --- .prettierrc.js | 2 +- cspell.json | 3 - package-lock.json | 13 -- package.json | 1 - .../questionary-aggr-proxy/dadata.service.ts | 29 ---- src/app/api/questionary-aggr-proxy/index.ts | 4 - .../kontur-focus.service.ts | 61 ------- .../questionary-aggr-proxy.module.ts | 16 -- ...reate-individual-entity-registered-name.ts | 3 - .../utils/get-address.ts | 20 --- .../api/questionary-aggr-proxy/utils/index.ts | 7 - .../utils/is-req-individual-entity.ts | 7 - .../utils/is-req-legal-entity.ts | 5 - .../utils/suggest-request.ts | 32 ---- .../utils/suggest-response.ts | 37 ----- .../utils/suggestion.ts | 4 - src/app/app.module.ts | 2 - src/app/dadata/_dadata-theme.scss | 27 --- src/app/dadata/dadata.component.html | 25 --- src/app/dadata/dadata.component.scss | 7 - src/app/dadata/dadata.component.ts | 156 ------------------ src/app/dadata/dadata.module.ts | 30 ---- src/app/dadata/highlight.pipe.ts | 29 ---- src/app/dadata/index.ts | 1 - src/app/dadata/type.ts | 2 - .../new-contractor-form.component.html | 6 - .../new-contractor-form.component.ts | 72 +------- .../russian-bank-account-form.component.html | 7 - .../russian-bank-account-form.component.ts | 10 -- .../create-russian-shop-entity.module.ts | 2 - src/assets/i18n/components/en.json | 6 +- src/assets/i18n/components/ru.json | 6 +- src/styles/dsh/_theme.scss | 2 - src/styles/dsh/_typography.scss | 2 - 34 files changed, 8 insertions(+), 628 deletions(-) delete mode 100644 src/app/api/questionary-aggr-proxy/dadata.service.ts delete mode 100644 src/app/api/questionary-aggr-proxy/index.ts delete mode 100644 src/app/api/questionary-aggr-proxy/kontur-focus.service.ts delete mode 100644 src/app/api/questionary-aggr-proxy/questionary-aggr-proxy.module.ts delete mode 100644 src/app/api/questionary-aggr-proxy/utils/create-individual-entity-registered-name.ts delete mode 100644 src/app/api/questionary-aggr-proxy/utils/get-address.ts delete mode 100644 src/app/api/questionary-aggr-proxy/utils/index.ts delete mode 100644 src/app/api/questionary-aggr-proxy/utils/is-req-individual-entity.ts delete mode 100644 src/app/api/questionary-aggr-proxy/utils/is-req-legal-entity.ts delete mode 100644 src/app/api/questionary-aggr-proxy/utils/suggest-request.ts delete mode 100644 src/app/api/questionary-aggr-proxy/utils/suggest-response.ts delete mode 100644 src/app/api/questionary-aggr-proxy/utils/suggestion.ts delete mode 100644 src/app/dadata/_dadata-theme.scss delete mode 100644 src/app/dadata/dadata.component.html delete mode 100644 src/app/dadata/dadata.component.scss delete mode 100644 src/app/dadata/dadata.component.ts delete mode 100644 src/app/dadata/dadata.module.ts delete mode 100644 src/app/dadata/highlight.pipe.ts delete mode 100644 src/app/dadata/index.ts delete mode 100644 src/app/dadata/type.ts diff --git a/.prettierrc.js b/.prettierrc.js index 3cee9524..9f81c84c 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1 +1 @@ -module.exports = require("@vality/prettier-config"); +module.exports = require('@vality/prettier-config'); diff --git a/cspell.json b/cspell.json index 579c7c0b..d25b329a 100644 --- a/cspell.json +++ b/cspell.json @@ -7,8 +7,6 @@ "transloco", "xrequest", "klass", - "aggr", - "kontur", "unflat", "datepicker", "autoselect", @@ -28,7 +26,6 @@ "actionbar", "topo", "toponim", - "dadata", "unlim", "apikeys", "anapi", diff --git a/package-lock.json b/package-lock.json index 6b746ea6..5a8bc68c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,6 @@ "@vality/swag-claim-management": "0.1.1-7a03f9b.0", "@vality/swag-organizations": "1.0.1-cd6cc10.0", "@vality/swag-payments": "0.1.1-01da4bb.0", - "@vality/swag-questionary-aggr-proxy": "0.1.1-ed41741.0", "@vality/swag-url-shortener": "0.1.1-f780d07.0", "@vality/swag-wallet": "0.1.3-6c7361c.0", "angular-file": "^3.0.1", @@ -6538,18 +6537,6 @@ "@angular/core": "^13.0.0" } }, - "node_modules/@vality/swag-questionary-aggr-proxy": { - "version": "0.1.1-ed41741.0", - "resolved": "https://registry.npmjs.org/@vality/swag-questionary-aggr-proxy/-/swag-questionary-aggr-proxy-0.1.1-ed41741.0.tgz", - "integrity": "sha512-Zm2DINHuG4xP+rmxWo2yvRHpkf84hNBS7giuE5AHw/zYPXiKG+9FiQxKYpU6g3OB4geZZWkt4lWLYgVwfcFFfQ==", - "dependencies": { - "tslib": "^2.3.0" - }, - "peerDependencies": { - "@angular/common": "^13.0.0", - "@angular/core": "^13.0.0" - } - }, "node_modules/@vality/swag-url-shortener": { "version": "0.1.1-f780d07.0", "resolved": "https://registry.npmjs.org/@vality/swag-url-shortener/-/swag-url-shortener-0.1.1-f780d07.0.tgz", diff --git a/package.json b/package.json index e0c8ef99..59b55048 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,6 @@ "@vality/swag-claim-management": "0.1.1-7a03f9b.0", "@vality/swag-organizations": "1.0.1-cd6cc10.0", "@vality/swag-payments": "0.1.1-01da4bb.0", - "@vality/swag-questionary-aggr-proxy": "0.1.1-ed41741.0", "@vality/swag-url-shortener": "0.1.1-f780d07.0", "@vality/swag-wallet": "0.1.3-6c7361c.0", "angular-file": "^3.0.1", diff --git a/src/app/api/questionary-aggr-proxy/dadata.service.ts b/src/app/api/questionary-aggr-proxy/dadata.service.ts deleted file mode 100644 index 3cc6a2c9..00000000 --- a/src/app/api/questionary-aggr-proxy/dadata.service.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Injectable } from '@angular/core'; -import { - DaDataService as ApiDaDataService, - DaDataRequest, -} from '@vality/swag-questionary-aggr-proxy'; -import { Observable } from 'rxjs'; -import { pluck } from 'rxjs/operators'; - -import { createApi } from '../utils'; - -import { ParamsByRequestType, ResponseByRequestType, SuggestionsByRequestType } from './utils'; - -type RequestType = DaDataRequest.DaDataRequestTypeEnum; - -@Injectable({ - providedIn: 'root', -}) -export class DaDataService extends createApi(ApiDaDataService) { - suggest( - daDataRequestType: T, - params: ParamsByRequestType[T], - ): Observable { - const requestParams = { request: { daDataRequestType, ...params } }; - const request = this.requestDaData({ daDataParams: requestParams }) as Observable< - ResponseByRequestType[T] - >; - return request.pipe(pluck('suggestions')) as Observable; - } -} diff --git a/src/app/api/questionary-aggr-proxy/index.ts b/src/app/api/questionary-aggr-proxy/index.ts deleted file mode 100644 index 3581a310..00000000 --- a/src/app/api/questionary-aggr-proxy/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './questionary-aggr-proxy.module'; -export * from './kontur-focus.service'; -export * from './utils'; -export * from './dadata.service'; diff --git a/src/app/api/questionary-aggr-proxy/kontur-focus.service.ts b/src/app/api/questionary-aggr-proxy/kontur-focus.service.ts deleted file mode 100644 index 3e47cb02..00000000 --- a/src/app/api/questionary-aggr-proxy/kontur-focus.service.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Injectable } from '@angular/core'; -import { - KonturFocusService as ApiKonturFocusService, - BeneficialOwnerQuery, - BeneficialOwnerResponses, - EgrDetailsQuery, - EgrDetailsResponses, - KonturFocusRequest, - KonturFocusResponse, - LicencesQuery, - LicencesResponses, - ReqQuery, - ReqResponses, -} from '@vality/swag-questionary-aggr-proxy'; -import { Observable } from 'rxjs'; -import { pluck } from 'rxjs/operators'; - -import { Mapping } from '../../../type-utils'; -import { createApi } from '../utils'; - -type RequestType = KonturFocusRequest.KonturFocusRequestTypeEnum; - -type ParamsByRequestType = Mapping< - RequestType, - KonturFocusRequest, - { - /* eslint-disable @typescript-eslint/naming-convention */ - ReqQuery: ReqQuery; - EgrDetailsQuery: EgrDetailsQuery; - LicencesQuery: LicencesQuery; - BeneficialOwnerQuery: BeneficialOwnerQuery; - /* eslint-enable @typescript-eslint/naming-convention */ - } ->; - -export type ResponsesByRequestType = Mapping< - RequestType, - KonturFocusResponse, - { - /* eslint-disable @typescript-eslint/naming-convention */ - ReqQuery: ReqResponses; - EgrDetailsQuery: EgrDetailsResponses; - LicencesQuery: LicencesResponses; - BeneficialOwnerQuery: BeneficialOwnerResponses; - /* eslint-enable @typescript-eslint/naming-convention */ - } ->; - -@Injectable({ - providedIn: 'root', -}) -export class KonturFocusService extends createApi(ApiKonturFocusService) { - request( - konturFocusRequestType: T, - requestParams: Partial>, - ): Observable { - return this.requestKonturFocus({ - konturFocusParams: { request: { konturFocusRequestType, ...requestParams } }, - }).pipe(pluck('responses')); - } -} diff --git a/src/app/api/questionary-aggr-proxy/questionary-aggr-proxy.module.ts b/src/app/api/questionary-aggr-proxy/questionary-aggr-proxy.module.ts deleted file mode 100644 index 2fccc965..00000000 --- a/src/app/api/questionary-aggr-proxy/questionary-aggr-proxy.module.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { NgModule } from '@angular/core'; -import { Configuration } from '@vality/swag-questionary-aggr-proxy'; - -import { ConfigService } from '../../config'; - -@NgModule({ - providers: [ - { - provide: Configuration, - deps: [ConfigService], - useFactory: (configService: ConfigService) => - new Configuration({ basePath: `${configService.apiEndpoint}/dark-api/v1` }), - }, - ], -}) -export class QuestionaryAggrProxyModule {} diff --git a/src/app/api/questionary-aggr-proxy/utils/create-individual-entity-registered-name.ts b/src/app/api/questionary-aggr-proxy/utils/create-individual-entity-registered-name.ts deleted file mode 100644 index f2410f80..00000000 --- a/src/app/api/questionary-aggr-proxy/utils/create-individual-entity-registered-name.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function createIndividualEntityRegisteredName(fio: string): string { - return `ИП ${fio}`; -} diff --git a/src/app/api/questionary-aggr-proxy/utils/get-address.ts b/src/app/api/questionary-aggr-proxy/utils/get-address.ts deleted file mode 100644 index dfc6e647..00000000 --- a/src/app/api/questionary-aggr-proxy/utils/get-address.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { ParsedAddressRF, Toponim } from '@vality/swag-questionary-aggr-proxy'; - -function getAddressPart(toponim: Toponim): string { - return [toponim?.topoShortName, toponim?.topoValue].filter(Boolean).join(' '); -} - -export function getAddress(address: ParsedAddressRF): string { - return [ - getAddressPart(address.regionName), - getAddressPart(address.district), - getAddressPart(address.city), - getAddressPart(address.settlement), - getAddressPart(address.street), - getAddressPart(address.bulk), - getAddressPart(address.house), - getAddressPart(address.flat), - ] - .filter((v) => !!v) - .join(', '); -} diff --git a/src/app/api/questionary-aggr-proxy/utils/index.ts b/src/app/api/questionary-aggr-proxy/utils/index.ts deleted file mode 100644 index 60d05da1..00000000 --- a/src/app/api/questionary-aggr-proxy/utils/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './is-req-individual-entity'; -export * from './is-req-legal-entity'; -export * from './get-address'; -export * from './create-individual-entity-registered-name'; -export * from './suggestion'; -export * from './suggest-request'; -export * from './suggest-response'; diff --git a/src/app/api/questionary-aggr-proxy/utils/is-req-individual-entity.ts b/src/app/api/questionary-aggr-proxy/utils/is-req-individual-entity.ts deleted file mode 100644 index 533de467..00000000 --- a/src/app/api/questionary-aggr-proxy/utils/is-req-individual-entity.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ReqContractor, ReqIndividualEntity } from '@vality/swag-questionary-aggr-proxy'; - -export function isReqIndividualEntity( - contractor: ReqContractor, -): contractor is ReqIndividualEntity { - return contractor.reqContractorType === 'ReqIndividualEntity'; -} diff --git a/src/app/api/questionary-aggr-proxy/utils/is-req-legal-entity.ts b/src/app/api/questionary-aggr-proxy/utils/is-req-legal-entity.ts deleted file mode 100644 index 94485bd6..00000000 --- a/src/app/api/questionary-aggr-proxy/utils/is-req-legal-entity.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ReqContractor, ReqLegalEntity } from '@vality/swag-questionary-aggr-proxy'; - -export function isReqLegalEntity(contractor: ReqContractor): contractor is ReqLegalEntity { - return contractor.reqContractorType === 'ReqLegalEntity'; -} diff --git a/src/app/api/questionary-aggr-proxy/utils/suggest-request.ts b/src/app/api/questionary-aggr-proxy/utils/suggest-request.ts deleted file mode 100644 index b74516e8..00000000 --- a/src/app/api/questionary-aggr-proxy/utils/suggest-request.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { - AddressQuery, - BankQuery, - DaDataRequest, - FioQuery, - FmsUnitQuery, - OkvedQuery, - PartyQuery, -} from '@vality/swag-questionary-aggr-proxy'; - -import { Mapping } from '@dsh/type-utils'; - -type RequestType = DaDataRequest.DaDataRequestTypeEnum; - -type FullParamsByRequestType = Mapping< - RequestType, - DaDataRequest, - { - /* eslint-disable @typescript-eslint/naming-convention */ - AddressQuery: AddressQuery; - BankQuery: BankQuery; - FioQuery: FioQuery; - FmsUnitQuery: FmsUnitQuery; - OkvedQuery: OkvedQuery; - PartyQuery: PartyQuery; - /* eslint-enable @typescript-eslint/naming-convention */ - } ->; - -export type ParamsByRequestType = { - [name in RequestType]: Omit; -}; diff --git a/src/app/api/questionary-aggr-proxy/utils/suggest-response.ts b/src/app/api/questionary-aggr-proxy/utils/suggest-response.ts deleted file mode 100644 index 922747e7..00000000 --- a/src/app/api/questionary-aggr-proxy/utils/suggest-response.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { - AddressResponse, - BankResponse, - DaDataRequest, - DaDataResponse, - FioResponse, - FmsUnitResponse, - OkvedResponse, - PartyResponse, -} from '@vality/swag-questionary-aggr-proxy'; - -import { Mapping } from '@dsh/type-utils'; - -type RequestType = DaDataRequest.DaDataRequestTypeEnum; - -export type ResponseByRequestType = Mapping< - RequestType, - DaDataResponse, - { - /* eslint-disable @typescript-eslint/naming-convention */ - AddressQuery: AddressResponse; - BankQuery: BankResponse; - FioQuery: FioResponse; - FmsUnitQuery: FmsUnitResponse; - OkvedQuery: OkvedResponse; - PartyQuery: PartyResponse; - /* eslint-enable @typescript-eslint/naming-convention */ - } ->; - -export type SuggestionsByRequestType = { - [name in RequestType]: ResponseByRequestType[name]['suggestions']; -}; - -export type ContentByRequestType = { - [name in RequestType]: SuggestionsByRequestType[name][number]; -}; diff --git a/src/app/api/questionary-aggr-proxy/utils/suggestion.ts b/src/app/api/questionary-aggr-proxy/utils/suggestion.ts deleted file mode 100644 index ee0fda2d..00000000 --- a/src/app/api/questionary-aggr-proxy/utils/suggestion.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface Suggestion { - value?: string; - unrestrictedValue?: string; -} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 27157813..301d270a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -29,7 +29,6 @@ import * as Sentry from '@sentry/angular-ivy'; import { AnapiModule } from '@dsh/app/api/anapi'; import { ClaimManagementModule } from '@dsh/app/api/claim-management'; import { PaymentsModule } from '@dsh/app/api/payments'; -import { QuestionaryAggrProxyModule } from '@dsh/app/api/questionary-aggr-proxy'; import { UrlShortenerModule } from '@dsh/app/api/url-shortener'; import { WalletModule } from '@dsh/app/api/wallet'; import { ErrorModule } from '@dsh/app/shared/services'; @@ -75,7 +74,6 @@ import { TranslocoHttpLoaderService } from './transloco-http-loader.service'; PaymentsModule, OrganizationsModule, UrlShortenerModule, - QuestionaryAggrProxyModule, WalletModule, SpinnerModule, ApiKeysModule, diff --git a/src/app/dadata/_dadata-theme.scss b/src/app/dadata/_dadata-theme.scss deleted file mode 100644 index 76449dc8..00000000 --- a/src/app/dadata/_dadata-theme.scss +++ /dev/null @@ -1,27 +0,0 @@ -@use '@angular/material' as mat; - -@mixin dsh-dadata-autocomplete-theme($theme) { - $primary: map-get($theme, primary); - - .dsh-dadata-autocomplete-mark { - background-color: mat.get-color-from-palette($primary, 100); - } -} - -@mixin dsh-dadata-autocomplete-typography($config) { - .dsh-dadata-autocomplete-option-header { - font: { - family: mat.font-family($config, body-1); - size: mat.font-size($config, body-1); - weight: mat.font-weight($config, body-1); - } - } - - .dsh-dadata-autocomplete-option-description { - font: { - family: mat.font-family($config, caption); - size: mat.font-size($config, caption); - weight: mat.font-weight($config, caption); - } - } -} diff --git a/src/app/dadata/dadata.component.html b/src/app/dadata/dadata.component.html deleted file mode 100644 index cd1db717..00000000 --- a/src/app/dadata/dadata.component.html +++ /dev/null @@ -1,25 +0,0 @@ - - {{ label }} - - - - -
-
-
-
-
- -
diff --git a/src/app/dadata/dadata.component.scss b/src/app/dadata/dadata.component.scss deleted file mode 100644 index 2ffe2d7f..00000000 --- a/src/app/dadata/dadata.component.scss +++ /dev/null @@ -1,7 +0,0 @@ -.field { - width: 100%; -} - -.option { - line-height: 1.4; -} diff --git a/src/app/dadata/dadata.component.ts b/src/app/dadata/dadata.component.ts deleted file mode 100644 index e0500876..00000000 --- a/src/app/dadata/dadata.component.ts +++ /dev/null @@ -1,156 +0,0 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete'; -import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import { FormControlSuperclass, createControlProviders } from '@vality/ng-core'; -import { - BankContent, - DaDataRequest, - FmsUnitContent, - FmsUnitQuery, - PartyContent, -} from '@vality/swag-questionary-aggr-proxy'; -import { coerceBoolean } from 'coerce-property'; -import isEmpty from 'lodash-es/isEmpty'; -import { interval, Observable } from 'rxjs'; -import { debounce, filter, map, switchMap, take } from 'rxjs/operators'; - -import { - ContentByRequestType, - DaDataService, - ParamsByRequestType, - Suggestion, -} from '@dsh/app/api/questionary-aggr-proxy'; -import { progress, shareReplayUntilDestroyed, takeError } from '@dsh/app/custom-operators'; - -import { Type } from './type'; - -import DaDataRequestType = DaDataRequest.DaDataRequestTypeEnum; - -interface Option { - label: string; - description: string; - value: S; -} - -type RequestTypeByType = { [name in Type]: DaDataRequestType }; -const REQUEST_TYPE_BY_TYPE: RequestTypeByType = { - address: DaDataRequestType.AddressQuery, - bank: DaDataRequestType.BankQuery, - fio: DaDataRequestType.FioQuery, - fmsUnit: DaDataRequestType.FmsUnitQuery, - okved: DaDataRequestType.OkvedQuery, - party: DaDataRequestType.PartyQuery, -}; - -@UntilDestroy() -@Component({ - selector: 'dsh-dadata-autocomplete', - styleUrls: ['dadata.component.scss'], - templateUrl: 'dadata.component.html', - providers: createControlProviders(() => DaDataAutocompleteComponent), -}) -export class DaDataAutocompleteComponent< - T extends Type = Type, - R extends DaDataRequestType = RequestTypeByType[T], - > - extends FormControlSuperclass - implements OnInit -{ - @Input() type: T; - @Input() params: ParamsByRequestType[R]; - @Input() label: string; - @Input() @coerceBoolean required = false; - - @Output() optionSelected = new EventEmitter(); - @Output() errorOccurred = new EventEmitter(); - @Output() suggestionNotFound = new EventEmitter(); - - suggestions$: Observable = this.control.valueChanges.pipe( - filter(Boolean), - debounce(() => interval(300)), - switchMap((v) => this.loadSuggestions(v)), - shareReplayUntilDestroyed(this), - ); - options$: Observable[]> = this.suggestions$.pipe( - map((suggestions) => suggestions.map((s) => this.getOption(s))), - shareReplayUntilDestroyed(this), - ); - isOptionsLoading$: Observable = progress( - this.control.valueChanges, - this.suggestions$, - ).pipe(shareReplayUntilDestroyed(this)); - - constructor(private daDataService: DaDataService) { - super(); - } - - ngOnInit(): void { - this.isOptionsLoading$.pipe(untilDestroyed(this)).subscribe(); - this.suggestions$ - .pipe(filter(isEmpty), untilDestroyed(this)) - .subscribe(() => this.suggestionNotFound.emit()); - this.suggestions$ - .pipe(takeError, untilDestroyed(this)) - .subscribe((error) => this.errorOccurred.next(error)); - } - - optionSelectedHandler(e: MatAutocompleteSelectedEvent): void { - const idx = e.source.options.toArray().findIndex((option) => option === e.option); - this.options$ - .pipe(take(1), untilDestroyed(this)) - .subscribe((options) => this.optionSelected.next(options[idx].value)); - } - - clear(): void { - this.control.setValue(''); - this.optionSelected.emit(null); - } - - private loadSuggestions(query: string): Observable { - const params: ParamsByRequestType[R] = { query } as ParamsByRequestType[R]; - return this.daDataService.suggest( - REQUEST_TYPE_BY_TYPE[this.type], - this.withSpecificParams(params), - ) as unknown as Observable; - } - - private withSpecificParams(params: ParamsByRequestType[R]): ParamsByRequestType[R] { - switch (this.type) { - case 'fmsUnit': { - const fmsUnitParams = { ...params } as FmsUnitQuery; - fmsUnitParams.queryType = 'FullTextSearch'; - return fmsUnitParams; - } - default: - return params; - } - } - - private getOption(suggestion: ContentByRequestType[R]): Option { - return { - label: suggestion.value || '', - description: this.getDescription(suggestion), - value: suggestion, - }; - } - - private getDescription(suggestion: ContentByRequestType[R]): string { - switch (this.type) { - case 'bank': { - const { bic, address } = suggestion as BankContent; - return [bic, address?.value].filter(Boolean).join(' '); - } - case 'party': { - const { inn, ogrn, address } = suggestion as PartyContent; - const innOGRN = [inn, ogrn].filter(Boolean).join('/'); - return [innOGRN, address?.value].filter(Boolean).join(' '); - } - case 'fmsUnit': { - const { code } = suggestion as FmsUnitContent; - return code; - } - default: - return ''; - } - } -} diff --git a/src/app/dadata/dadata.module.ts b/src/app/dadata/dadata.module.ts deleted file mode 100644 index 1e83db5f..00000000 --- a/src/app/dadata/dadata.module.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { HttpClientModule } from '@angular/common/http'; -import { NgModule } from '@angular/core'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { MatAutocompleteModule } from '@angular/material/autocomplete'; -import { MatButtonModule } from '@angular/material/button'; -import { MatInputModule } from '@angular/material/input'; - -import { FormControlsModule } from '@dsh/components/form-controls'; -import { BootstrapIconModule } from '@dsh/components/indicators'; - -import { DaDataAutocompleteComponent } from './dadata.component'; -import { HighlightSearchPipe } from './highlight.pipe'; - -@NgModule({ - imports: [ - HttpClientModule, - MatAutocompleteModule, - CommonModule, - FormsModule, - ReactiveFormsModule, - MatInputModule, - FormControlsModule, - BootstrapIconModule, - MatButtonModule, - ], - declarations: [DaDataAutocompleteComponent, HighlightSearchPipe], - exports: [DaDataAutocompleteComponent], -}) -export class DaDataModule {} diff --git a/src/app/dadata/highlight.pipe.ts b/src/app/dadata/highlight.pipe.ts deleted file mode 100644 index 86bb9ad5..00000000 --- a/src/app/dadata/highlight.pipe.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; - -@Pipe({ - name: 'highlight', -}) -export class HighlightSearchPipe implements PipeTransform { - constructor(private sanitizer: DomSanitizer) {} - - transform(value: string, args: string): SafeHtml { - if (!args) { - return value; - } - - const re = new RegExp(args, 'gi'); - // eslint-disable-next-line @typescript-eslint/prefer-regexp-exec - const match = value.match(re); - - if (!match) { - return value; - } - - const replacedValue = value.replace( - re, - '' + match[0] + '', - ); - return this.sanitizer.bypassSecurityTrustHtml(replacedValue); - } -} diff --git a/src/app/dadata/index.ts b/src/app/dadata/index.ts deleted file mode 100644 index 51c37cde..00000000 --- a/src/app/dadata/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './dadata.module'; diff --git a/src/app/dadata/type.ts b/src/app/dadata/type.ts deleted file mode 100644 index a58f599b..00000000 --- a/src/app/dadata/type.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const TYPE = ['address', 'party', 'bank', 'fio', 'fmsUnit', 'okved'] as const; -export type Type = (typeof TYPE)[number]; diff --git a/src/app/shared/components/shop-creation/create-russian-shop-entity/components/new-contractor-form/new-contractor-form.component.html b/src/app/shared/components/shop-creation/create-russian-shop-entity/components/new-contractor-form/new-contractor-form.component.html index 40b47757..a79822f6 100644 --- a/src/app/shared/components/shop-creation/create-russian-shop-entity/components/new-contractor-form/new-contractor-form.component.html +++ b/src/app/shared/components/shop-creation/create-russian-shop-entity/components/new-contractor-form/new-contractor-form.component.html @@ -4,12 +4,6 @@ fxLayout="column" fxLayoutGap="16px" > - {{ p('form.registeredName') }} (''); - constructor( - private fb: FormBuilder, - private konturFocusService: KonturFocusService, - ) { + constructor(private fb: FormBuilder) { super(); } - - updateSuggestion(dadata: PartyContent): void { - if (!dadata) return this.control.patchValue(this.getFormByData()); - this.konturFocusService - .request('ReqQuery', { - inn: [dadata.inn], - }) - .pipe( - map(([kontur]): Partial => this.getFormByData(dadata, kontur)), - untilDestroyed(this), - ) - .subscribe( - (data) => this.control.patchValue(data), - (err) => { - console.error('Kontur.Focus API error', err); - this.control.patchValue(this.getFormByData(dadata)); - }, - ); - } - - private getFormByData(dadata?: PartyContent, kontur?: ReqResponse): Partial { - const result: Partial = { - inn: kontur?.inn || dadata?.inn || null, - registeredNumber: kontur?.ogrn || dadata?.ogrn || null, - registeredName: dadata?.name?.shortWithOpf || null, - actualAddress: null, - representativeFullName: null, - }; - if (dadata) { - if (dadata.orgType === OrgType.Individual) { - result.actualAddress = dadata.address?.value || result.actualAddress; - result.representativeFullName = - dadata.name?.fullName || result.representativeFullName; - } - } - if (kontur) { - if (isReqIndividualEntity(kontur.contractor)) { - result.registeredName = - createIndividualEntityRegisteredName(kontur.contractor.fio) || - result.registeredName; - result.representativeFullName = - kontur.contractor.fio || result.representativeFullName; - } - if (isReqLegalEntity(kontur.contractor)) { - result.registeredName = - kontur.contractor.legalName.shortName || result.registeredName; - result.actualAddress = - getAddress(kontur.contractor.legalAddress.addressRf) || result.actualAddress; - } - } - return result; - } } diff --git a/src/app/shared/components/shop-creation/create-russian-shop-entity/components/russian-bank-account-form/russian-bank-account-form.component.html b/src/app/shared/components/shop-creation/create-russian-shop-entity/components/russian-bank-account-form/russian-bank-account-form.component.html index b7db69dd..c9b8d733 100644 --- a/src/app/shared/components/shop-creation/create-russian-shop-entity/components/russian-bank-account-form/russian-bank-account-form.component.html +++ b/src/app/shared/components/shop-creation/create-russian-shop-entity/components/russian-bank-account-form/russian-bank-account-form.component.html @@ -4,13 +4,6 @@ fxLayout="column" fxLayoutGap="16px" > - -
{{ p('name') }} diff --git a/src/app/shared/components/shop-creation/create-russian-shop-entity/components/russian-bank-account-form/russian-bank-account-form.component.ts b/src/app/shared/components/shop-creation/create-russian-shop-entity/components/russian-bank-account-form/russian-bank-account-form.component.ts index c79acb76..3ae94d04 100644 --- a/src/app/shared/components/shop-creation/create-russian-shop-entity/components/russian-bank-account-form/russian-bank-account-form.component.ts +++ b/src/app/shared/components/shop-creation/create-russian-shop-entity/components/russian-bank-account-form/russian-bank-account-form.component.ts @@ -1,7 +1,6 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { FormBuilder } from '@angular/forms'; import { createControlProviders, FormGroupSuperclass } from '@vality/ng-core'; -import { BankContent } from '@vality/swag-questionary-aggr-proxy'; import { RussianBankAccountForm } from './types/bank-account-form-data'; @@ -20,17 +19,8 @@ export class RussianBankAccountFormComponent extends FormGroupSuperclass< bankPostAccount: null, bankBik: null, }); - searchControl = this.fb.control(''); constructor(private fb: FormBuilder) { super(); } - - bankSelected(bank: BankContent): void { - this.control.patchValue({ - bankName: bank?.value || null, - bankBik: bank?.bic || null, - bankPostAccount: bank?.correspondentAccount || null, - }); - } } diff --git a/src/app/shared/components/shop-creation/create-russian-shop-entity/create-russian-shop-entity.module.ts b/src/app/shared/components/shop-creation/create-russian-shop-entity/create-russian-shop-entity.module.ts index 35e1d28e..02aff5e2 100644 --- a/src/app/shared/components/shop-creation/create-russian-shop-entity/create-russian-shop-entity.module.ts +++ b/src/app/shared/components/shop-creation/create-russian-shop-entity/create-russian-shop-entity.module.ts @@ -22,7 +22,6 @@ import { ButtonModule } from '@dsh/components/buttons'; import { FormatInputModule } from '@dsh/components/form-controls'; import { DetailsItemModule } from '@dsh/components/layout'; -import { DaDataModule } from '../../../../dadata'; import { ShopPayoutToolDetailsService } from '../../../../sections/payment-section/shops/services/shop-payout-tool-details/shop-payout-tool-details.service'; import { CurrencyAutocompleteFieldModule } from '../../inputs/currency-autocomplete-field'; @@ -43,7 +42,6 @@ import { CreateRussianShopEntityService } from './services/create-russian-shop-e MatInputModule, MatDividerModule, MatRadioModule, - DaDataModule, FormatInputModule, MatSelectModule, PayoutToolDetailsModule, diff --git a/src/assets/i18n/components/en.json b/src/assets/i18n/components/en.json index 09a1d198..2605d77e 100644 --- a/src/assets/i18n/components/en.json +++ b/src/assets/i18n/components/en.json @@ -220,8 +220,7 @@ "registeredNumber": "OGRN/OGRNIP", "representativeDocument": "EEC/representative document", "representativeFullName": "EEC/representative full name", - "representativePosition": "Position of EEC/representative", - "search": "To search, enter the name of the legal entity, INN, OGRN/OGRNIP" + "representativePosition": "Position of EEC/representative" } }, "newInternationalContractorForm": { @@ -269,8 +268,7 @@ "account": "Operating account", "bik": "BIC", "name": "Name", - "postAccount": "Correspondent account", - "search": "For search, specify the name, BIC, SWIFT or TIN of the bank" + "postAccount": "Correspondent account" }, "select-active-organization-dialog": { "confirm": "Confirm", diff --git a/src/assets/i18n/components/ru.json b/src/assets/i18n/components/ru.json index a36da1cd..35dddf08 100644 --- a/src/assets/i18n/components/ru.json +++ b/src/assets/i18n/components/ru.json @@ -220,8 +220,7 @@ "registeredNumber": "ОГРН/ОГРНИП", "representativeDocument": "Документ ЕИО/представителя", "representativeFullName": "ФИО ЕИО/представителя", - "representativePosition": "Должность ЕИО/представителя", - "search": "Для поиска укажите название юр. лица, ИНН, ОГРН/ОГРНИП" + "representativePosition": "Должность ЕИО/представителя" } }, "newInternationalContractorForm": { @@ -269,8 +268,7 @@ "account": "Расчетный счет", "bik": "БИК", "name": "Наименование", - "postAccount": "Корреспондентский счет", - "search": "Для поиска укажите название, БИК, SWIFT или ИНН банка" + "postAccount": "Корреспондентский счет" }, "select-active-organization-dialog": { "confirm": "Подтвердить", diff --git a/src/styles/dsh/_theme.scss b/src/styles/dsh/_theme.scss index 184ee1f5..9932eb59 100644 --- a/src/styles/dsh/_theme.scss +++ b/src/styles/dsh/_theme.scss @@ -23,7 +23,6 @@ @import '../../app/home/home-theme'; @import '../../app/home/actionbar/actionbar-theme'; @import '../../app/home/mobile-grid/mobile-grid-theme'; -@import '../../app/dadata/dadata-theme'; @import '../../app/sections/payment-section/analytics/percent-difference/percent-difference-theme'; @import '../../app/sections/payment-section/analytics/stat-item/stat-item-theme'; @import '../../app/sections/payment-section/balances/balances-theme'; @@ -39,7 +38,6 @@ @include dsh-mobile-grid-theme($theme); @include dsh-button-theme($theme); @include dsh-status-theme($theme); - @include dsh-dadata-autocomplete-theme($theme); @include dsh-details-item-theme($theme); @include dsh-panel-theme($theme); @include dsh-bar-chart-theme($theme); diff --git a/src/styles/dsh/_typography.scss b/src/styles/dsh/_typography.scss index 9c267079..1ba11dff 100644 --- a/src/styles/dsh/_typography.scss +++ b/src/styles/dsh/_typography.scss @@ -20,7 +20,6 @@ @import '../../app/home/home-theme'; @import '../../app/home/mobile-grid/mobile-grid-theme'; -@import '../../app/dadata/dadata-theme'; @import '../../app/sections/payment-section/balances/balances-theme'; @import '../../app/sections/payment-section/no-shops-alert/no-shops-alert-theme'; @@ -30,7 +29,6 @@ @include dsh-state-nav-typography($config); @include dsh-card-typography($config); @include dsh-dropdown-typography($config); - @include dsh-dadata-autocomplete-typography($config); @include dsh-panel-typography($config); @include dsh-charts-typography($config); @include dsh-row-typography($config);