mirror of
https://github.com/valitydev/dashboard.git
synced 2024-11-06 02:25:23 +00:00
TD-835: Remove swag-questionary-aggr-proxy (#160)
This commit is contained in:
parent
fe6438f83c
commit
2b1820f78d
@ -1 +1 @@
|
||||
module.exports = require("@vality/prettier-config");
|
||||
module.exports = require('@vality/prettier-config');
|
||||
|
@ -7,8 +7,6 @@
|
||||
"transloco",
|
||||
"xrequest",
|
||||
"klass",
|
||||
"aggr",
|
||||
"kontur",
|
||||
"unflat",
|
||||
"datepicker",
|
||||
"autoselect",
|
||||
@ -28,7 +26,6 @@
|
||||
"actionbar",
|
||||
"topo",
|
||||
"toponim",
|
||||
"dadata",
|
||||
"unlim",
|
||||
"apikeys",
|
||||
"anapi",
|
||||
|
13
package-lock.json
generated
13
package-lock.json
generated
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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<T extends RequestType>(
|
||||
daDataRequestType: T,
|
||||
params: ParamsByRequestType[T],
|
||||
): Observable<SuggestionsByRequestType[T]> {
|
||||
const requestParams = { request: { daDataRequestType, ...params } };
|
||||
const request = this.requestDaData({ daDataParams: requestParams }) as Observable<
|
||||
ResponseByRequestType[T]
|
||||
>;
|
||||
return request.pipe(pluck('suggestions')) as Observable<SuggestionsByRequestType[T]>;
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
export * from './questionary-aggr-proxy.module';
|
||||
export * from './kontur-focus.service';
|
||||
export * from './utils';
|
||||
export * from './dadata.service';
|
@ -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<T extends RequestType>(
|
||||
konturFocusRequestType: T,
|
||||
requestParams: Partial<Omit<ParamsByRequestType[T], 'konturFocusRequestType'>>,
|
||||
): Observable<ResponsesByRequestType[T]['responses']> {
|
||||
return this.requestKonturFocus({
|
||||
konturFocusParams: { request: { konturFocusRequestType, ...requestParams } },
|
||||
}).pipe(pluck<ResponsesByRequestType[T], 'responses'>('responses'));
|
||||
}
|
||||
}
|
@ -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 {}
|
@ -1,3 +0,0 @@
|
||||
export function createIndividualEntityRegisteredName(fio: string): string {
|
||||
return `ИП ${fio}`;
|
||||
}
|
@ -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(', ');
|
||||
}
|
@ -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';
|
@ -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';
|
||||
}
|
@ -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';
|
||||
}
|
@ -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<FullParamsByRequestType[name], 'daDataRequestType'>;
|
||||
};
|
@ -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];
|
||||
};
|
@ -1,4 +0,0 @@
|
||||
export interface Suggestion {
|
||||
value?: string;
|
||||
unrestrictedValue?: string;
|
||||
}
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<mat-form-field class="field">
|
||||
<mat-label>{{ label }}</mat-label>
|
||||
<input [formControl]="control" [matAutocomplete]="auto" [required]="required" matInput />
|
||||
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="optionSelectedHandler($event)">
|
||||
<ng-container *ngIf="!(isOptionsLoading$ | async)">
|
||||
<mat-option
|
||||
*ngFor="let option of options$ | async"
|
||||
[value]="option.label"
|
||||
class="option"
|
||||
>
|
||||
<div
|
||||
[innerHTML]="option.label | highlight: control.value"
|
||||
class="dsh-dadata-autocomplete-option-header"
|
||||
></div>
|
||||
<div
|
||||
[innerHTML]="option.description | highlight: control.value"
|
||||
class="dsh-dadata-autocomplete-option-description"
|
||||
></div>
|
||||
</mat-option>
|
||||
</ng-container>
|
||||
</mat-autocomplete>
|
||||
<button *ngIf="control.value" mat-icon-button matSuffix (click)="clear()">
|
||||
<dsh-bi icon="x" size="lg"></dsh-bi>
|
||||
</button>
|
||||
</mat-form-field>
|
@ -1,7 +0,0 @@
|
||||
.field {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.option {
|
||||
line-height: 1.4;
|
||||
}
|
@ -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<S extends Suggestion> {
|
||||
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<string>
|
||||
implements OnInit
|
||||
{
|
||||
@Input() type: T;
|
||||
@Input() params: ParamsByRequestType[R];
|
||||
@Input() label: string;
|
||||
@Input() @coerceBoolean required = false;
|
||||
|
||||
@Output() optionSelected = new EventEmitter<ContentByRequestType[R]>();
|
||||
@Output() errorOccurred = new EventEmitter<unknown>();
|
||||
@Output() suggestionNotFound = new EventEmitter();
|
||||
|
||||
suggestions$: Observable<ContentByRequestType[R][]> = this.control.valueChanges.pipe(
|
||||
filter<string>(Boolean),
|
||||
debounce(() => interval(300)),
|
||||
switchMap((v) => this.loadSuggestions(v)),
|
||||
shareReplayUntilDestroyed(this),
|
||||
);
|
||||
options$: Observable<Option<ContentByRequestType[R]>[]> = this.suggestions$.pipe(
|
||||
map((suggestions) => suggestions.map((s) => this.getOption(s))),
|
||||
shareReplayUntilDestroyed(this),
|
||||
);
|
||||
isOptionsLoading$: Observable<boolean> = 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<ContentByRequestType[R][]> {
|
||||
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<ContentByRequestType[R][]>;
|
||||
}
|
||||
|
||||
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<ContentByRequestType[R]> {
|
||||
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 '';
|
||||
}
|
||||
}
|
||||
}
|
@ -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 {}
|
@ -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,
|
||||
'<mark class="dsh-dadata-autocomplete-mark">' + match[0] + '</mark>',
|
||||
);
|
||||
return this.sanitizer.bypassSecurityTrustHtml(replacedValue);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './dadata.module';
|
@ -1,2 +0,0 @@
|
||||
export const TYPE = ['address', 'party', 'bank', 'fio', 'fmsUnit', 'okved'] as const;
|
||||
export type Type = (typeof TYPE)[number];
|
@ -4,12 +4,6 @@
|
||||
fxLayout="column"
|
||||
fxLayoutGap="16px"
|
||||
>
|
||||
<dsh-dadata-autocomplete
|
||||
[formControl]="searchControl"
|
||||
[label]="p('form.search')"
|
||||
type="party"
|
||||
(optionSelected)="updateSuggestion($event)"
|
||||
></dsh-dadata-autocomplete>
|
||||
<mat-form-field>
|
||||
<mat-label>{{ p('form.registeredName') }}</mat-label>
|
||||
<input
|
||||
|
@ -1,17 +1,7 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { FormControl, FormBuilder } from '@angular/forms';
|
||||
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
||||
import { FormBuilder } from '@angular/forms';
|
||||
import { UntilDestroy } from '@ngneat/until-destroy';
|
||||
import { FormGroupSuperclass, createControlProviders } from '@vality/ng-core';
|
||||
import { PartyContent, ReqResponse, OrgType } from '@vality/swag-questionary-aggr-proxy';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import {
|
||||
KonturFocusService,
|
||||
createIndividualEntityRegisteredName,
|
||||
isReqLegalEntity,
|
||||
isReqIndividualEntity,
|
||||
getAddress,
|
||||
} from '@dsh/app/api/questionary-aggr-proxy';
|
||||
|
||||
import { RussianBankAccountForm } from '../russian-bank-account-form/types/bank-account-form-data';
|
||||
|
||||
@ -43,64 +33,8 @@ export class NewContractorFormComponent extends FormGroupSuperclass<Partial<NewC
|
||||
representativeDocument: null,
|
||||
bankAccount: null,
|
||||
});
|
||||
searchControl = new FormControl<string>('');
|
||||
|
||||
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<NewContractorForm> => 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<NewContractorForm> {
|
||||
const result: Partial<NewContractorForm> = {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,6 @@
|
||||
fxLayout="column"
|
||||
fxLayoutGap="16px"
|
||||
>
|
||||
<dsh-dadata-autocomplete
|
||||
[formControl]="searchControl"
|
||||
[label]="p('search')"
|
||||
type="bank"
|
||||
(optionSelected)="bankSelected($event)"
|
||||
></dsh-dadata-autocomplete>
|
||||
|
||||
<div gdColumns="1fr" gdColumns.gt-sm="1fr 1fr" gdGap="24px">
|
||||
<mat-form-field gdColumn="1/-1">
|
||||
<mat-label>{{ p('name') }}</mat-label>
|
||||
|
@ -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<string>('');
|
||||
|
||||
constructor(private fb: FormBuilder) {
|
||||
super();
|
||||
}
|
||||
|
||||
bankSelected(bank: BankContent): void {
|
||||
this.control.patchValue({
|
||||
bankName: bank?.value || null,
|
||||
bankBik: bank?.bic || null,
|
||||
bankPostAccount: bank?.correspondentAccount || null,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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",
|
||||
|
@ -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": "Подтвердить",
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user