diff --git a/package-lock.json b/package-lock.json index d9c14071..eb88ead2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,12 +29,12 @@ "@s-libs/ng-core": "14.0.0", "@s-libs/rxjs-core": "14.0.0", "@vality/deanonimus-proto": "1.0.1-c9a6cae.0", - "@vality/domain-proto": "1.0.1-3efe7df.0", + "@vality/domain-proto": "1.0.1-9362c08.0", "@vality/dominant-cache-proto": "1.0.1-5b29d81.0", "@vality/file-storage-proto": "1.0.1-447212b.0", "@vality/fistful-proto": "1.0.1-ea0fe7a.0", "@vality/machinegun-proto": "1.0.1-277f06e.0", - "@vality/magista-proto": "1.0.1-9f37374.0", + "@vality/magista-proto": "1.0.1-5352f74.0", "@vality/messages-proto": "1.0.1-8c5435c.0", "@vality/payout-manager-proto": "1.0.1-dbed280.0", "@vality/repairer-proto": "1.0.1-675b6f4.0", @@ -51,7 +51,7 @@ "lodash-es": "4.17.21", "moment": "2.29.4", "monaco-editor": "0.21.2", - "ngx-mat-select-search": "4.2.0", + "ngx-mat-select-search": "4.2.1", "rxjs": "7.5.4", "short-uuid": "4.1.0", "transliteration": "2.1.8", @@ -5470,9 +5470,9 @@ "integrity": "sha512-GjD4N6ZXyuYaGXv4od+lcCGKfIJFi640I6wJ3+O1eA9VrUI4Ro+Ljpu+TLjckMQ6nS1DkXuu+06Dk7Hr5nK1og==" }, "node_modules/@vality/domain-proto": { - "version": "1.0.1-3efe7df.0", - "resolved": "https://registry.npmjs.org/@vality/domain-proto/-/domain-proto-1.0.1-3efe7df.0.tgz", - "integrity": "sha512-cILZ0VttIGWLMRATT4/OblgACFraOn5Udnxhi6QiDPC3wd3wSm8YnHiOwFNx8HjydaSOw/5nzf5c+0G9gk27dA==" + "version": "1.0.1-9362c08.0", + "resolved": "https://registry.npmjs.org/@vality/domain-proto/-/domain-proto-1.0.1-9362c08.0.tgz", + "integrity": "sha512-B7JksaSacuNVNS/xyXa8IciOwIkh99vvME34482q1voMu4irVGRwCxovvpWcQKxfmEXoBvV5FTn1mkNNDiIWcA==" }, "node_modules/@vality/dominant-cache-proto": { "version": "1.0.1-5b29d81.0", @@ -5495,9 +5495,9 @@ "integrity": "sha512-qSotrFM8SY/rrfaIRWiyDFeu8ncMqPw8ohrerrGp5S+UZtGvqF0cHQiXytglK+fbAFJ0scyHgvSFBjc1bUtAzA==" }, "node_modules/@vality/magista-proto": { - "version": "1.0.1-9f37374.0", - "resolved": "https://registry.npmjs.org/@vality/magista-proto/-/magista-proto-1.0.1-9f37374.0.tgz", - "integrity": "sha512-jgcC0nrH1hZleK9rNgIcUUFmcj6mEK3aMb4h+oa2EWvTSxhSGcjmbGiGXYNnVnoWy+z3CeZoW3hcwGLPPXFieg==" + "version": "1.0.1-5352f74.0", + "resolved": "https://registry.npmjs.org/@vality/magista-proto/-/magista-proto-1.0.1-5352f74.0.tgz", + "integrity": "sha512-lpTKcF/61zn5kfohCE+YionuaK5S0/sN4TiFvdkk853A5v4CFOs0L+O2z7pqKtiVhPIjXhE9bU5pfnLvJzEg6w==" }, "node_modules/@vality/messages-proto": { "version": "1.0.1-8c5435c.0", @@ -15539,9 +15539,9 @@ } }, "node_modules/ngx-mat-select-search": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/ngx-mat-select-search/-/ngx-mat-select-search-4.2.0.tgz", - "integrity": "sha512-vPlq2s8mJPZ8W+HDrhen95YzW/H+0zI2+EDOhju5zrKLoFZi0pQ7SDLHMmfOpPDcSAttGjVZ3lA9N0bCq3RHMw==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ngx-mat-select-search/-/ngx-mat-select-search-4.2.1.tgz", + "integrity": "sha512-bKHpOSIXyqwZw35OB6yi87tcRRV/69mu49PN0M2ZzVbiWBPg/IN58aJnCHUDxDG6CdK0vbGJ/2eCPniZ1nf9KA==", "dependencies": { "tslib": "^2.4.0" }, @@ -25739,9 +25739,9 @@ "integrity": "sha512-GjD4N6ZXyuYaGXv4od+lcCGKfIJFi640I6wJ3+O1eA9VrUI4Ro+Ljpu+TLjckMQ6nS1DkXuu+06Dk7Hr5nK1og==" }, "@vality/domain-proto": { - "version": "1.0.1-3efe7df.0", - "resolved": "https://registry.npmjs.org/@vality/domain-proto/-/domain-proto-1.0.1-3efe7df.0.tgz", - "integrity": "sha512-cILZ0VttIGWLMRATT4/OblgACFraOn5Udnxhi6QiDPC3wd3wSm8YnHiOwFNx8HjydaSOw/5nzf5c+0G9gk27dA==" + "version": "1.0.1-9362c08.0", + "resolved": "https://registry.npmjs.org/@vality/domain-proto/-/domain-proto-1.0.1-9362c08.0.tgz", + "integrity": "sha512-B7JksaSacuNVNS/xyXa8IciOwIkh99vvME34482q1voMu4irVGRwCxovvpWcQKxfmEXoBvV5FTn1mkNNDiIWcA==" }, "@vality/dominant-cache-proto": { "version": "1.0.1-5b29d81.0", @@ -25764,9 +25764,9 @@ "integrity": "sha512-qSotrFM8SY/rrfaIRWiyDFeu8ncMqPw8ohrerrGp5S+UZtGvqF0cHQiXytglK+fbAFJ0scyHgvSFBjc1bUtAzA==" }, "@vality/magista-proto": { - "version": "1.0.1-9f37374.0", - "resolved": "https://registry.npmjs.org/@vality/magista-proto/-/magista-proto-1.0.1-9f37374.0.tgz", - "integrity": "sha512-jgcC0nrH1hZleK9rNgIcUUFmcj6mEK3aMb4h+oa2EWvTSxhSGcjmbGiGXYNnVnoWy+z3CeZoW3hcwGLPPXFieg==" + "version": "1.0.1-5352f74.0", + "resolved": "https://registry.npmjs.org/@vality/magista-proto/-/magista-proto-1.0.1-5352f74.0.tgz", + "integrity": "sha512-lpTKcF/61zn5kfohCE+YionuaK5S0/sN4TiFvdkk853A5v4CFOs0L+O2z7pqKtiVhPIjXhE9bU5pfnLvJzEg6w==" }, "@vality/messages-proto": { "version": "1.0.1-8c5435c.0", @@ -33618,9 +33618,9 @@ } }, "ngx-mat-select-search": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/ngx-mat-select-search/-/ngx-mat-select-search-4.2.0.tgz", - "integrity": "sha512-vPlq2s8mJPZ8W+HDrhen95YzW/H+0zI2+EDOhju5zrKLoFZi0pQ7SDLHMmfOpPDcSAttGjVZ3lA9N0bCq3RHMw==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ngx-mat-select-search/-/ngx-mat-select-search-4.2.1.tgz", + "integrity": "sha512-bKHpOSIXyqwZw35OB6yi87tcRRV/69mu49PN0M2ZzVbiWBPg/IN58aJnCHUDxDG6CdK0vbGJ/2eCPniZ1nf9KA==", "requires": { "tslib": "^2.4.0" }, diff --git a/package.json b/package.json index 55f5bdb5..3c341346 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "start": "ng serve --proxy-config proxy.conf.js --port 4200", "build": "ng build --extra-webpack-config webpack.extra.js", "test": "ng test", - "lint-cmd": "eslint \"src/**/*.{ts,js,html}\" --max-warnings 1216", + "lint-cmd": "eslint \"src/**/*.{ts,js,html}\" --max-warnings 1115", "lint": "npm run lint-cmd -- --cache", "lint-fix": "npm run lint -- --fix", "lint-errors": "npm run lint -- --quiet", @@ -37,12 +37,12 @@ "@s-libs/ng-core": "14.0.0", "@s-libs/rxjs-core": "14.0.0", "@vality/deanonimus-proto": "1.0.1-c9a6cae.0", - "@vality/domain-proto": "1.0.1-3efe7df.0", + "@vality/domain-proto": "1.0.1-9362c08.0", "@vality/dominant-cache-proto": "1.0.1-5b29d81.0", "@vality/file-storage-proto": "1.0.1-447212b.0", "@vality/fistful-proto": "1.0.1-ea0fe7a.0", "@vality/machinegun-proto": "1.0.1-277f06e.0", - "@vality/magista-proto": "1.0.1-9f37374.0", + "@vality/magista-proto": "1.0.1-5352f74.0", "@vality/messages-proto": "1.0.1-8c5435c.0", "@vality/payout-manager-proto": "1.0.1-dbed280.0", "@vality/repairer-proto": "1.0.1-675b6f4.0", @@ -59,7 +59,7 @@ "lodash-es": "4.17.21", "moment": "2.29.4", "monaco-editor": "0.21.2", - "ngx-mat-select-search": "4.2.0", + "ngx-mat-select-search": "4.2.1", "rxjs": "7.5.4", "short-uuid": "4.1.0", "transliteration": "2.1.8", diff --git a/src/app/api/payment-processing/index.ts b/src/app/api/payment-processing/index.ts index bac94e52..f2fa63d5 100644 --- a/src/app/api/payment-processing/index.ts +++ b/src/app/api/payment-processing/index.ts @@ -1,3 +1 @@ export * from './party-management.service'; -export * from './services/user-info'; -export * from './services/party-management-with-user'; diff --git a/src/app/api/payment-processing/services/party-management-with-user/index.ts b/src/app/api/payment-processing/services/party-management-with-user/index.ts deleted file mode 100644 index 675363ba..00000000 --- a/src/app/api/payment-processing/services/party-management-with-user/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './party-management-with-user.service'; diff --git a/src/app/api/payment-processing/services/party-management-with-user/party-management-with-user.service.ts b/src/app/api/payment-processing/services/party-management-with-user/party-management-with-user.service.ts deleted file mode 100644 index 82b60cc3..00000000 --- a/src/app/api/payment-processing/services/party-management-with-user/party-management-with-user.service.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Injectable } from '@angular/core'; -import { ContractID, PartyID, ShopID } from '@vality/domain-proto'; -import { switchMap } from 'rxjs'; - -import { PartyManagementService, UserInfoService } from '@cc/app/api/payment-processing'; - -@Injectable({ - providedIn: 'root', -}) -export class PartyManagementWithUserService { - constructor( - private partyManagementService: PartyManagementService, - private userInfoService: UserInfoService - ) {} - - getParty(partyId: PartyID) { - return this.userInfoService - .getUserInfo() - .pipe(switchMap((userInfo) => this.partyManagementService.Get(userInfo, partyId))); - } - - getShop(partyId: PartyID, id: ShopID) { - return this.userInfoService - .getUserInfo() - .pipe( - switchMap((userInfo) => this.partyManagementService.GetShop(userInfo, partyId, id)) - ); - } - - getContract(partyId: PartyID, id: ContractID) { - return this.userInfoService - .getUserInfo() - .pipe( - switchMap((userInfo) => - this.partyManagementService.GetContract(userInfo, partyId, id) - ) - ); - } -} diff --git a/src/app/api/payment-processing/services/user-info/index.ts b/src/app/api/payment-processing/services/user-info/index.ts deleted file mode 100644 index 58d04182..00000000 --- a/src/app/api/payment-processing/services/user-info/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './user-info.service'; diff --git a/src/app/api/payment-processing/services/user-info/user-info.service.ts b/src/app/api/payment-processing/services/user-info/user-info.service.ts deleted file mode 100644 index 84af7d3e..00000000 --- a/src/app/api/payment-processing/services/user-info/user-info.service.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Injectable } from '@angular/core'; -import { UserInfo } from '@vality/domain-proto/lib/payment_processing'; -import { Observable } from 'rxjs'; -import { first, map, shareReplay } from 'rxjs/operators'; - -import { KeycloakTokenInfoService } from '@cc/app/shared/services'; - -@Injectable({ - providedIn: 'root', -}) -export class UserInfoService { - userInfo$: Observable = this.keycloakTokenInfoService.decoded$.pipe( - map(({ sub }) => ({ - id: sub, - type: { internal_user: {} }, - })), - shareReplay({ refCount: true, bufferSize: 1 }) - ); - - constructor(private keycloakTokenInfoService: KeycloakTokenInfoService) {} - - getUserInfo() { - return this.userInfo$.pipe(first()); - } -} diff --git a/src/app/api/utils/thrift-instance/namespace-type.ts b/src/app/api/utils/thrift-instance/namespace-type.ts index a975d674..c62b070a 100644 --- a/src/app/api/utils/thrift-instance/namespace-type.ts +++ b/src/app/api/utils/thrift-instance/namespace-type.ts @@ -43,9 +43,11 @@ export function parseNamespaceObjectType( include?: JsonAST['include'] ): NamespaceObjectType { // metadata reverse find - search for the last matching protocol if the names match (files are overwritten in the same order) - const namespaceMetadata = include - ? metadata.reverse().find((m) => m.path === include[namespace].path) - : metadata.reverse().find((m) => m.name === namespace); + let namespaceMetadata: ThriftAstMetadata; + if (include) + namespaceMetadata = metadata.reverse().find((m) => m.path === include[namespace].path); + if (!namespaceMetadata) + namespaceMetadata = metadata.reverse().find((m) => m.name === namespace); const objectType = (Object.keys(namespaceMetadata.ast) as StructureType[]).find( (t) => namespaceMetadata.ast[t][type] ); diff --git a/src/app/party-modification-creator-legacy/party-modification-target/party-target/party-target.service.ts b/src/app/party-modification-creator-legacy/party-modification-target/party-target/party-target.service.ts index d5a6c684..13064eb4 100644 --- a/src/app/party-modification-creator-legacy/party-modification-target/party-target/party-target.service.ts +++ b/src/app/party-modification-creator-legacy/party-modification-target/party-target/party-target.service.ts @@ -3,17 +3,17 @@ import { Contract, Party, PartyContractor, Shop } from '@vality/domain-proto/lib import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; import { PartyTarget } from '../party-target'; import { SelectableItem } from './selectable-item'; @Injectable() export class PartyTargetService { - constructor(private partyManagementWithUserService: PartyManagementWithUserService) {} + constructor(private partyManagementService: PartyManagementService) {} getSelectableItems(partyID: string, targetName: PartyTarget): Observable { - return this.partyManagementWithUserService.getParty(partyID).pipe( + return this.partyManagementService.Get(partyID).pipe( map((party) => { const result = []; const target = this.getTarget(party, targetName); diff --git a/src/app/query-dsl/payment.ts b/src/app/query-dsl/payment.ts index 39b4e665..7804ebac 100644 --- a/src/app/query-dsl/payment.ts +++ b/src/app/query-dsl/payment.ts @@ -2,7 +2,6 @@ import { InvoicePaymentFlow, InvoicePaymentStatus, PaymentTool, - TerminalPaymentProvider, } from '@vality/domain-proto/lib/merch_stat'; export interface Payment { @@ -11,7 +10,6 @@ export interface Payment { payment_email?: string; payment_flow?: InvoicePaymentFlow; payment_method?: PaymentTool; - payment_terminal_provider?: TerminalPaymentProvider; payment_ip?: string; payment_provider_id?: string; payment_terminal_id?: string; diff --git a/src/app/repairing/repairing.service.ts b/src/app/repairing/repairing.service.ts index 5301c876..1f5be2a4 100644 --- a/src/app/repairing/repairing.service.ts +++ b/src/app/repairing/repairing.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { MatSnackBar } from '@angular/material/snack-bar'; -import { InvoiceRepairScenario, UserInfo } from '@vality/domain-proto/lib/payment_processing'; +import { InvoiceRepairScenario } from '@vality/domain-proto/lib/payment_processing'; import { RepairScenario } from '@vality/fistful-proto/lib/withdrawal_session'; import { KeycloakService } from 'keycloak-angular'; import { BehaviorSubject, Observable } from 'rxjs'; @@ -51,13 +51,6 @@ export class RepairingService { return ids; } - getUser(): UserInfo { - return { - id: this.keycloakService.getUsername(), - type: { internal_user: {} }, - }; - } - remove(currentElements: E[], elements: E[]) { const resultDataSource = currentElements.slice(); for (const element of elements) { @@ -105,13 +98,12 @@ export class RepairingService { elements: E[], scenario: InvoiceRepairScenario ) { - const user = this.getUser(); this._progress$.next(0); return execute( elements.map( ({ id }) => () => - this.paymentProcessingService.repairWithScenario(user, id, scenario) + this.paymentProcessingService.repairWithScenario(id, scenario) ) ).pipe(tap(({ progress }) => this._progress$.next(progress))); } diff --git a/src/app/sections/claim/claim.component.ts b/src/app/sections/claim/claim.component.ts index c72a3fcc..fc25626c 100644 --- a/src/app/sections/claim/claim.component.ts +++ b/src/app/sections/claim/claim.component.ts @@ -14,7 +14,7 @@ import { import { catchError, first, map, shareReplay } from 'rxjs/operators'; import { ClaimManagementService } from '@cc/app/api/claim-management'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; import { ChangeStatusDialogComponent } from '@cc/app/sections/claim/components/change-status-dialog/change-status-dialog.component'; import { AllowedClaimStatusesService } from '@cc/app/sections/claim/services/allowed-claim-statuses.service'; import { UploadFileService } from '@cc/app/sections/claim/services/upload-file.service'; @@ -36,7 +36,7 @@ import { CLAIM_STATUS_COLOR } from './types/claim-status-color'; export class ClaimComponent { party$ = (this.route.params as Observable>).pipe( switchMap(({ partyID }) => - this.partyManagementWithUserService.getParty(partyID).pipe( + this.partyManagementService.Get(partyID).pipe( progressTo(this.progress$), catchError((err) => { this.notificationService.error('The party was not loaded'); @@ -81,7 +81,7 @@ export class ClaimComponent { constructor( private route: ActivatedRoute, private claimManagementService: ClaimManagementService, - private partyManagementWithUserService: PartyManagementWithUserService, + private partyManagementService: PartyManagementService, private notificationService: NotificationService, private uploadFileService: UploadFileService, private allowedClaimStatusesService: AllowedClaimStatusesService, diff --git a/src/app/sections/claim/components/modification-unit-timeline-item/modification-unit-timeline-item.component.ts b/src/app/sections/claim/components/modification-unit-timeline-item/modification-unit-timeline-item.component.ts index f7f80d12..c2003725 100644 --- a/src/app/sections/claim/components/modification-unit-timeline-item/modification-unit-timeline-item.component.ts +++ b/src/app/sections/claim/components/modification-unit-timeline-item/modification-unit-timeline-item.component.ts @@ -7,7 +7,7 @@ import { BehaviorSubject, switchMap } from 'rxjs'; import { filter, first } from 'rxjs/operators'; import { ClaimManagementService } from '@cc/app/api/claim-management'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; import { getModificationName } from '@cc/app/sections/claim/utils/get-modification-name'; import { Patch } from '@cc/app/shared/components/json-viewer'; import { NotificationService } from '@cc/app/shared/services/notification'; @@ -43,7 +43,7 @@ export class ModificationUnitTimelineItemComponent { private progress$ = new BehaviorSubject(0); constructor( - private partyManagementWithUserService: PartyManagementWithUserService, + private partyManagementService: PartyManagementService, private baseDialogService: BaseDialogService, private claimManagementService: ClaimManagementService, private notificationService: NotificationService @@ -62,8 +62,8 @@ export class ModificationUnitTimelineItemComponent { } update() { - this.partyManagementWithUserService - .getParty(this.claim.party_id) + this.partyManagementService + .Get(this.claim.party_id) .pipe( first(), switchMap((party) => @@ -88,7 +88,7 @@ export class ModificationUnitTimelineItemComponent { .afterClosed() .pipe( filter(({ status }) => status === BaseDialogResponseStatus.Success), - switchMap(() => this.partyManagementWithUserService.getParty(this.claim.party_id)), + switchMap(() => this.partyManagementService.Get(this.claim.party_id)), switchMap((party) => this.claimManagementService.RemoveModification( party.id, diff --git a/src/app/sections/party-shops/party-shops.service.ts b/src/app/sections/party-shops/party-shops.service.ts index 70412886..25ff17ee 100644 --- a/src/app/sections/party-shops/party-shops.service.ts +++ b/src/app/sections/party-shops/party-shops.service.ts @@ -4,7 +4,7 @@ import { Party } from '@vality/domain-proto/lib/domain'; import { defer, Observable } from 'rxjs'; import { map, pluck, shareReplay, switchMap } from 'rxjs/operators'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; @Injectable() export class PartyShopsService { @@ -15,12 +15,12 @@ export class PartyShopsService { private party$: Observable = this.route.params.pipe( pluck('partyID'), - switchMap((partyID) => this.partyManagementWithUserService.getParty(partyID)), + switchMap((partyID) => this.partyManagementService.Get(partyID)), shareReplay(1) ); constructor( - private partyManagementWithUserService: PartyManagementWithUserService, + private partyManagementService: PartyManagementService, private route: ActivatedRoute ) {} } diff --git a/src/app/sections/payment-adjustment/create-and-capture/adjustment-operations/adjustment-params.ts b/src/app/sections/payment-adjustment/create-and-capture/adjustment-operations/adjustment-params.ts index 3a5aab74..f47bf880 100644 --- a/src/app/sections/payment-adjustment/create-and-capture/adjustment-operations/adjustment-params.ts +++ b/src/app/sections/payment-adjustment/create-and-capture/adjustment-operations/adjustment-params.ts @@ -1,24 +1,18 @@ -import { - InvoicePaymentAdjustmentParams, - UserInfo, -} from '@vality/domain-proto/lib/payment_processing'; +import { InvoicePaymentAdjustmentParams } from '@vality/domain-proto/lib/payment_processing'; export interface PaymentAdjustmentCreationParams { - user: UserInfo; invoice_id: string; payment_id: string; params: InvoicePaymentAdjustmentParams; } export interface PaymentAdjustmentCancelParams { - user: UserInfo; invoice_id: string; payment_id: string; adjustment_id: string; } export interface PaymentAdjustmentCaptureParams { - user: UserInfo; invoice_id: string; payment_id: string; adjustment_id: string; diff --git a/src/app/sections/payment-adjustment/create-and-capture/cancel-actions/cancel-actions.component.ts b/src/app/sections/payment-adjustment/create-and-capture/cancel-actions/cancel-actions.component.ts index fb120dc4..259d89b1 100644 --- a/src/app/sections/payment-adjustment/create-and-capture/cancel-actions/cancel-actions.component.ts +++ b/src/app/sections/payment-adjustment/create-and-capture/cancel-actions/cancel-actions.component.ts @@ -82,8 +82,7 @@ export class CancelActionsComponent implements OnInit { } recreate() { - const createParams = this.cancelResult.map(({ user, invoice_id, payment_id }) => ({ - user, + const createParams = this.cancelResult.map(({ invoice_id, payment_id }) => ({ invoice_id, payment_id, params: this.adjustmentParams, diff --git a/src/app/sections/payment-adjustment/create-and-capture/create-actions/create-actions.component.ts b/src/app/sections/payment-adjustment/create-and-capture/create-actions/create-actions.component.ts index 2a11ef6c..a100e992 100644 --- a/src/app/sections/payment-adjustment/create-and-capture/create-actions/create-actions.component.ts +++ b/src/app/sections/payment-adjustment/create-and-capture/create-actions/create-actions.component.ts @@ -73,8 +73,7 @@ export class CreateActionsComponent implements OnInit { capture() { const captureParams = this.createResult.map( - ({ adjustmentId, creationParams: { user, invoice_id, payment_id } }) => ({ - user, + ({ adjustmentId, creationParams: { invoice_id, payment_id } }) => ({ invoice_id, payment_id, adjustment_id: adjustmentId, @@ -95,10 +94,9 @@ export class CreateActionsComponent implements OnInit { ({ operationScope: { adjustmentId, - creationParams: { user, invoice_id, payment_id }, + creationParams: { invoice_id, payment_id }, }, }) => ({ - user, invoice_id, payment_id, adjustment_id: adjustmentId, diff --git a/src/app/sections/payment-adjustment/create-and-capture/create-and-capture.component.ts b/src/app/sections/payment-adjustment/create-and-capture/create-and-capture.component.ts index 551bb78e..947ff8ac 100644 --- a/src/app/sections/payment-adjustment/create-and-capture/create-and-capture.component.ts +++ b/src/app/sections/payment-adjustment/create-and-capture/create-and-capture.component.ts @@ -13,7 +13,6 @@ import { StatPayment } from '@vality/domain-proto/lib/merch_stat'; import { InvoicePaymentAdjustmentParams, InvoicePaymentAdjustmentScenario, - UserInfo, } from '@vality/domain-proto/lib/payment_processing'; import { KeycloakService } from 'keycloak-angular'; import isEqual from 'lodash-es/isEqual'; @@ -142,7 +141,6 @@ export class CreateAndCaptureComponent implements OnInit { this.createStarted = true; this.form.disable(); const createParams = this.payments.map(({ invoice_id, id }) => ({ - user: this.getUser(), invoice_id, payment_id: id, params: this.adjustmentParams, @@ -197,11 +195,4 @@ export class CreateAndCaptureComponent implements OnInit { scenario, } as InvoicePaymentAdjustmentParams; } - - private getUser(): UserInfo { - return { - id: this.keycloakService.getUsername(), - type: { internal_user: {} }, - }; - } } diff --git a/src/app/sections/payment-details/payment-details.service.ts b/src/app/sections/payment-details/payment-details.service.ts index aaa0d446..2c560cae 100644 --- a/src/app/sections/payment-details/payment-details.service.ts +++ b/src/app/sections/payment-details/payment-details.service.ts @@ -4,7 +4,7 @@ import { ActivatedRoute } from '@angular/router'; import { combineLatest, of } from 'rxjs'; import { map, pluck, shareReplay, switchMap, tap } from 'rxjs/operators'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; import { progress } from '@cc/app/shared/custom-operators'; import { QueryDsl } from '../../query-dsl'; @@ -49,14 +49,12 @@ export class PaymentDetailsService { // eslint-disable-next-line @typescript-eslint/member-ordering shop$ = this.payment$.pipe( switchMap((payment) => combineLatest([this.partyID$, of(payment.shop_id)])), - switchMap(([partyID, shopID]) => - this.partyManagementWithUserService.getShop(partyID, shopID) - ), + switchMap(([partyID, shopID]) => this.partyManagementService.GetShop(partyID, shopID)), shareReplay(1) ); constructor( - private partyManagementWithUserService: PartyManagementWithUserService, + private partyManagementService: PartyManagementService, private merchantStatisticsService: MerchantStatisticsService, private route: ActivatedRoute, private snackBar: MatSnackBar diff --git a/src/app/sections/payment-details/payment-main-info/payment-contractor/fetch-contractor.service.ts b/src/app/sections/payment-details/payment-main-info/payment-contractor/fetch-contractor.service.ts index d16b6da5..bef297c9 100644 --- a/src/app/sections/payment-details/payment-main-info/payment-contractor/fetch-contractor.service.ts +++ b/src/app/sections/payment-details/payment-main-info/payment-contractor/fetch-contractor.service.ts @@ -3,7 +3,7 @@ import { ContractID, PartyID } from '@vality/domain-proto'; import { forkJoin, merge, Observable, of, Subject } from 'rxjs'; import { catchError, filter, map, shareReplay, startWith, switchMap } from 'rxjs/operators'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; import { progress } from '@cc/app/shared/custom-operators'; @Injectable() @@ -17,7 +17,7 @@ export class FetchContractorService { ({ partyID, contractID }): Observable<[ContractID, any]> => forkJoin([ of(contractID), - this.partyManagementWithUserService.getParty(partyID).pipe( + this.partyManagementService.Get(partyID).pipe( catchError(() => { this.hasError$.next(); return of('error'); @@ -38,7 +38,7 @@ export class FetchContractorService { startWith(true) ); - constructor(private partyManagementWithUserService: PartyManagementWithUserService) { + constructor(private partyManagementService: PartyManagementService) { this.contractor$.subscribe(); } diff --git a/src/app/sections/payment-details/payment-main-info/payment-tool/bank-card/bank-card.component.html b/src/app/sections/payment-details/payment-main-info/payment-tool/bank-card/bank-card.component.html index 3fd99ea6..b8a7a487 100644 --- a/src/app/sections/payment-details/payment-main-info/payment-tool/bank-card/bank-card.component.html +++ b/src/app/sections/payment-details/payment-main-info/payment-tool/bank-card/bank-card.component.html @@ -1,27 +1,28 @@
{{ bankCard | toCardNumber }}
- - - - - - + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/app/sections/payment-details/payment-main-info/payment-tool/bank-card/bank-card.component.ts b/src/app/sections/payment-details/payment-main-info/payment-tool/bank-card/bank-card.component.ts index 14891b08..5291c288 100644 --- a/src/app/sections/payment-details/payment-main-info/payment-tool/bank-card/bank-card.component.ts +++ b/src/app/sections/payment-details/payment-main-info/payment-tool/bank-card/bank-card.component.ts @@ -1,8 +1,4 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; -import { - LegacyBankCardPaymentSystem, - LegacyBankCardTokenProvider, -} from '@vality/domain-proto/lib/domain'; import { BankCard } from '@vality/domain-proto/lib/merch_stat'; @Component({ @@ -12,8 +8,4 @@ import { BankCard } from '@vality/domain-proto/lib/merch_stat'; }) export class BankCardComponent { @Input() bankCard: BankCard; - - // TODO Need migration according to: https://github.com/rbkmoney/damsel/commit/61677b86006d405619bdc5f23d6416a929688180 - legacyPaymentSystems = LegacyBankCardPaymentSystem; - legacyTokenProviders = LegacyBankCardTokenProvider; } diff --git a/src/app/sections/payment-details/payment-main-info/payment-tool/payment-tool.component.html b/src/app/sections/payment-details/payment-main-info/payment-tool/payment-tool.component.html index 7c5cd186..939deec5 100644 --- a/src/app/sections/payment-details/payment-main-info/payment-tool/payment-tool.component.html +++ b/src/app/sections/payment-details/payment-main-info/payment-tool/payment-tool.component.html @@ -1,14 +1,13 @@
- {{ paymentTool.crypto_currency | toCryptoCurrency }} + {{ paymentTool.crypto_currency?.crypto_currency?.id }}
- {{ paymentTool.digital_wallet?.provider | toDigitalWallet }} + {{ paymentTool.digital_wallet?.id }}
{{ paymentTool.mobile_commerce.phone }}
- {{ paymentTool.payment_terminal?.terminal_type_deprecated | toPaymentTerminal }} - {{ paymentTool.payment_terminal?.payment_service }} + {{ paymentTool.payment_terminal?.payment_service?.id }}
diff --git a/src/app/sections/payment-details/payment-main-info/payment-tool/payment-tool.module.ts b/src/app/sections/payment-details/payment-main-info/payment-tool/payment-tool.module.ts index e72094a3..8c3ca947 100644 --- a/src/app/sections/payment-details/payment-main-info/payment-tool/payment-tool.module.ts +++ b/src/app/sections/payment-details/payment-main-info/payment-tool/payment-tool.module.ts @@ -4,17 +4,9 @@ import { FlexLayoutModule } from '@angular/flex-layout'; import { BankCardModule } from './bank-card'; import { PaymentToolComponent } from './payment-tool.component'; -import { ToCryptoCurrencyPipe } from './to-crypto-currency.pipe'; -import { ToDigitalWalletPipe } from './to-digital-wallet.pipe'; -import { ToPaymentTerminalPipe } from './to-payment-terminal.pipe'; @NgModule({ imports: [CommonModule, FlexLayoutModule, BankCardModule], - declarations: [ - PaymentToolComponent, - ToCryptoCurrencyPipe, - ToDigitalWalletPipe, - ToPaymentTerminalPipe, - ], + declarations: [PaymentToolComponent], exports: [PaymentToolComponent], }) export class PaymentToolModule {} diff --git a/src/app/sections/payment-details/payment-main-info/payment-tool/to-crypto-currency.pipe.ts b/src/app/sections/payment-details/payment-main-info/payment-tool/to-crypto-currency.pipe.ts deleted file mode 100644 index b262d97b..00000000 --- a/src/app/sections/payment-details/payment-main-info/payment-tool/to-crypto-currency.pipe.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { CryptoCurrency } from '@vality/domain-proto/lib/merch_stat'; - -@Pipe({ - name: 'toCryptoCurrency', -}) -export class ToCryptoCurrencyPipe implements PipeTransform { - transform(currency: CryptoCurrency): string { - return toCryptoCurrency(currency); - } -} - -export const toCryptoCurrency = (currency: CryptoCurrency): string => { - switch (currency) { - case CryptoCurrency.bitcoin: - return 'Bitcoin'; - case CryptoCurrency.litecoin: - return 'Litecoin'; - case CryptoCurrency.bitcoin_cash: - return 'Bitcoin Cash'; - case CryptoCurrency.ripple: - return 'Ripple'; - case CryptoCurrency.ethereum: - return 'Ethereum'; - case CryptoCurrency.zcash: - return 'Zcash'; - } -}; diff --git a/src/app/sections/payment-details/payment-main-info/payment-tool/to-digital-wallet.pipe.ts b/src/app/sections/payment-details/payment-main-info/payment-tool/to-digital-wallet.pipe.ts deleted file mode 100644 index 3788c9e6..00000000 --- a/src/app/sections/payment-details/payment-main-info/payment-tool/to-digital-wallet.pipe.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { DigitalWalletProvider } from '@vality/domain-proto/lib/merch_stat'; - -@Pipe({ - name: 'toDigitalWallet', -}) -export class ToDigitalWalletPipe implements PipeTransform { - transform(provider: DigitalWalletProvider): string { - return toDigitalWallet(provider); - } -} - -export const toDigitalWallet = (provider: DigitalWalletProvider): string => { - switch (provider) { - case DigitalWalletProvider.qiwi: - return 'QIWI'; - } -}; diff --git a/src/app/sections/payment-details/payment-main-info/payment-tool/to-payment-terminal.pipe.ts b/src/app/sections/payment-details/payment-main-info/payment-tool/to-payment-terminal.pipe.ts deleted file mode 100644 index 3d210f64..00000000 --- a/src/app/sections/payment-details/payment-main-info/payment-tool/to-payment-terminal.pipe.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { TerminalPaymentProvider } from '@vality/domain-proto/lib/merch_stat'; - -@Pipe({ - name: 'toPaymentTerminal', -}) -export class ToPaymentTerminalPipe implements PipeTransform { - transform(terminalType: TerminalPaymentProvider): string { - return toPaymentTerminal(terminalType); - } -} - -export const toPaymentTerminal = (terminalType: TerminalPaymentProvider): string => { - switch (terminalType) { - case TerminalPaymentProvider.euroset: - return 'Евросеть'; - case TerminalPaymentProvider.wechat: - return 'WeChat'; - case TerminalPaymentProvider.alipay: - return 'AliPay'; - case TerminalPaymentProvider.zotapay: - return 'ZotaPay'; - case TerminalPaymentProvider.qps: - return 'QPS'; - } -}; diff --git a/src/app/sections/payouts/payout-details/payout-details.component.html b/src/app/sections/payouts/payout-details/payout-details.component.html index f4debbc9..4cb4f85f 100644 --- a/src/app/sections/payouts/payout-details/payout-details.component.html +++ b/src/app/sections/payouts/payout-details/payout-details.component.html @@ -1,5 +1,25 @@
- Payout details +
+ Payout details +
+ + +
+
diff --git a/src/app/sections/payouts/payout-details/payout-details.component.ts b/src/app/sections/payouts/payout-details/payout-details.component.ts index 68c26055..8bef8459 100644 --- a/src/app/sections/payouts/payout-details/payout-details.component.ts +++ b/src/app/sections/payouts/payout-details/payout-details.component.ts @@ -1,15 +1,19 @@ import { Component } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; +import { PayoutID, PayoutStatus } from '@vality/magista-proto'; import { combineLatest } from 'rxjs'; import { map, pluck, shareReplay, startWith, switchMap } from 'rxjs/operators'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; import { PayoutManagementService } from '@cc/app/api/payout-manager'; +import { PayoutActionsService } from '../services/payout-actions.service'; + @Component({ selector: 'cc-payout-details', templateUrl: './payout-details.component.html', styleUrls: ['./payout-details.component.scss'], + providers: [PayoutActionsService], }) export class PayoutDetailsComponent { payout$ = this.route.params.pipe( @@ -20,18 +24,18 @@ export class PayoutDetailsComponent { ); shop$ = this.payout$.pipe( switchMap(({ party_id, shop_id }) => - this.partyManagementWithUserService.getShop(party_id, shop_id) + this.partyManagementService.GetShop(party_id, shop_id) ), shareReplay({ refCount: true, bufferSize: 1 }) ); party$ = this.payout$.pipe( - switchMap(({ party_id }) => this.partyManagementWithUserService.getParty(party_id)), + switchMap(({ party_id }) => this.partyManagementService.Get(party_id)), shareReplay({ refCount: true, bufferSize: 1 }) ); payoutTool$ = combineLatest([this.payout$, this.shop$]).pipe( switchMap(([{ party_id, payout_tool_id }, { contract_id }]) => - this.partyManagementWithUserService - .getContract(party_id, contract_id) + this.partyManagementService + .GetContract(party_id, contract_id) .pipe(map((contract) => contract.payout_tools.find((t) => t.id === payout_tool_id))) ), shareReplay({ refCount: true, bufferSize: 1 }) @@ -41,6 +45,23 @@ export class PayoutDetailsComponent { constructor( private route: ActivatedRoute, private payoutManagementService: PayoutManagementService, - private partyManagementWithUserService: PartyManagementWithUserService + private partyManagementService: PartyManagementService, + private payoutActionsService: PayoutActionsService ) {} + + canBeConfirmed(status: keyof PayoutStatus) { + return this.payoutActionsService.canBeConfirmed(status); + } + + canBeCancelled(status: keyof PayoutStatus) { + return this.payoutActionsService.canBeCancelled(status); + } + + cancel(id: PayoutID) { + this.payoutActionsService.cancel(id); + } + + confirm(id: PayoutID) { + this.payoutActionsService.confirm(id); + } } diff --git a/src/app/sections/payouts/payout-details/payout-details.module.ts b/src/app/sections/payouts/payout-details/payout-details.module.ts index 476977a9..52eaaf94 100644 --- a/src/app/sections/payouts/payout-details/payout-details.module.ts +++ b/src/app/sections/payouts/payout-details/payout-details.module.ts @@ -1,6 +1,7 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FlexLayoutModule } from '@angular/flex-layout'; +import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; import { MatDividerModule } from '@angular/material/divider'; import { MatPaginatorModule } from '@angular/material/paginator'; @@ -13,6 +14,7 @@ import { DetailsItemModule } from '@cc/components/details-item'; import { EmptySearchResultModule } from '@cc/components/empty-search-result'; import { HeadlineModule } from '@cc/components/headline'; +import { ActionsModule } from '../../../../components/actions'; import { PayoutDetailsRoutingModule } from './payout-details-routing.module'; import { PayoutDetailsComponent } from './payout-details.component'; @@ -33,6 +35,8 @@ import { PayoutDetailsComponent } from './payout-details.component'; MatTableModule, EmptySearchResultModule, MatPaginatorModule, + MatButtonModule, + ActionsModule, ], }) export class PayoutDetailsModule {} diff --git a/src/app/sections/payouts/payouts/components/cancel-payout-dialog/cancel-payout-dialog.component.ts b/src/app/sections/payouts/payouts/components/cancel-payout-dialog/cancel-payout-dialog.component.ts index 01f9b631..04708ad9 100644 --- a/src/app/sections/payouts/payouts/components/cancel-payout-dialog/cancel-payout-dialog.component.ts +++ b/src/app/sections/payouts/payouts/components/cancel-payout-dialog/cancel-payout-dialog.component.ts @@ -1,5 +1,4 @@ -import { Component, Inject } from '@angular/core'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { Component, Injector } from '@angular/core'; import { FormControl } from '@ngneat/reactive-forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { PayoutID } from '@vality/payout-manager-proto'; @@ -9,29 +8,39 @@ import { PayoutManagementService } from '@cc/app/api/payout-manager'; import { NotificationService } from '@cc/app/shared/services/notification'; import { progressTo } from '@cc/utils/operators'; +import { + BaseDialogResponseStatus, + BaseDialogSuperclass, +} from '../../../../../../components/base-dialog'; + @UntilDestroy() @Component({ selector: 'cc-cancel-payout-dialog', templateUrl: './cancel-payout-dialog.component.html', }) -export class CancelPayoutDialogComponent { +export class CancelPayoutDialogComponent extends BaseDialogSuperclass< + CancelPayoutDialogComponent, + { id: PayoutID } +> { detailsControl = new FormControl(); progress$ = new BehaviorSubject(0); constructor( - private dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) private data: { id: PayoutID }, + injector: Injector, private payoutManagementService: PayoutManagementService, private notificationService: NotificationService - ) {} + ) { + super(injector); + } accept() { this.payoutManagementService - .CancelPayout(this.data.id, this.detailsControl.value) + .CancelPayout(this.dialogData.id, this.detailsControl.value) .pipe(progressTo(this.progress$), untilDestroyed(this)) .subscribe({ next: () => { - this.dialogRef.close(true); + this.dialogRef.close({ status: BaseDialogResponseStatus.Success }); + this.notificationService.success('Payout canceled successfully'); }, error: (err) => { this.notificationService.error('Payout cancellation error'); diff --git a/src/app/sections/payouts/payouts/components/create-payout-dialog/create-payout-dialog.component.ts b/src/app/sections/payouts/payouts/components/create-payout-dialog/create-payout-dialog.component.ts index 7c675356..2e8ca5db 100644 --- a/src/app/sections/payouts/payouts/components/create-payout-dialog/create-payout-dialog.component.ts +++ b/src/app/sections/payouts/payouts/components/create-payout-dialog/create-payout-dialog.component.ts @@ -1,5 +1,4 @@ -import { ChangeDetectionStrategy, Component } from '@angular/core'; -import { MatDialogRef } from '@angular/material/dialog'; +import { ChangeDetectionStrategy, Component, Injector } from '@angular/core'; import { FormBuilder } from '@ngneat/reactive-forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { PayoutParams } from '@vality/payout-manager-proto'; @@ -12,6 +11,11 @@ import { NotificationService } from '@cc/app/shared/services/notification'; import { progressTo } from '@cc/utils/operators'; import { toMinor } from '@cc/utils/to-minor'; +import { + BaseDialogResponseStatus, + BaseDialogSuperclass, +} from '../../../../../../components/base-dialog'; + interface CreatePayoutDialogForm { partyId: string; shopId: string; @@ -26,7 +30,7 @@ interface CreatePayoutDialogForm { templateUrl: './create-payout-dialog.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) -export class CreatePayoutDialogComponent { +export class CreatePayoutDialogComponent extends BaseDialogSuperclass { progress$ = new BehaviorSubject(0); control = this.fb.group({ partyId: null, @@ -37,11 +41,13 @@ export class CreatePayoutDialogComponent { }); constructor( + injector: Injector, private fb: FormBuilder, private payoutManagementService: PayoutManagementService, - private dialogRef: MatDialogRef, private notificationService: NotificationService - ) {} + ) { + super(injector); + } create() { const { value } = this.control; @@ -65,7 +71,8 @@ export class CreatePayoutDialogComponent { .pipe(untilDestroyed(this), progressTo(this.progress$)) .subscribe({ next: () => { - this.dialogRef.close(true); + this.notificationService.error('Payout created successfully'); + this.dialogRef.close({ status: BaseDialogResponseStatus.Success }); }, error: (err) => { console.error(err); diff --git a/src/app/sections/payouts/payouts/components/payouts-table/payouts-table.component.ts b/src/app/sections/payouts/payouts/components/payouts-table/payouts-table.component.ts index b63b231a..c2e044d9 100644 --- a/src/app/sections/payouts/payouts/components/payouts-table/payouts-table.component.ts +++ b/src/app/sections/payouts/payouts/components/payouts-table/payouts-table.component.ts @@ -1,20 +1,10 @@ -import { Component, Inject, Input } from '@angular/core'; -import { MatDialog } from '@angular/material/dialog'; -import { Router } from '@angular/router'; -import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; +import { Component, Input } from '@angular/core'; +import { UntilDestroy } from '@ngneat/until-destroy'; import { PayoutID, PayoutStatus, StatPayout } from '@vality/magista-proto'; -import { switchMap } from 'rxjs'; -import { filter } from 'rxjs/operators'; -import { PayoutManagementService } from '@cc/app/api/payout-manager'; -import { NotificationService } from '@cc/app/shared/services/notification'; import { StatusColor } from '@cc/app/styles'; -import { BaseDialogResponseStatus } from '@cc/components/base-dialog'; -import { BaseDialogService } from '@cc/components/base-dialog/services/base-dialog.service'; -import { ConfirmActionDialogComponent } from '@cc/components/confirm-action-dialog'; -import { DIALOG_CONFIG, DialogConfig } from '../../../../../tokens'; -import { CancelPayoutDialogComponent } from '../cancel-payout-dialog/cancel-payout-dialog.component'; +import { PayoutActionsService } from '../../../services/payout-actions.service'; @UntilDestroy() @Component({ @@ -37,14 +27,7 @@ export class PayoutsTableComponent { 'actions', ]; - constructor( - private router: Router, - private payoutManagementService: PayoutManagementService, - private dialog: MatDialog, - private baseDialogService: BaseDialogService, - @Inject(DIALOG_CONFIG) private dialogConfig: DialogConfig, - private notificationService: NotificationService - ) {} + constructor(private payoutActionsService: PayoutActionsService) {} getColorByStatus(status: keyof PayoutStatus) { switch (status) { @@ -61,37 +44,18 @@ export class PayoutsTableComponent { } canBeConfirmed(status: keyof PayoutStatus) { - return (['paid'] as (keyof PayoutStatus)[]).includes(status); + return this.payoutActionsService.canBeConfirmed(status); } canBeCancelled(status: keyof PayoutStatus) { - return (['paid', 'confirmed', 'unpaid'] as (keyof PayoutStatus)[]).includes(status); + return this.payoutActionsService.canBeCancelled(status); } cancel(id: PayoutID) { - this.dialog - .open(CancelPayoutDialogComponent, { - ...this.dialogConfig.medium, - data: { id }, - }) - .afterClosed() - .subscribe(); + this.payoutActionsService.cancel(id); } confirm(id: PayoutID) { - this.baseDialogService - .open(ConfirmActionDialogComponent, { title: 'Confirm payout' }) - .afterClosed() - .pipe( - filter(({ status }) => status === BaseDialogResponseStatus.Success), - switchMap(() => this.payoutManagementService.ConfirmPayout(id)), - untilDestroyed(this) - ) - .subscribe({ - error: (err) => { - this.notificationService.error('Payout confirmation error'); - console.error(err); - }, - }); + this.payoutActionsService.confirm(id); } } diff --git a/src/app/sections/payouts/payouts/payouts.component.html b/src/app/sections/payouts/payouts/payouts.component.html index 4aac6682..4ef28e6e 100644 --- a/src/app/sections/payouts/payouts/payouts.component.html +++ b/src/app/sections/payouts/payouts/payouts.component.html @@ -1,7 +1,7 @@

Payouts

-
+
diff --git a/src/app/sections/payouts/payouts/payouts.component.ts b/src/app/sections/payouts/payouts/payouts.component.ts index 6e68f6ed..a3e46029 100644 --- a/src/app/sections/payouts/payouts/payouts.component.ts +++ b/src/app/sections/payouts/payouts/payouts.component.ts @@ -1,14 +1,14 @@ -import { ChangeDetectionStrategy, Component, Inject, OnInit } from '@angular/core'; -import { MatDialog } from '@angular/material/dialog'; +import { Component, Inject, OnInit } from '@angular/core'; import { FormControl } from '@ngneat/reactive-forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import omitBy from 'lodash-es/omitBy'; -import { debounceTime } from 'rxjs/operators'; import { QueryParamsService } from '@cc/app/shared/services'; import { isNilOrEmptyString } from '@cc/utils/is-nil-or-empty-string'; +import { BaseDialogService } from '../../../../components/base-dialog/services/base-dialog.service'; import { DIALOG_CONFIG, DialogConfig } from '../../../tokens'; +import { PayoutActionsService } from '../services/payout-actions.service'; import { CreatePayoutDialogComponent } from './components/create-payout-dialog/create-payout-dialog.component'; import { PayoutsSearchForm } from './components/payouts-search-form/payouts-search-form.component'; import { FetchPayoutsService, SearchParams } from './services/fetch-payouts.service'; @@ -18,34 +18,33 @@ import { FetchPayoutsService, SearchParams } from './services/fetch-payouts.serv selector: 'cc-payouts', templateUrl: './payouts.component.html', styleUrls: ['./payouts.component.scss'], - providers: [FetchPayoutsService], - changeDetection: ChangeDetectionStrategy.OnPush, + providers: [FetchPayoutsService, PayoutActionsService], }) export class PayoutsComponent implements OnInit { - control = new FormControl(this.qp.params); + control = new FormControl(this.qp.params as PayoutsSearchForm); inProgress$ = this.fetchPayoutsService.doAction$; payouts$ = this.fetchPayoutsService.searchResult$; hasMore$ = this.fetchPayoutsService.hasMore$; constructor( private fetchPayoutsService: FetchPayoutsService, - private qp: QueryParamsService, - private dialog: MatDialog, + private qp: QueryParamsService>, + private baseDialogService: BaseDialogService, @Inject(DIALOG_CONFIG) private dialogConfig: DialogConfig ) {} ngOnInit() { this.control.valueChanges - .pipe(debounceTime(250), untilDestroyed(this)) - .subscribe((value) => this.search(value)); + .pipe(untilDestroyed(this)) + .subscribe((value) => void this.qp.set(omitBy(value, isNilOrEmptyString))); + this.qp.params$.pipe(untilDestroyed(this)).subscribe((value) => this.search(value)); } fetchMore() { this.fetchPayoutsService.fetchMore(); } - search(value: PayoutsSearchForm) { - void this.qp.set(omitBy(value, isNilOrEmptyString) as PayoutsSearchForm); + search(value: Partial) { this.fetchPayoutsService.search( omitBy( { @@ -68,10 +67,6 @@ export class PayoutsComponent implements OnInit { } create() { - this.dialog - .open(CreatePayoutDialogComponent, this.dialogConfig.medium) - .afterClosed() - .pipe(untilDestroyed(this)) - .subscribe(); + this.baseDialogService.open(CreatePayoutDialogComponent); } } diff --git a/src/app/sections/payouts/payouts/payouts.module.ts b/src/app/sections/payouts/payouts/payouts.module.ts index 638ee845..08c62515 100644 --- a/src/app/sections/payouts/payouts/payouts.module.ts +++ b/src/app/sections/payouts/payouts/payouts.module.ts @@ -19,6 +19,7 @@ import { MerchantFieldModule } from '@cc/app/shared/components/merchant-field'; import { ApiModelPipesModule, CommonPipesModule, ThriftPipesModule } from '@cc/app/shared/pipes'; import { EmptySearchResultModule } from '@cc/components/empty-search-result'; +import { BaseDialogModule } from '../../../../components/base-dialog'; import { CancelPayoutDialogComponent } from './components/cancel-payout-dialog/cancel-payout-dialog.component'; import { CreatePayoutDialogComponent } from './components/create-payout-dialog/create-payout-dialog.component'; import { PayoutsSearchFormComponent } from './components/payouts-search-form/payouts-search-form.component'; @@ -59,6 +60,7 @@ import { PayoutsComponent } from './payouts.component'; MatDialogModule, ShopFieldModule, PayoutToolFieldModule, + BaseDialogModule, ], }) export class PayoutsModule {} diff --git a/src/app/sections/payouts/payouts/services/fetch-payouts.service.ts b/src/app/sections/payouts/payouts/services/fetch-payouts.service.ts index 5a63f079..6d00f92b 100644 --- a/src/app/sections/payouts/payouts/services/fetch-payouts.service.ts +++ b/src/app/sections/payouts/payouts/services/fetch-payouts.service.ts @@ -32,7 +32,7 @@ export class FetchPayoutsService extends PartialFetcher status === BaseDialogResponseStatus.Success), + switchMap(() => this.payoutManagementService.ConfirmPayout(id)), + untilDestroyed(this) + ) + .subscribe({ + error: (err) => { + this.notificationService.error('Payout confirmation error'); + console.error(err); + }, + }); + } +} diff --git a/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.service.ts b/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.service.ts index bc9428fd..fac27c75 100644 --- a/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.service.ts +++ b/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.service.ts @@ -5,7 +5,7 @@ import { combineLatest, defer, Observable } from 'rxjs'; import { map, pluck, shareReplay, switchMap } from 'rxjs/operators'; import { FistfulStatisticsService } from '@cc/app/api/fistful-stat'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; import { createDsl } from '../../../query-dsl'; import { RoutingRulesService } from '../../../thrift-services'; @@ -48,14 +48,14 @@ export class PartyRoutingRulesetService { ); private party$ = this.partyID$.pipe( - switchMap((partyID) => this.partyManagementWithUserService.getParty(partyID)), + switchMap((partyID) => this.partyManagementService.Get(partyID)), untilDestroyed(this), shareReplay(1) ); constructor( private route: ActivatedRoute, - private partyManagementWithUserService: PartyManagementWithUserService, + private partyManagementService: PartyManagementService, private domainStoreService: DomainStoreService, private routingRulesService: RoutingRulesService, private fistfulStatistics: FistfulStatisticsService diff --git a/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.service.ts b/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.service.ts index 18e1f4d6..83cc5623 100644 --- a/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.service.ts +++ b/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.service.ts @@ -7,7 +7,7 @@ import { startWith, switchMap, take } from 'rxjs/operators'; import { BaseDialogResponseStatus } from '@cc/components/base-dialog'; -import { RoutingRulesService, TerminalService } from '../../../../thrift-services'; +import { RoutingRulesService } from '../../../../thrift-services'; import { AddRoutingRuleDialogComponent } from './add-routing-rule-dialog.component'; export enum TerminalType { @@ -38,8 +38,7 @@ export class AddRoutingRuleDialogService { constructor( private fb: UntypedFormBuilder, private dialogRef: MatDialogRef, - private routingRulesService: RoutingRulesService, - private terminalService: TerminalService + private routingRulesService: RoutingRulesService ) { this.form .get('terminalType') @@ -67,10 +66,10 @@ export class AddRoutingRuleDialogService { const { description, weight, priority, terminalType, existentTerminalID, newTerminal } = this.form.value; (terminalType === TerminalType.New - ? this.terminalService.createTerminal({ - terminalName: newTerminal.name, - terminalDescription: newTerminal.description, - riskCoverage: newTerminal.riskCoverage, + ? this.routingRulesService.createTerminal({ + name: newTerminal.name, + description: newTerminal.description, + risk_coverage: newTerminal.riskCoverage, options: newTerminal.options, }) : of(existentTerminalID) diff --git a/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.service.ts b/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.service.ts index 0ea3a57a..d29f4475 100644 --- a/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.service.ts +++ b/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.service.ts @@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router'; import { combineLatest, Observable } from 'rxjs'; import { map, pluck, shareReplay, switchMap, take } from 'rxjs/operators'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; import { handleError } from '../../../../utils/operators/handle-error'; import { ErrorService } from '../../../shared/services/error'; @@ -27,7 +27,7 @@ export class RoutingRulesetService { shareReplay(1) ); private party$ = this.partyID$.pipe( - switchMap((partyID) => this.partyManagementWithUserService.getParty(partyID)), + switchMap((partyID) => this.partyManagementService.Get(partyID)), shareReplay(1) ); // eslint-disable-next-line @typescript-eslint/member-ordering @@ -45,7 +45,7 @@ export class RoutingRulesetService { constructor( private routingRulesService: RoutingRulesDamselService, private route: ActivatedRoute, - private partyManagementWithUserService: PartyManagementWithUserService, + private partyManagementService: PartyManagementService, private errorService: ErrorService ) {} diff --git a/src/app/sections/shop-details/services/fetch-shop.service.ts b/src/app/sections/shop-details/services/fetch-shop.service.ts index 5bd66b4f..68cfc542 100644 --- a/src/app/sections/shop-details/services/fetch-shop.service.ts +++ b/src/app/sections/shop-details/services/fetch-shop.service.ts @@ -4,7 +4,7 @@ import { PartyID, ShopID } from '@vality/domain-proto'; import { BehaviorSubject, merge, of, Subject } from 'rxjs'; import { catchError, filter, shareReplay, startWith, switchMap } from 'rxjs/operators'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; import { progress } from '@cc/app/shared/custom-operators'; @Injectable() @@ -15,7 +15,7 @@ export class FetchShopService { // eslint-disable-next-line @typescript-eslint/member-ordering shop$ = this.getShop$.pipe( switchMap(({ partyID, shopID }) => - this.partyManagementWithUserService.getShop(partyID, shopID).pipe( + this.partyManagementService.GetShop(partyID, shopID).pipe( catchError((e) => { this.hasError$.next(e); this.snackBar.open('An error occurred while fetching shop', 'OK'); @@ -31,7 +31,7 @@ export class FetchShopService { inProgress$ = progress(this.getShop$, merge(this.shop$, this.hasError$)).pipe(startWith(true)); constructor( - private partyManagementWithUserService: PartyManagementWithUserService, + private partyManagementService: PartyManagementService, private snackBar: MatSnackBar ) {} diff --git a/src/app/sections/shop-details/shop-details.component.html b/src/app/sections/shop-details/shop-details.component.html index 75ed1783..184d849b 100644 --- a/src/app/sections/shop-details/shop-details.component.html +++ b/src/app/sections/shop-details/shop-details.component.html @@ -8,14 +8,4 @@
-
Providers
- - - - -
diff --git a/src/app/sections/shop-details/shop-details.module.ts b/src/app/sections/shop-details/shop-details.module.ts index 9ea40480..f9dfc291 100644 --- a/src/app/sections/shop-details/shop-details.module.ts +++ b/src/app/sections/shop-details/shop-details.module.ts @@ -9,7 +9,6 @@ import { HeadlineModule } from '@cc/components/headline'; import { ShopDetailsRoutingModule } from './shop-details-routing.module'; import { ShopDetailsComponent } from './shop-details.component'; import { ShopMainInfoModule } from './shop-main-info'; -import { ShopProvidersModule } from './shop-providers'; @NgModule({ imports: [ @@ -20,7 +19,6 @@ import { ShopProvidersModule } from './shop-providers'; MatCardModule, CommonModule, MatProgressSpinnerModule, - ShopProvidersModule, ], declarations: [ShopDetailsComponent], }) diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/add-terminal-dialog.component.html b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/add-terminal-dialog.component.html deleted file mode 100644 index 19d8ad14..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/add-terminal-dialog.component.html +++ /dev/null @@ -1,49 +0,0 @@ -
Add terminal
- - - - Select provider: -
- -
- -
-
-
- - Select or create terminal: -
- -
-
-
-
-
- -
- - -
- -
diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/add-terminal-dialog.component.ts b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/add-terminal-dialog.component.ts deleted file mode 100644 index bfc70a89..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/add-terminal-dialog.component.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { ChangeDetectionStrategy, Component, Inject } from '@angular/core'; -import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { PartyID, ShopID } from '@vality/domain-proto'; - -import { DomainStoreService } from '../../../../thrift-services/damsel/domain-store.service'; -import { AddTerminalDialogResponse } from '../types/add-terminal-dialog-response'; -import { AddTerminalDecisionService } from './services/add-terminal-decision'; - -@Component({ - templateUrl: 'add-terminal-dialog.component.html', - providers: [AddTerminalDecisionService], - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class AddTerminalDialogComponent { - providers$ = this.addTerminalDecisionService.getProviders(this.data.categoryID); - terminals$ = this.domainStoreService.getObjects('terminal'); - inProgress$ = this.addTerminalDecisionService.inProgress$; - - providerForm = this.addTerminalDecisionService.providerForm; - terminalForm = this.addTerminalDecisionService.terminalForm; - - constructor( - private domainStoreService: DomainStoreService, - private addTerminalDecisionService: AddTerminalDecisionService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) - public data: { - shopID: ShopID; - partyID: PartyID; - categoryID: number; - } - ) { - this.addTerminalDecisionService.terminalAdded$.subscribe(() => - this.dialogRef.close('added') - ); - } - - providerIDSelected(id: number) { - this.providerForm.setValue({ id }); - } - - terminalIDSelected(id: number) { - this.terminalForm.setValue({ id }); - } - - add() { - this.addTerminalDecisionService.add({ - partyID: this.data.partyID, - shopID: this.data.shopID, - }); - } -} diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/add-terminal-dialog.module.ts b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/add-terminal-dialog.module.ts deleted file mode 100644 index 50402f84..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/add-terminal-dialog.module.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { FlexModule } from '@angular/flex-layout'; -import { MatButtonModule } from '@angular/material/button'; -import { MatCheckboxModule } from '@angular/material/checkbox'; -import { MatDialogModule } from '@angular/material/dialog'; -import { MatFormFieldModule } from '@angular/material/form-field'; -import { MatInputModule } from '@angular/material/input'; -import { MatPaginatorModule } from '@angular/material/paginator'; -import { MatProgressBarModule } from '@angular/material/progress-bar'; -import { MatStepperModule } from '@angular/material/stepper'; -import { MatTableModule } from '@angular/material/table'; - -import { AddTerminalDialogComponent } from './add-terminal-dialog.component'; -import { SelectProviderComponent, TerminalsTableComponent } from './components'; - -@NgModule({ - declarations: [AddTerminalDialogComponent, SelectProviderComponent, TerminalsTableComponent], - imports: [ - MatDialogModule, - MatButtonModule, - MatProgressBarModule, - CommonModule, - MatStepperModule, - FlexModule, - MatFormFieldModule, - MatInputModule, - MatTableModule, - MatCheckboxModule, - MatPaginatorModule, - ], -}) -export class AddTerminalDialogModule {} diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/index.ts b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/index.ts deleted file mode 100644 index 83762a90..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './select-provider'; -export * from './terminals-table'; diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/select-provider/index.ts b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/select-provider/index.ts deleted file mode 100644 index 4bf0d3c1..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/select-provider/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './select-provider.component'; diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/select-provider/select-provider.component.html b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/select-provider/select-provider.component.html deleted file mode 100644 index a23526be..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/select-provider/select-provider.component.html +++ /dev/null @@ -1,43 +0,0 @@ -
- - - -
- - - - - - - - - - - - - - - - - - - -
- - - ID{{ provider.ref.id }}Name{{ provider.data.name }}Description{{ provider.data.description }}
- - diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/select-provider/select-provider.component.scss b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/select-provider/select-provider.component.scss deleted file mode 100644 index a47b720e..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/select-provider/select-provider.component.scss +++ /dev/null @@ -1,8 +0,0 @@ -table { - width: 100%; -} - -.th, -.td { - padding: 5px 10px; -} diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/select-provider/select-provider.component.ts b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/select-provider/select-provider.component.ts deleted file mode 100644 index 71a2b7b8..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/select-provider/select-provider.component.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { SelectionModel } from '@angular/cdk/collections'; -import { - ChangeDetectionStrategy, - Component, - EventEmitter, - Input, - OnChanges, - OnInit, - Output, - SimpleChanges, - ViewChild, -} from '@angular/core'; -import { MatPaginator } from '@angular/material/paginator'; -import { MatTableDataSource } from '@angular/material/table'; -import { ProviderObject } from '@vality/domain-proto'; - -@Component({ - templateUrl: 'select-provider.component.html', - selector: 'cc-select-provider', - styleUrls: ['select-provider.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class SelectProviderComponent implements OnInit, OnChanges { - @Input() providers: ProviderObject[]; - - @Output() providerIDSelected: EventEmitter = new EventEmitter(); - - @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; - - displayedColumns: string[] = ['select', 'id', 'name', 'description']; - dataSource: MatTableDataSource = new MatTableDataSource([]); - selection = new SelectionModel(false, []); - - ngOnChanges(changes: SimpleChanges) { - const { providers } = changes; - if (providers.currentValue && providers.currentValue.length > 0) { - this.dataSource = new MatTableDataSource(providers.currentValue); - } - } - - ngOnInit() { - this.dataSource.paginator = this.paginator; - this.dataSource.filterPredicate = (provider: ProviderObject, filter: string) => - JSON.stringify(provider).toLowerCase().includes(filter); - this.selection.changed.subscribe(() => { - const providerSelection = Array.from(this.selection.selected.values()); - if (providerSelection.length > 0) { - this.providerIDSelected.emit(providerSelection[0].ref.id); - } - }); - } - - applyFilter(filterValue: string) { - this.dataSource.filter = filterValue.trim().toLowerCase(); - } -} diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/terminals-table/index.ts b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/terminals-table/index.ts deleted file mode 100644 index a3205f74..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/terminals-table/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './terminals-table.component'; diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/terminals-table/terminals-table.component.html b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/terminals-table/terminals-table.component.html deleted file mode 100644 index 3bf2d35d..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/terminals-table/terminals-table.component.html +++ /dev/null @@ -1,43 +0,0 @@ -
- - - -
- - - - - - - - - - - - - - - - - - - -
- - - ID{{ terminal.ref.id }}Name{{ terminal.data.name }}Description{{ terminal.data.description }}
- - diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/terminals-table/terminals-table.component.scss b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/terminals-table/terminals-table.component.scss deleted file mode 100644 index a47b720e..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/terminals-table/terminals-table.component.scss +++ /dev/null @@ -1,8 +0,0 @@ -table { - width: 100%; -} - -.th, -.td { - padding: 5px 10px; -} diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/terminals-table/terminals-table.component.ts b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/terminals-table/terminals-table.component.ts deleted file mode 100644 index d46542d7..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/components/terminals-table/terminals-table.component.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { SelectionModel } from '@angular/cdk/collections'; -import { - ChangeDetectionStrategy, - Component, - EventEmitter, - Input, - OnChanges, - OnInit, - Output, - SimpleChanges, - ViewChild, -} from '@angular/core'; -import { MatPaginator } from '@angular/material/paginator'; -import { MatTableDataSource } from '@angular/material/table'; -import { TerminalObject } from '@vality/domain-proto/lib/domain'; - -@Component({ - selector: 'cc-terminals-table', - templateUrl: 'terminals-table.component.html', - styleUrls: ['terminals-table.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class TerminalsTableComponent implements OnInit, OnChanges { - @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; - @Input() terminals: TerminalObject[]; - @Output() terminalIDSelected: EventEmitter = new EventEmitter(); - - displayedColumns: string[] = ['select', 'id', 'name', 'description']; - dataSource: MatTableDataSource = new MatTableDataSource([]); - selection = new SelectionModel(false, []); - - ngOnInit(): void { - this.dataSource.paginator = this.paginator; - this.dataSource.filterPredicate = (terminal: TerminalObject, filter: string) => - JSON.stringify(terminal).toLowerCase().includes(filter); - this.selection.changed.subscribe(() => { - const terminalSelection = Array.from(this.selection.selected.values()); - if (terminalSelection.length > 0) { - this.terminalIDSelected.emit(terminalSelection[0].ref.id); - } - }); - } - - ngOnChanges(changes: SimpleChanges): void { - const { terminals } = changes; - if (terminals.currentValue && terminals.currentValue.length > 0) { - this.dataSource = new MatTableDataSource(terminals.currentValue); - } - } - - applyFilter(filterValue: string) { - this.dataSource.filter = filterValue.trim().toLowerCase(); - } -} diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/index.ts b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/index.ts deleted file mode 100644 index d8c6dbae..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './add-terminal-dialog.module'; diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/services/add-terminal-decision/add-terminal-decision.service.ts b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/services/add-terminal-decision/add-terminal-decision.service.ts deleted file mode 100644 index ad156894..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/services/add-terminal-decision/add-terminal-decision.service.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { Injectable } from '@angular/core'; -import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; -import { PartyID, ProviderObject, ShopID } from '@vality/domain-proto/lib/domain'; -import { merge, Observable, Subject } from 'rxjs'; -import { map, shareReplay, switchMap } from 'rxjs/operators'; - -import { progress } from '@cc/app/shared/custom-operators'; - -import { AddDecisionToProvider, ProviderService } from '../../../../../../thrift-services/damsel'; -import { DomainStoreService } from '../../../../../../thrift-services/damsel/domain-store.service'; -import { addDecisionToProviderCommit } from '../../../../../../thrift-services/damsel/operations'; -import { - filterProvidersByCategoryId, - filterProvidersByTerminalSelector, -} from '../../../../../../thrift-services/filters'; - -@Injectable() -export class AddTerminalDecisionService { - private add$ = new Subject<{ shopID: ShopID; partyID: PartyID }>(); - - // eslint-disable-next-line @typescript-eslint/member-ordering - providerForm = this.prepareForm(); - // eslint-disable-next-line @typescript-eslint/member-ordering - terminalForm = this.prepareForm(); - // eslint-disable-next-line @typescript-eslint/member-ordering - error$ = new Subject(); - - // eslint-disable-next-line @typescript-eslint/member-ordering - terminalAdded$ = this.add$.pipe( - map((params) => ({ - ...params, - providerID: this.providerForm.value.id, - terminalID: this.terminalForm.value.id, - })), - switchMap((params) => - this.providerService.getProviderFromParams(params) - ), - switchMap(([params, providerObject]) => - this.domainStoreService.commit(addDecisionToProviderCommit(providerObject, params)) - ), - shareReplay(1) - ); - - // eslint-disable-next-line @typescript-eslint/member-ordering - inProgress$ = progress(this.add$, merge(this.terminalAdded$, this.error$)); - - constructor( - private domainStoreService: DomainStoreService, - private providerService: ProviderService, - private fb: UntypedFormBuilder - ) { - this.terminalAdded$.subscribe(); - } - - add(params: { shopID: ShopID; partyID: PartyID }) { - this.add$.next(params); - } - - getProviders(categoryID: number): Observable { - return this.domainStoreService.getObjects('provider').pipe( - map((objects) => filterProvidersByTerminalSelector(objects, 'decisions')), - map((objects) => filterProvidersByCategoryId(objects, categoryID)) - ); - } - - private prepareForm(): UntypedFormGroup { - return this.fb.group({ - id: ['', Validators.required], - }); - } -} diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/services/add-terminal-decision/index.ts b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/services/add-terminal-decision/index.ts deleted file mode 100644 index 95b59727..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/services/add-terminal-decision/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './add-terminal-decision.service'; diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/services/index.ts b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/services/index.ts deleted file mode 100644 index 344963e9..00000000 --- a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/services/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './add-terminal-decision'; diff --git a/src/app/sections/shop-details/shop-providers/add-terminal-dialog/types/index.ts b/src/app/sections/shop-details/shop-providers/add-terminal-dialog/types/index.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/src/app/sections/shop-details/shop-providers/components/edit-terminal-dialog/edit-terminal-dialog.component.html b/src/app/sections/shop-details/shop-providers/components/edit-terminal-dialog/edit-terminal-dialog.component.html deleted file mode 100644 index a83a5c3e..00000000 --- a/src/app/sections/shop-details/shop-providers/components/edit-terminal-dialog/edit-terminal-dialog.component.html +++ /dev/null @@ -1,39 +0,0 @@ -
- {{ data.type === terminalActionTypes.EditWeight ? 'Edit weight' : null }} - {{ data.type === terminalActionTypes.EditPriority ? 'Edit priority' : null }} -
- - - - - - -
- - - -
diff --git a/src/app/sections/shop-details/shop-providers/components/edit-terminal-dialog/edit-terminal-dialog.component.ts b/src/app/sections/shop-details/shop-providers/components/edit-terminal-dialog/edit-terminal-dialog.component.ts deleted file mode 100644 index 160a473f..00000000 --- a/src/app/sections/shop-details/shop-providers/components/edit-terminal-dialog/edit-terminal-dialog.component.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { ChangeDetectionStrategy, Component, Inject } from '@angular/core'; -import { UntypedFormControl, Validators } from '@angular/forms'; -import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { PartyID, ShopID } from '@vality/domain-proto'; -import { TerminalID } from '@vality/fistful-proto'; - -import { EditTerminalDecisionPropertyForShopService } from '../../../../../thrift-services/damsel'; -import { EditTerminalDialogResponse, TerminalActionTypes } from '../../types'; - -@Component({ - templateUrl: 'edit-terminal-dialog.component.html', - providers: [EditTerminalDecisionPropertyForShopService], - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class EditTerminalDialogComponent { - editValueControl = new UntypedFormControl('', [Validators.required]); - terminalActionTypes = TerminalActionTypes; - inProgress$ = this.editTerminalDecisionPropertyForShopService.inProgress$; - - constructor( - private editTerminalDecisionPropertyForShopService: EditTerminalDecisionPropertyForShopService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) - public data: { - type: TerminalActionTypes; - terminalID: TerminalID; - providerID: number; - shopID: ShopID; - partyID: PartyID; - } - ) { - this.editTerminalDecisionPropertyForShopService.edited$.subscribe(() => - this.dialogRef.close('edited') - ); - this.editTerminalDecisionPropertyForShopService.inProgress$.subscribe((progress) => { - if (progress) { - this.editValueControl.disable(); - } else { - this.editValueControl.enable(); - } - }); - } - - save() { - const editParams = { - providerID: this.data.providerID, - terminalID: this.data.terminalID, - partyID: this.data.partyID, - shopID: this.data.shopID, - value: this.editValueControl.value, - }; - switch (this.data.type) { - case TerminalActionTypes.EditWeight: - this.editTerminalDecisionPropertyForShopService.editTerminalDecisionPropertyForShop( - { - ...editParams, - property: 'weight', - } - ); - break; - case TerminalActionTypes.EditPriority: - this.editTerminalDecisionPropertyForShopService.editTerminalDecisionPropertyForShop( - { - ...editParams, - property: 'priority', - } - ); - break; - default: - console.error('Wrong terminal action!'); - } - } -} diff --git a/src/app/sections/shop-details/shop-providers/components/edit-terminal-dialog/index.ts b/src/app/sections/shop-details/shop-providers/components/edit-terminal-dialog/index.ts deleted file mode 100644 index 56443009..00000000 --- a/src/app/sections/shop-details/shop-providers/components/edit-terminal-dialog/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './edit-terminal-dialog.component'; diff --git a/src/app/sections/shop-details/shop-providers/components/index.ts b/src/app/sections/shop-details/shop-providers/components/index.ts deleted file mode 100644 index 67f7d87c..00000000 --- a/src/app/sections/shop-details/shop-providers/components/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './edit-terminal-dialog'; diff --git a/src/app/sections/shop-details/shop-providers/index.ts b/src/app/sections/shop-details/shop-providers/index.ts deleted file mode 100644 index 5d5c5d21..00000000 --- a/src/app/sections/shop-details/shop-providers/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './shop-providers.module'; diff --git a/src/app/sections/shop-details/shop-providers/provider/index.ts b/src/app/sections/shop-details/shop-providers/provider/index.ts deleted file mode 100644 index f0999b7e..00000000 --- a/src/app/sections/shop-details/shop-providers/provider/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './provider.module'; diff --git a/src/app/sections/shop-details/shop-providers/provider/provider.component.html b/src/app/sections/shop-details/shop-providers/provider/provider.component.html deleted file mode 100644 index 350f3902..00000000 --- a/src/app/sections/shop-details/shop-providers/provider/provider.component.html +++ /dev/null @@ -1,5 +0,0 @@ -
{{ providerInfo.provider.data.name }}
- diff --git a/src/app/sections/shop-details/shop-providers/provider/provider.component.ts b/src/app/sections/shop-details/shop-providers/provider/provider.component.ts deleted file mode 100644 index 6cffd5b4..00000000 --- a/src/app/sections/shop-details/shop-providers/provider/provider.component.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; -import { PartyID, ShopID } from '@vality/domain-proto'; - -import { ProviderInfo, TerminalAction } from '../types'; - -@Component({ - selector: 'cc-provider', - templateUrl: 'provider.component.html', - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class ProviderComponent { - @Input() - providerInfo: ProviderInfo; - - @Input() - partyID: PartyID; - - @Input() - shopID: ShopID; - - @Output() - action: EventEmitter = new EventEmitter(); -} diff --git a/src/app/sections/shop-details/shop-providers/provider/provider.module.ts b/src/app/sections/shop-details/shop-providers/provider/provider.module.ts deleted file mode 100644 index c1816eea..00000000 --- a/src/app/sections/shop-details/shop-providers/provider/provider.module.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { NgModule } from '@angular/core'; -import { FlexModule } from '@angular/flex-layout'; -import { MatCardModule } from '@angular/material/card'; - -import { ProviderComponent } from './provider.component'; -import { TerminalsInfoTableModule } from './terminals-info-table/terminals-info-table.module'; - -@NgModule({ - declarations: [ProviderComponent], - exports: [ProviderComponent], - imports: [MatCardModule, FlexModule, TerminalsInfoTableModule], -}) -export class ProviderModule {} diff --git a/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/is-active.pipe.ts b/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/is-active.pipe.ts deleted file mode 100644 index af9bb0fd..00000000 --- a/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/is-active.pipe.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; - -@Pipe({ - name: 'ccIsActive', -}) -export class IsActivePipe implements PipeTransform { - public transform(input: boolean): string { - return input ? 'Active' : 'Inactive'; - } -} diff --git a/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/terminals-info-table.component.html b/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/terminals-info-table.component.html deleted file mode 100644 index 9834ec2d..00000000 --- a/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/terminals-info-table.component.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name{{ terminalInfo.terminal.data.name }}Description - {{ terminalInfo.terminal.data.description }} - Type{{ terminalInfo.predicateType }}Priority - {{ terminalInfo.priority }} - Weight{{ terminalInfo.weight }}Status - {{ !terminalInfo.disabled | ccIsActive }} - - - - - - - -
diff --git a/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/terminals-info-table.component.scss b/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/terminals-info-table.component.scss deleted file mode 100644 index bdadd8bb..00000000 --- a/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/terminals-info-table.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -table { - width: 100%; -} diff --git a/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/terminals-info-table.component.ts b/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/terminals-info-table.component.ts deleted file mode 100644 index c1c0456a..00000000 --- a/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/terminals-info-table.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; -import { TerminalID } from '@vality/fistful-proto'; - -import { TerminalAction, TerminalActionTypes, TerminalInfo } from '../../types'; - -@Component({ - selector: 'cc-terminals-info-table', - styleUrls: ['terminals-info-table.component.scss'], - templateUrl: 'terminals-info-table.component.html', - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class TerminalsInfoTableComponent { - @Input() - terminalsInfo: TerminalInfo[]; - - @Output() action: EventEmitter = new EventEmitter(); - - displayedColumns = ['name', 'description', 'type', 'priority', 'weight', 'status', 'actions']; - terminalActionTypes = TerminalActionTypes; - - actions(type: TerminalActionTypes, terminalID: TerminalID) { - this.action.emit({ type, terminalID }); - } -} diff --git a/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/terminals-info-table.module.ts b/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/terminals-info-table.module.ts deleted file mode 100644 index 77d2ac2a..00000000 --- a/src/app/sections/shop-details/shop-providers/provider/terminals-info-table/terminals-info-table.module.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { NgModule } from '@angular/core'; -import { FlexModule } from '@angular/flex-layout'; -import { MatButtonModule } from '@angular/material/button'; -import { MatIconModule } from '@angular/material/icon'; -import { MatMenuModule } from '@angular/material/menu'; -import { MatTableModule } from '@angular/material/table'; - -import { IsActivePipe } from './is-active.pipe'; -import { TerminalsInfoTableComponent } from './terminals-info-table.component'; - -@NgModule({ - declarations: [TerminalsInfoTableComponent, IsActivePipe], - imports: [MatTableModule, FlexModule, MatButtonModule, MatIconModule, MatMenuModule], - exports: [TerminalsInfoTableComponent], -}) -export class TerminalsInfoTableModule {} diff --git a/src/app/sections/shop-details/shop-providers/services/add-provider/add-provider.service.ts b/src/app/sections/shop-details/shop-providers/services/add-provider/add-provider.service.ts deleted file mode 100644 index 006e7ea7..00000000 --- a/src/app/sections/shop-details/shop-providers/services/add-provider/add-provider.service.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Injectable } from '@angular/core'; -import { MatDialog } from '@angular/material/dialog'; -import { PartyID, ShopID } from '@vality/domain-proto'; -import { Subject } from 'rxjs'; -import { filter, shareReplay, switchMap } from 'rxjs/operators'; - -import { AddTerminalDialogComponent } from '../../add-terminal-dialog/add-terminal-dialog.component'; -import { AddTerminalDialogResponse } from '../../types/add-terminal-dialog-response'; - -@Injectable() -export class AddProviderService { - private add$ = new Subject<{ partyID: PartyID; shopID: ShopID; categoryID: number }>(); - - // eslint-disable-next-line @typescript-eslint/member-ordering - terminalAdded$ = this.add$.pipe( - switchMap((data) => - this.dialog - .open(AddTerminalDialogComponent, { - width: '760px', - disableClose: true, - data, - }) - .afterClosed() - .pipe(filter((response: AddTerminalDialogResponse) => response === 'added')) - ), - shareReplay(1) - ); - - constructor(private dialog: MatDialog) { - this.terminalAdded$.subscribe(); - } - - add(params: { partyID: PartyID; shopID: ShopID; categoryID: number }) { - this.add$.next(params); - } -} diff --git a/src/app/sections/shop-details/shop-providers/services/add-provider/index.ts b/src/app/sections/shop-details/shop-providers/services/add-provider/index.ts deleted file mode 100644 index b2982edc..00000000 --- a/src/app/sections/shop-details/shop-providers/services/add-provider/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './add-provider.service'; diff --git a/src/app/sections/shop-details/shop-providers/services/edit-terminal-decision/edit-terminal-decision.service.ts b/src/app/sections/shop-details/shop-providers/services/edit-terminal-decision/edit-terminal-decision.service.ts deleted file mode 100644 index c6d7ffb3..00000000 --- a/src/app/sections/shop-details/shop-providers/services/edit-terminal-decision/edit-terminal-decision.service.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Injectable } from '@angular/core'; -import { MatDialog } from '@angular/material/dialog'; -import { Subject } from 'rxjs'; -import { filter, shareReplay, switchMap } from 'rxjs/operators'; - -import { EditTerminalDialogComponent } from '../../components/edit-terminal-dialog'; -import { ChangeProviderParams, EditTerminalDialogResponse } from '../../types'; - -@Injectable() -export class EditTerminalDecisionService { - private edit$ = new Subject(); - - // eslint-disable-next-line @typescript-eslint/member-ordering - terminalChanged$ = this.edit$.pipe( - switchMap((data) => - this.dialog - .open(EditTerminalDialogComponent, { - width: '300px', - disableClose: true, - data, - }) - .afterClosed() - .pipe(filter((r: EditTerminalDialogResponse) => r === 'edited')) - ), - shareReplay(1) - ); - - constructor(private dialog: MatDialog) { - this.terminalChanged$.subscribe(); - } - - edit(params: ChangeProviderParams) { - this.edit$.next(params); - } -} diff --git a/src/app/sections/shop-details/shop-providers/services/edit-terminal-decision/index.ts b/src/app/sections/shop-details/shop-providers/services/edit-terminal-decision/index.ts deleted file mode 100644 index 9d70d7b9..00000000 --- a/src/app/sections/shop-details/shop-providers/services/edit-terminal-decision/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './edit-terminal-decision.service'; diff --git a/src/app/sections/shop-details/shop-providers/services/fetch-shop-providers/extract-terminals-info.ts b/src/app/sections/shop-details/shop-providers/services/fetch-shop-providers/extract-terminals-info.ts deleted file mode 100644 index 9406e91f..00000000 --- a/src/app/sections/shop-details/shop-providers/services/fetch-shop-providers/extract-terminals-info.ts +++ /dev/null @@ -1,171 +0,0 @@ -import { - Condition, - PartyID, - Predicate, - ShopID, - TerminalDecision, - TerminalObject, - TerminalRef, - TerminalSelector, -} from '@vality/domain-proto/lib/domain'; -import get from 'lodash-es/get'; - -import { getUnionKey, getUnionValue } from '@cc/utils/get-union-key'; - -import { findDomainObject } from '../../../../../thrift-services/damsel/operations/utils'; -import { - FlattenTerminalInfoGroup, - PredicateInfo, - PredicateType, - TerminalInfo, - TerminalInfoGroup, -} from '../../types'; - -function inPredicates(predicates: Set, shopID: ShopID, partyID: PartyID): boolean { - for (const predicate of predicates) { - if (extractPredicateInfo(predicate, shopID, partyID).shopPartyContain) { - return true; - } - } -} - -function inPartyCondition(condition: Condition, shopID: ShopID, partyID: PartyID): boolean { - const shopIs = get(condition.party, 'definition.shop_is'); - return condition.party?.id === partyID && shopIs === shopID; -} - -function isDisabled(allOf: Set): boolean { - const constant = Array.from(allOf).find((pre) => pre.constant !== null); - return constant ? constant.constant : false; -} - -function extractPredicateInfo( - predicate: Predicate, - shopID: ShopID, - partyID: PartyID -): PredicateInfo { - const v = getUnionValue(predicate); - switch (getUnionKey(predicate)) { - case 'all_of': - return { - shopPartyContain: inPredicates(v as Set, shopID, partyID), - predicateType: PredicateType.AllOf, - disabled: isDisabled(v as Set), - }; - case 'any_of': - return { - shopPartyContain: inPredicates(v as Set, shopID, partyID), - predicateType: PredicateType.AnyOf, - disabled: false, - }; - case 'is_not': - return extractPredicateInfo(v as Predicate, shopID, partyID); - case 'condition': - if (getUnionKey(v as Condition) === 'payment_tool') { - break; - } - return { - shopPartyContain: inPartyCondition(v as Condition, shopID, partyID), - predicateType: PredicateType.Condition, - disabled: false, - }; - } - return { - shopPartyContain: false, - }; -} - -const extractIdsFromValue = (value: TerminalRef[]): number[] => value.map((v) => v.id); - -function extractIdsFromDecisions(decisions: TerminalDecision[]): number[] { - return decisions.reduce((r, { then_ }) => { - if (then_.decisions) { - r = r.concat(extractIdsFromDecisions(then_.decisions)); - } - if (then_.value) { - r = r.concat(extractIdsFromValue(Array.from(then_.value))); - } - return r; - }, []); -} - -function extractIds({ decisions, value }: TerminalSelector): number[] { - if (decisions) { - return extractIdsFromDecisions(decisions); - } - if (value) { - return extractIdsFromValue(Array.from(value)); - } -} - -function extractWeights({ value }: TerminalSelector): number[] { - if (value) { - return Array.from(value).map(({ weight }) => weight); - } -} - -function extractPriorities({ value }: TerminalSelector): number[] { - if (value) { - return Array.from(value).map(({ priority }) => priority); - } -} - -const extractTerminalsInfoGroup = ( - decisions: TerminalDecision[], - shopID: ShopID, - partyID: PartyID -): TerminalInfoGroup[] => - decisions.reduce((r, { if_, then_ }) => { - const { shopPartyContain, disabled, predicateType } = extractPredicateInfo( - if_, - shopID, - partyID - ); - if (shopPartyContain) { - r = r.concat({ - terminalIds: extractIds(then_), - disabled, - predicateType, - weights: extractWeights(then_), - priorities: extractPriorities(then_), - }); - } - return r; - }, []); - -const flattenGroup = (group: TerminalInfoGroup[]): FlattenTerminalInfoGroup[] => - group.reduce( - (r, { terminalIds, disabled, predicateType, weights, priorities }) => [ - ...r, - ...terminalIds.map((terminalId, idx) => ({ - terminalId, - disabled, - predicateType, - weight: weights[idx], - priority: priorities[idx], - })), - ], - [] - ); - -const enrichWithTerminal = ( - groups: FlattenTerminalInfoGroup[], - terminalObjects: TerminalObject[] -): TerminalInfo[] => - groups.map((group) => ({ - terminal: findDomainObject(terminalObjects, group.terminalId), - disabled: group.disabled, - predicateType: group.predicateType, - weight: group.weight, - priority: group.priority, - })); - -export function extractTerminalsInfo( - decisions: TerminalDecision[], - terminalObjects: TerminalObject[], - shopID: ShopID, - partyID: PartyID -): TerminalInfo[] { - const extractedGroup = extractTerminalsInfoGroup(decisions, shopID, partyID); - return enrichWithTerminal(flattenGroup(extractedGroup), terminalObjects); -} diff --git a/src/app/sections/shop-details/shop-providers/services/fetch-shop-providers/fetch-shop-providers.service.ts b/src/app/sections/shop-details/shop-providers/services/fetch-shop-providers/fetch-shop-providers.service.ts deleted file mode 100644 index 5125538c..00000000 --- a/src/app/sections/shop-details/shop-providers/services/fetch-shop-providers/fetch-shop-providers.service.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Injectable } from '@angular/core'; -import { PartyID, ShopID } from '@vality/domain-proto'; -import { combineLatest, defer, ReplaySubject } from 'rxjs'; -import { map, shareReplay, startWith, switchMap } from 'rxjs/operators'; - -import { progress } from '@cc/app/shared/custom-operators'; - -import { DomainStoreService } from '../../../../../thrift-services/damsel/domain-store.service'; -import { toProvidersInfo } from './to-providers-info'; - -@Injectable() -export class FetchShopProvidersService { - providersInfo$ = defer(() => this.getProvidersInfo$).pipe( - switchMap(({ partyID, shopID }) => - combineLatest([ - this.domainStoreService.getObjects('provider'), - this.domainStoreService.getObjects('terminal'), - ]).pipe( - map(([providerObjects, terminalObjects]) => - toProvidersInfo(providerObjects, terminalObjects, partyID, shopID) - ) - ) - ), - shareReplay(1) - ); - - inProgress$ = progress( - defer(() => this.getProvidersInfo$), - this.providersInfo$ - ).pipe(startWith(true)); - - private getProvidersInfo$ = new ReplaySubject<{ partyID: PartyID; shopID: ShopID }>(1); - - constructor(private domainStoreService: DomainStoreService) { - this.providersInfo$.subscribe(); - } - - getProvidersInfo(partyID: PartyID, shopID: ShopID): void { - this.getProvidersInfo$.next({ partyID, shopID }); - } -} diff --git a/src/app/sections/shop-details/shop-providers/services/fetch-shop-providers/index.ts b/src/app/sections/shop-details/shop-providers/services/fetch-shop-providers/index.ts deleted file mode 100644 index f154f65a..00000000 --- a/src/app/sections/shop-details/shop-providers/services/fetch-shop-providers/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './fetch-shop-providers.service'; diff --git a/src/app/sections/shop-details/shop-providers/services/fetch-shop-providers/to-providers-info.ts b/src/app/sections/shop-details/shop-providers/services/fetch-shop-providers/to-providers-info.ts deleted file mode 100644 index 13ecda22..00000000 --- a/src/app/sections/shop-details/shop-providers/services/fetch-shop-providers/to-providers-info.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { ProviderObject, TerminalObject } from '@vality/domain-proto/lib/domain'; -import get from 'lodash-es/get'; - -import { ProviderInfo } from '../../types'; -import { extractTerminalsInfo } from './extract-terminals-info'; - -export const toProvidersInfo = ( - providers: ProviderObject[], - terminalObjects: TerminalObject[], - partyID: string, - shopID: string -): ProviderInfo[] => - providers.reduce((acc, provider) => { - const decisions = get(provider, 'data.terminal.decisions'); - if (!decisions) { - return acc; - } - const info = extractTerminalsInfo(decisions, terminalObjects, shopID, partyID); - if (info.length === 0) { - return acc; - } - return [ - ...acc, - { - provider, - terminalsInfo: info, - }, - ]; - }, []); diff --git a/src/app/sections/shop-details/shop-providers/services/index.ts b/src/app/sections/shop-details/shop-providers/services/index.ts deleted file mode 100644 index 294a7a18..00000000 --- a/src/app/sections/shop-details/shop-providers/services/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './fetch-shop-providers'; -export * from './remove-terminal-decision'; -export * from './edit-terminal-decision'; -export * from './add-provider'; diff --git a/src/app/sections/shop-details/shop-providers/services/remove-terminal-decision/index.ts b/src/app/sections/shop-details/shop-providers/services/remove-terminal-decision/index.ts deleted file mode 100644 index 2538120f..00000000 --- a/src/app/sections/shop-details/shop-providers/services/remove-terminal-decision/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './remove-terminal-decision.service'; diff --git a/src/app/sections/shop-details/shop-providers/services/remove-terminal-decision/remove-terminal-decision.service.ts b/src/app/sections/shop-details/shop-providers/services/remove-terminal-decision/remove-terminal-decision.service.ts deleted file mode 100644 index a6e573dc..00000000 --- a/src/app/sections/shop-details/shop-providers/services/remove-terminal-decision/remove-terminal-decision.service.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { Injectable } from '@angular/core'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { combineLatest, EMPTY, merge, of, Subject } from 'rxjs'; -import { catchError, filter, map, shareReplay, switchMap } from 'rxjs/operators'; - -import { progress } from '@cc/app/shared/custom-operators'; -import { BaseDialogResponseStatus } from '@cc/components/base-dialog'; -import { BaseDialogService } from '@cc/components/base-dialog/services/base-dialog.service'; -import { ConfirmActionDialogComponent } from '@cc/components/confirm-action-dialog'; - -import { ProviderService } from '../../../../../thrift-services/damsel'; -import { DomainStoreService } from '../../../../../thrift-services/damsel/domain-store.service'; -import { createRemoveTerminalFromShopCommit } from '../../../../../thrift-services/damsel/operations/create-remove-terminal-from-shop-commit'; -import { RemoveTerminalFromShopParams } from '../../../../../thrift-services/damsel/operations/remove-terminal-from-shop-params'; -import { ChangeProviderParams } from '../../types'; - -@Injectable() -export class RemoveTerminalDecisionService { - private remove$ = new Subject(); - - // eslint-disable-next-line @typescript-eslint/member-ordering - error$ = new Subject(); - // eslint-disable-next-line @typescript-eslint/member-ordering - cancelled$ = new Subject(); - - // eslint-disable-next-line @typescript-eslint/member-ordering - terminalRemoved$ = this.remove$.pipe( - switchMap((params) => - combineLatest([ - of(params), - this.baseDialogService - .open(ConfirmActionDialogComponent, { - title: `Remove this terminal from shop?`, - }) - .afterClosed() - .pipe( - filter(({ status }) => { - if (status === BaseDialogResponseStatus.Cancelled) { - this.cancelled$.next(); - } - return status === BaseDialogResponseStatus.Success; - }) - ), - ]) - ), - switchMap(([params]) => - this.providerService.getProviderFromParams(params) - ), - map(([params, providerObject]) => - createRemoveTerminalFromShopCommit(providerObject, params) - ), - switchMap((commit) => - this.domainStoreService.commit(commit).pipe( - catchError(() => { - this.error$.next(); - return EMPTY; - }) - ) - ), - shareReplay(1) - ); - - // eslint-disable-next-line @typescript-eslint/member-ordering - inProgress$ = progress( - this.remove$, - merge(this.terminalRemoved$, this.error$, this.cancelled$) - ); - - constructor( - private baseDialogService: BaseDialogService, - private snackBar: MatSnackBar, - private domainStoreService: DomainStoreService, - private providerService: ProviderService - ) { - this.terminalRemoved$.subscribe(); - this.error$.subscribe(() => { - this.snackBar.open('An error occurred while editing providerObject', 'OK'); - }); - } - - remove(params: ChangeProviderParams) { - this.remove$.next(params); - } -} diff --git a/src/app/sections/shop-details/shop-providers/shop-providers.component.html b/src/app/sections/shop-details/shop-providers/shop-providers.component.html deleted file mode 100644 index 0a15bc9f..00000000 --- a/src/app/sections/shop-details/shop-providers/shop-providers.component.html +++ /dev/null @@ -1,24 +0,0 @@ -
- -
-
- -
-
- -
- - diff --git a/src/app/sections/shop-details/shop-providers/shop-providers.component.ts b/src/app/sections/shop-details/shop-providers/shop-providers.component.ts deleted file mode 100644 index 36f0feca..00000000 --- a/src/app/sections/shop-details/shop-providers/shop-providers.component.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core'; -import { PartyID, ShopID } from '@vality/domain-proto'; -import { merge } from 'rxjs'; - -import { - AddProviderService, - EditTerminalDecisionService, - FetchShopProvidersService, - RemoveTerminalDecisionService, -} from './services'; -import { TerminalAction, TerminalActionTypes } from './types'; - -@Component({ - selector: 'cc-shop-providers', - templateUrl: 'shop-providers.component.html', - providers: [ - FetchShopProvidersService, - EditTerminalDecisionService, - RemoveTerminalDecisionService, - AddProviderService, - ], - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class ShopProvidersComponent implements OnInit { - @Input() - partyID: PartyID; - - @Input() - shopID: ShopID; - - @Input() - categoryID: number; - - providersInfo$ = this.fetchProvidersService.providersInfo$; - fetchProgress$ = this.fetchProvidersService.inProgress$; - removeProgress$ = this.removeTerminalDecisionService.inProgress$; - - constructor( - private fetchProvidersService: FetchShopProvidersService, - private editTerminalDecisionService: EditTerminalDecisionService, - private removeTerminalDecisionService: RemoveTerminalDecisionService, - private addProviderService: AddProviderService - ) { - merge([ - this.editTerminalDecisionService.terminalChanged$, - this.removeTerminalDecisionService.terminalRemoved$, - this.addProviderService.terminalAdded$, - ]).subscribe(() => this.getProviders()); - } - - ngOnInit() { - this.getProviders(); - } - - getProviders() { - this.fetchProvidersService.getProvidersInfo(this.partyID, this.shopID); - } - - action(action: TerminalAction, providerID: number) { - switch (action.type) { - case TerminalActionTypes.EditPriority: - case TerminalActionTypes.EditWeight: - this.editTerminalDecisionService.edit({ - ...action, - providerID, - partyID: this.partyID, - shopID: this.shopID, - }); - break; - case TerminalActionTypes.RemoveTerminal: - this.removeTerminalDecisionService.remove({ - ...action, - providerID, - partyID: this.partyID, - shopID: this.shopID, - }); - break; - } - } - - addTerminal() { - this.addProviderService.add({ - partyID: this.partyID, - shopID: this.shopID, - categoryID: this.categoryID, - }); - } -} diff --git a/src/app/sections/shop-details/shop-providers/shop-providers.module.ts b/src/app/sections/shop-details/shop-providers/shop-providers.module.ts deleted file mode 100644 index 0241b59d..00000000 --- a/src/app/sections/shop-details/shop-providers/shop-providers.module.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { FlexModule } from '@angular/flex-layout'; -import { ReactiveFormsModule } from '@angular/forms'; -import { MatButtonModule } from '@angular/material/button'; -import { MatDialogModule } from '@angular/material/dialog'; -import { MatFormFieldModule } from '@angular/material/form-field'; -import { MatInputModule } from '@angular/material/input'; -import { MatProgressBarModule } from '@angular/material/progress-bar'; -import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; - -import { EmptySearchResultModule } from '@cc/components/empty-search-result'; - -import { AddTerminalDialogModule } from './add-terminal-dialog'; -import { EditTerminalDialogComponent } from './components/edit-terminal-dialog'; -import { ProviderModule } from './provider'; -import { ShopProvidersComponent } from './shop-providers.component'; - -@NgModule({ - declarations: [ShopProvidersComponent, EditTerminalDialogComponent], - imports: [ - CommonModule, - FlexModule, - MatProgressSpinnerModule, - EmptySearchResultModule, - ProviderModule, - MatDialogModule, - MatFormFieldModule, - MatInputModule, - MatButtonModule, - MatProgressBarModule, - ReactiveFormsModule, - AddTerminalDialogModule, - ], - exports: [ShopProvidersComponent], -}) -export class ShopProvidersModule {} diff --git a/src/app/sections/shop-details/shop-providers/types/add-terminal-dialog-response.ts b/src/app/sections/shop-details/shop-providers/types/add-terminal-dialog-response.ts deleted file mode 100644 index 33a6134b..00000000 --- a/src/app/sections/shop-details/shop-providers/types/add-terminal-dialog-response.ts +++ /dev/null @@ -1 +0,0 @@ -export type AddTerminalDialogResponse = 'added' | 'canceled'; diff --git a/src/app/sections/shop-details/shop-providers/types/change-provider-params.ts b/src/app/sections/shop-details/shop-providers/types/change-provider-params.ts deleted file mode 100644 index 80f3f917..00000000 --- a/src/app/sections/shop-details/shop-providers/types/change-provider-params.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { PartyID, ShopID } from '@vality/domain-proto'; -import { TerminalID } from '@vality/fistful-proto'; - -import { TerminalActionTypes } from './terminal-action-types'; - -export interface ChangeProviderParams { - type: TerminalActionTypes; - terminalID: TerminalID; - providerID: number; - partyID: PartyID; - shopID: ShopID; -} diff --git a/src/app/sections/shop-details/shop-providers/types/edit-terminal-dialog-response.ts b/src/app/sections/shop-details/shop-providers/types/edit-terminal-dialog-response.ts deleted file mode 100644 index cd52b480..00000000 --- a/src/app/sections/shop-details/shop-providers/types/edit-terminal-dialog-response.ts +++ /dev/null @@ -1 +0,0 @@ -export type EditTerminalDialogResponse = 'edited' | 'canceled'; diff --git a/src/app/sections/shop-details/shop-providers/types/flatten-terminal-info-group.ts b/src/app/sections/shop-details/shop-providers/types/flatten-terminal-info-group.ts deleted file mode 100644 index e7feb24f..00000000 --- a/src/app/sections/shop-details/shop-providers/types/flatten-terminal-info-group.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TerminalID } from '@vality/fistful-proto'; -import Int64 from '@vality/thrift-ts/lib/int64'; - -import { PredicateType } from './predicate-type'; - -export interface FlattenTerminalInfoGroup { - terminalId: TerminalID; - disabled: boolean; - predicateType: PredicateType; - priority: Int64; - weight: Int64; -} diff --git a/src/app/sections/shop-details/shop-providers/types/index.ts b/src/app/sections/shop-details/shop-providers/types/index.ts deleted file mode 100644 index a3d4124c..00000000 --- a/src/app/sections/shop-details/shop-providers/types/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export * from './provider-info'; -export * from './flatten-terminal-info-group'; -export * from './predicate-info'; -export * from './terminal-info-group'; -export * from './terminal-info'; -export * from './terminal-action-types'; -export * from './terminal-action'; -export * from './edit-terminal-dialog-response'; -export * from './predicate-type'; -export * from './change-provider-params'; diff --git a/src/app/sections/shop-details/shop-providers/types/predicate-info.ts b/src/app/sections/shop-details/shop-providers/types/predicate-info.ts deleted file mode 100644 index af41b594..00000000 --- a/src/app/sections/shop-details/shop-providers/types/predicate-info.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { PredicateType } from './predicate-type'; - -export interface PredicateInfo { - shopPartyContain: boolean; - predicateType?: PredicateType; - disabled?: boolean; -} diff --git a/src/app/sections/shop-details/shop-providers/types/predicate-type.ts b/src/app/sections/shop-details/shop-providers/types/predicate-type.ts deleted file mode 100644 index 63b784ef..00000000 --- a/src/app/sections/shop-details/shop-providers/types/predicate-type.ts +++ /dev/null @@ -1,6 +0,0 @@ -export enum PredicateType { - Condition = 'condition', - IsNot = 'is_not', - AllOf = 'all_of', - AnyOf = 'any_of', -} diff --git a/src/app/sections/shop-details/shop-providers/types/provider-info.ts b/src/app/sections/shop-details/shop-providers/types/provider-info.ts deleted file mode 100644 index 8086cff7..00000000 --- a/src/app/sections/shop-details/shop-providers/types/provider-info.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ProviderObject } from '@vality/domain-proto/lib/domain'; - -import { TerminalInfo } from './terminal-info'; - -export interface ProviderInfo { - provider: ProviderObject; - terminalsInfo: TerminalInfo[]; -} diff --git a/src/app/sections/shop-details/shop-providers/types/terminal-action-types.ts b/src/app/sections/shop-details/shop-providers/types/terminal-action-types.ts deleted file mode 100644 index 9b36bf98..00000000 --- a/src/app/sections/shop-details/shop-providers/types/terminal-action-types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum TerminalActionTypes { - EditWeight = 'editWeight', - EditPriority = 'editPriority', - RemoveTerminal = 'removeTerminal', -} diff --git a/src/app/sections/shop-details/shop-providers/types/terminal-action.ts b/src/app/sections/shop-details/shop-providers/types/terminal-action.ts deleted file mode 100644 index 94ef8fe9..00000000 --- a/src/app/sections/shop-details/shop-providers/types/terminal-action.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { TerminalID } from '@vality/fistful-proto'; - -import { TerminalActionTypes } from './terminal-action-types'; - -export interface TerminalAction { - type: TerminalActionTypes; - terminalID: TerminalID; -} diff --git a/src/app/sections/shop-details/shop-providers/types/terminal-info-group.ts b/src/app/sections/shop-details/shop-providers/types/terminal-info-group.ts deleted file mode 100644 index 481898aa..00000000 --- a/src/app/sections/shop-details/shop-providers/types/terminal-info-group.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TerminalID } from '@vality/fistful-proto'; -import Int64 from '@vality/thrift-ts/lib/int64'; - -import { PredicateType } from './predicate-type'; - -export interface TerminalInfoGroup { - terminalIds: TerminalID[]; - weights: Int64[]; - priorities: Int64[]; - disabled: boolean; - predicateType: PredicateType; -} diff --git a/src/app/sections/shop-details/shop-providers/types/terminal-info.ts b/src/app/sections/shop-details/shop-providers/types/terminal-info.ts deleted file mode 100644 index 067b63d2..00000000 --- a/src/app/sections/shop-details/shop-providers/types/terminal-info.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TerminalObject } from '@vality/domain-proto/lib/domain'; -import Int64 from '@vality/thrift-ts/lib/int64'; - -import { PredicateType } from './predicate-type'; - -export interface TerminalInfo { - terminal: TerminalObject; - disabled: boolean; - predicateType: PredicateType; - weight: Int64; - priority: Int64; -} diff --git a/src/app/sections/withdrawals/withdrawals.component.html b/src/app/sections/withdrawals/withdrawals.component.html index dbb79224..c3aee8ea 100644 --- a/src/app/sections/withdrawals/withdrawals.component.html +++ b/src/app/sections/withdrawals/withdrawals.component.html @@ -20,11 +20,11 @@ Amount from - + Amount to - +
diff --git a/src/app/sections/withdrawals/withdrawals.component.ts b/src/app/sections/withdrawals/withdrawals.component.ts index 2c5a61d4..d6e8cbed 100644 --- a/src/app/sections/withdrawals/withdrawals.component.ts +++ b/src/app/sections/withdrawals/withdrawals.component.ts @@ -3,13 +3,16 @@ import { Component, OnInit } from '@angular/core'; import { FormBuilder } from '@angular/forms'; import { DateRange } from '@angular/material/datepicker'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; +import { omitBy } from '@s-libs/micro-dash'; import { PartyID } from '@vality/domain-proto'; import { StatWithdrawal } from '@vality/fistful-proto/lib/fistful_stat'; import { Moment } from 'moment'; +import { map } from 'rxjs/operators'; import { BaseDialogResponseStatus } from '../../../components/base-dialog'; import { BaseDialogService } from '../../../components/base-dialog/services/base-dialog.service'; import { SELECT_COLUMN_NAME } from '../../../components/table'; +import { isNilOrEmptyString } from '../../../utils'; import { WithdrawalParams } from '../../query-dsl'; import { QueryParamsService } from '../../shared/services'; import { ErrorService } from '../../shared/services/error'; @@ -72,7 +75,7 @@ export class WithdrawalsComponent implements OnInit { constructor( private fetchWithdrawalsService: FetchWithdrawalsService, private fb: FormBuilder, - private qp: QueryParamsService, + private qp: QueryParamsService>, private baseDialogService: BaseDialogService, private notificationService: NotificationService, private errorService: ErrorService @@ -80,8 +83,11 @@ export class WithdrawalsComponent implements OnInit { ngOnInit() { this.filters.valueChanges - .pipe(untilDestroyed(this)) - .subscribe((v) => this.qp.set(v as WithdrawalsForm)); + .pipe( + map((v) => omitBy(v, isNilOrEmptyString)), + untilDestroyed(this) + ) + .subscribe((v) => void this.qp.set(omitBy(v, isNilOrEmptyString))); this.qp.params$ .pipe(untilDestroyed(this)) .subscribe(({ dateRange, merchant, status, amountFrom, amountTo, withdrawalId }) => diff --git a/src/app/shared/components/merchant-field/merchant-field.component.ts b/src/app/shared/components/merchant-field/merchant-field.component.ts index effee7b9..7b20c835 100644 --- a/src/app/shared/components/merchant-field/merchant-field.component.ts +++ b/src/app/shared/components/merchant-field/merchant-field.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, Injector, Input, OnInit } from '@angular/core'; +import { Component, Injector, Input, OnInit } from '@angular/core'; import { MatSnackBar } from '@angular/material/snack-bar'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { PartyID } from '@vality/domain-proto'; @@ -16,7 +16,6 @@ import { DeanonimusService } from '../../../thrift-services/deanonimus'; @Component({ selector: 'cc-merchant-field', templateUrl: 'merchant-field.component.html', - changeDetection: ChangeDetectionStrategy.OnPush, providers: createControlProviders(MerchantFieldComponent), }) export class MerchantFieldComponent @@ -48,7 +47,7 @@ export class MerchantFieldComponent untilDestroyed(this) ) .subscribe((options) => this.options$.next(options)); - return super.ngOnInit(); + super.ngOnInit(); } private searchOptions(str: string): Observable[]> { diff --git a/src/app/shared/components/party-modification-creator/party-modification-target/target-table/target-table.service.ts b/src/app/shared/components/party-modification-creator/party-modification-target/target-table/target-table.service.ts index c920abbe..cb26974b 100644 --- a/src/app/shared/components/party-modification-creator/party-modification-target/target-table/target-table.service.ts +++ b/src/app/shared/components/party-modification-creator/party-modification-target/target-table/target-table.service.ts @@ -5,7 +5,7 @@ import { Contract, Party, PartyContractor, Shop } from '@vality/domain-proto/lib import { combineLatest, merge, Observable, of, Subject } from 'rxjs'; import { catchError, map, switchMap, tap, filter } from 'rxjs/operators'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; import { progress } from '@cc/app/shared/custom-operators'; import { PartyTarget } from '../party-target'; @@ -26,7 +26,7 @@ export class TargetTableService { tap(() => this.hasError$.next()), switchMap(({ partyID, targetName, fromClaim }) => combineLatest([ - this.partyManagementWithUserService.getParty(partyID).pipe( + this.partyManagementService.Get(partyID).pipe( map((party) => { const result = []; const target = this.getTarget(party, targetName); @@ -52,7 +52,7 @@ export class TargetTableService { inProgress$ = progress(this.getSelectableItems$, merge(this.selectableItems$, this.hasError$)); constructor( - private partyManagementWithUserService: PartyManagementWithUserService, + private partyManagementService: PartyManagementService, private snackBar: MatSnackBar ) {} diff --git a/src/app/shared/components/payments-search-filters/payments-main-search-filters/payments-main-search-filters.service.ts b/src/app/shared/components/payments-search-filters/payments-main-search-filters/payments-main-search-filters.service.ts index 57207422..21276750 100644 --- a/src/app/shared/components/payments-search-filters/payments-main-search-filters/payments-main-search-filters.service.ts +++ b/src/app/shared/components/payments-search-filters/payments-main-search-filters/payments-main-search-filters.service.ts @@ -5,7 +5,7 @@ import * as moment from 'moment'; import { ReplaySubject } from 'rxjs'; import { debounceTime, filter, map, shareReplay, switchMap } from 'rxjs/operators'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; import { SearchFiltersParams } from '../search-filters-params'; import { formValueToSearchParams } from './form-value-to-search-params'; @@ -37,13 +37,13 @@ export class PaymentsMainSearchFiltersService { // eslint-disable-next-line @typescript-eslint/member-ordering shops$ = this.getShops$.pipe( - switchMap((partyID) => this.partyManagementWithUserService.getParty(partyID)), + switchMap((partyID) => this.partyManagementService.Get(partyID)), map(({ shops }) => Array.from(shops.values())), shareReplay(1) ); constructor( - private partyManagementWithUserService: PartyManagementWithUserService, + private partyManagementService: PartyManagementService, private fb: UntypedFormBuilder ) {} diff --git a/src/app/shared/components/payout-tool-field/payout-tool-field.component.ts b/src/app/shared/components/payout-tool-field/payout-tool-field.component.ts index 4e3ff8fe..9343bb3d 100644 --- a/src/app/shared/components/payout-tool-field/payout-tool-field.component.ts +++ b/src/app/shared/components/payout-tool-field/payout-tool-field.component.ts @@ -6,7 +6,7 @@ import { coerceBoolean } from 'coerce-property'; import { BehaviorSubject, combineLatest, defer, Observable, of, Subject, switchMap } from 'rxjs'; import { catchError, map, pluck, shareReplay, startWith } from 'rxjs/operators'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; import { NotificationService } from '@cc/app/shared/services/notification'; import { Option } from '@cc/components/select-search-field'; import { createControlProviders, ValidatedControlSuperclass } from '@cc/utils/forms'; @@ -49,11 +49,11 @@ export class PayoutToolFieldComponent private payoutTools$ = combineLatest([this.partyId$, this.shopId$]).pipe( switchMap(([partyId, shopId]) => partyId && shopId - ? this.partyManagementWithUserService - .getShop(partyId, shopId) + ? this.partyManagementService + .GetShop(partyId, shopId) .pipe( switchMap(({ contract_id }) => - this.partyManagementWithUserService.getContract(partyId, contract_id) + this.partyManagementService.GetContract(partyId, contract_id) ), pluck('payout_tools') ) @@ -71,7 +71,7 @@ export class PayoutToolFieldComponent constructor( injector: Injector, - private partyManagementWithUserService: PartyManagementWithUserService, + private partyManagementService: PartyManagementService, private notificationService: NotificationService ) { super(injector); diff --git a/src/app/shared/components/shop-field/shop-field.component.ts b/src/app/shared/components/shop-field/shop-field.component.ts index dff812da..e278085e 100644 --- a/src/app/shared/components/shop-field/shop-field.component.ts +++ b/src/app/shared/components/shop-field/shop-field.component.ts @@ -13,7 +13,7 @@ import { coerceBoolean } from 'coerce-property'; import { BehaviorSubject, defer, of } from 'rxjs'; import { filter, map, share, switchMap } from 'rxjs/operators'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; import { ComponentChanges } from '@cc/app/shared/utils'; import { createControlProviders, ValidatedControlSuperclass } from '@cc/utils/forms'; @@ -40,8 +40,8 @@ export class ShopFieldComponent shops$ = defer(() => this.partyId$).pipe( switchMap((partyId) => partyId - ? this.partyManagementWithUserService - .getParty(partyId) + ? this.partyManagementService + .Get(partyId) .pipe(map(({ shops }) => Array.from(shops.values()))) : of([]) ), @@ -50,10 +50,7 @@ export class ShopFieldComponent private partyId$ = new BehaviorSubject(null); - constructor( - injector: Injector, - private partyManagementWithUserService: PartyManagementWithUserService - ) { + constructor(injector: Injector, private partyManagementService: PartyManagementService) { super(injector); } diff --git a/src/app/shared/pipes/api-model-types/shop-name.pipe.ts b/src/app/shared/pipes/api-model-types/shop-name.pipe.ts index e6968654..55201c3b 100644 --- a/src/app/shared/pipes/api-model-types/shop-name.pipe.ts +++ b/src/app/shared/pipes/api-model-types/shop-name.pipe.ts @@ -2,7 +2,7 @@ import { ChangeDetectorRef, OnDestroy, Pipe, PipeTransform } from '@angular/core import { BehaviorSubject, combineLatest, Subject } from 'rxjs'; import { distinctUntilChanged, map, pluck, switchMap, takeUntil } from 'rxjs/operators'; -import { PartyManagementWithUserService } from '@cc/app/api/payment-processing'; +import { PartyManagementService } from '@cc/app/api/payment-processing'; @Pipe({ name: 'shopName', @@ -15,13 +15,13 @@ export class ShopNamePipe implements PipeTransform, OnDestroy { private destroy$ = new Subject(); constructor( - private partyManagementWithUserService: PartyManagementWithUserService, + private partyManagementService: PartyManagementService, private ref: ChangeDetectorRef ) { combineLatest([ this.partyIDChange$.pipe( distinctUntilChanged(), - switchMap((id) => this.partyManagementWithUserService.getParty(id)), + switchMap((id) => this.partyManagementService.Get(id)), map(({ shops }) => Array.from(shops.values())) ), this.shopIDChange$.pipe(distinctUntilChanged()), diff --git a/src/app/shared/services/domain-metadata-form-extensions/utils/domains-objects-to-options.ts b/src/app/shared/services/domain-metadata-form-extensions/utils/domains-objects-to-options.ts index f1006e56..1e5dd0d1 100644 --- a/src/app/shared/services/domain-metadata-form-extensions/utils/domains-objects-to-options.ts +++ b/src/app/shared/services/domain-metadata-form-extensions/utils/domains-objects-to-options.ts @@ -26,6 +26,6 @@ export const DOMAIN_OBJECTS_TO_OPTIONS: { export function defaultDomainObjectToOption(o: DomainRefDataObjects[keyof DomainRefDataObjects]) { let label: string; if ('name' in o.data) label = o.data.name; - if ('id' in o.data && !label) label = o.data.id; + if ('id' in o.data && !label) label = (o.data as unknown as { id: string }).id; return { value: o.ref.id, label, details: o }; } diff --git a/src/app/thrift-services/converters/index.ts b/src/app/thrift-services/converters/index.ts index 2c0e3180..a1f7ea79 100644 --- a/src/app/thrift-services/converters/index.ts +++ b/src/app/thrift-services/converters/index.ts @@ -1,5 +1,4 @@ export * from './to-gen-terminal-object'; -export * from './to-gen-terminal-decision'; export * from './to-gen-domain-object'; export * from './to-gen-reference'; export * from './to-gen-commit'; diff --git a/src/app/thrift-services/converters/to-gen-terminal-decision.ts b/src/app/thrift-services/converters/to-gen-terminal-decision.ts deleted file mode 100644 index 2139c038..00000000 --- a/src/app/thrift-services/converters/to-gen-terminal-decision.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { - Condition, - PartyCondition, - PartyConditionDefinition, - Predicate, - TerminalDecision, - TerminalRef, - TerminalSelector, -} from '@vality/domain-proto/lib/domain'; -import * as DomainTypes from '@vality/domain-proto/lib/domain_config/gen-nodejs/domain_types'; - -const toPartyConditionDefinitionGen = (definition: PartyConditionDefinition) => { - const definitionGen = new DomainTypes.PartyConditionDefinition(); - definitionGen.shop_is = definition.shop_is; - return definitionGen; -}; - -const toPartyConditionGen = (partyCondition: PartyCondition) => { - const partyConditionGen = new DomainTypes.PartyCondition(); - partyConditionGen.id = partyCondition.id; - partyConditionGen.definition = toPartyConditionDefinitionGen(partyCondition.definition); - return partyConditionGen; -}; - -const toConditionGen = (condition: Condition) => { - const conditionDef = new DomainTypes.Condition(); - if (condition.party) { - conditionDef.party = toPartyConditionGen(condition.party); - } - return conditionDef; -}; - -const toPredicateGen = (predicate: Predicate) => { - const predicateGen = new DomainTypes.Predicate(); - if (predicate.condition) { - predicateGen.condition = toConditionGen(predicate.condition); - } - return predicateGen; -}; - -const toTerminalRefGen = (ref: TerminalRef) => { - const terminalRefGen = new DomainTypes.TerminalRef(); - terminalRefGen.id = ref.id; - return terminalRefGen; -}; - -const toTerminalSelectorGen = (selector: TerminalSelector) => { - const selectorGen = new DomainTypes.TerminalSelector(); - if (selector.value) { - selectorGen.value = Array.from(selector.value).map((ref) => toTerminalRefGen(ref)); - } - return selectorGen; -}; - -export const toGenTerminalDecision = (terminalDecision: TerminalDecision) => { - const terminalDecisionGen = new DomainTypes.TerminalDecision(); - terminalDecisionGen.if_ = toPredicateGen(terminalDecision.if_); - terminalDecisionGen.then_ = toTerminalSelectorGen(terminalDecision.then_); - return terminalDecisionGen; -}; diff --git a/src/app/thrift-services/damsel/damsel.module.ts b/src/app/thrift-services/damsel/damsel.module.ts index 03f07e8d..899285d7 100644 --- a/src/app/thrift-services/damsel/damsel.module.ts +++ b/src/app/thrift-services/damsel/damsel.module.ts @@ -5,15 +5,12 @@ import { DomainStoreService } from './domain-store.service'; import { DomainService } from './domain.service'; import { MerchantStatisticsService } from './merchant-statistics.service'; import { PaymentProcessingService } from './payment-processing.service'; -import { ProviderService } from './provider.service'; import { RoutingRulesModule } from './routing-rules'; -import { TerminalModule } from './terminal'; @NgModule({ - imports: [RoutingRulesModule, TerminalModule], + imports: [RoutingRulesModule], providers: [ DomainService, - ProviderService, PaymentProcessingService, MerchantStatisticsService, DomainStoreService, diff --git a/src/app/thrift-services/damsel/index.ts b/src/app/thrift-services/damsel/index.ts index 13209ff8..29c32c8a 100644 --- a/src/app/thrift-services/damsel/index.ts +++ b/src/app/thrift-services/damsel/index.ts @@ -1,8 +1,4 @@ -export * from './operations'; export * from './domain.service'; export * from './utils/create-damsel-instance'; export * from './damsel.module'; export * from './routing-rules'; -export * from './services'; -export * from './terminal'; -export * from './provider.service'; diff --git a/src/app/thrift-services/damsel/operations/add-decision-to-provider-commit.ts b/src/app/thrift-services/damsel/operations/add-decision-to-provider-commit.ts deleted file mode 100644 index dc3eed57..00000000 --- a/src/app/thrift-services/damsel/operations/add-decision-to-provider-commit.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { PartyID, ProviderObject, ShopID } from '@vality/domain-proto/lib/domain'; -import { Commit } from '@vality/domain-proto/lib/domain_config'; -import { TerminalID } from '@vality/fistful-proto'; - -import { createAddTerminalToProviderOperation } from './create-add-terminal-to-provider-operation'; - -export class AddDecisionToProvider { - partyID: PartyID; - shopID: ShopID; - terminalID: TerminalID; - providerID: number; -} - -export const addDecisionToProviderCommit = ( - providerObject: ProviderObject, - params: AddDecisionToProvider -): Commit => ({ - ops: [ - { - update: createAddTerminalToProviderOperation(providerObject, params), - }, - ], -}); diff --git a/src/app/thrift-services/damsel/operations/add-terminal-decision.ts b/src/app/thrift-services/damsel/operations/add-terminal-decision.ts deleted file mode 100644 index 497de4d3..00000000 --- a/src/app/thrift-services/damsel/operations/add-terminal-decision.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { - PartyID, - ProviderObject, - ShopID, - TerminalDecision, - TerminalRef, -} from '@vality/domain-proto/lib/domain'; -import cloneDeep from 'lodash-es/cloneDeep'; -// eslint-disable-next-line you-dont-need-lodash-underscore/drop-right -import dropRight from 'lodash-es/dropRight'; -// eslint-disable-next-line you-dont-need-lodash-underscore/last -import last from 'lodash-es/last'; - -import { toGenTerminalDecision } from '../../converters'; -import { checkSelector } from './utils'; - -const createDecision = ( - partyID: PartyID, - shopID: ShopID, - terminalID: number -): TerminalDecision => ({ - if_: { - condition: { - party: { - id: partyID, - definition: { - shop_is: shopID, - }, - }, - }, - }, - then_: { - value: [{ id: terminalID }] as unknown as Set, - }, -}); - -const addDecision = ( - decisions: TerminalDecision[], - newDecision: TerminalDecision -): TerminalDecision[] => { - let result; - if (!decisions || decisions.length === 0) { - result = [newDecision]; - } else { - result = dropRight(decisions).concat([newDecision, last(decisions)]); - } - return result; -}; - -export const addTerminalDecision = ( - providerObject: ProviderObject, - partyID: PartyID, - shopID: ShopID, - terminalID: number -): ProviderObject => { - checkSelector(providerObject.data.terminal); - const result = cloneDeep(providerObject); - const decision = toGenTerminalDecision(createDecision(partyID, shopID, terminalID)); - result.data.terminal.decisions = addDecision(providerObject.data.terminal.decisions, decision); - return result; -}; diff --git a/src/app/thrift-services/damsel/operations/create-add-terminal-to-provider-operation.ts b/src/app/thrift-services/damsel/operations/create-add-terminal-to-provider-operation.ts deleted file mode 100644 index 38837d04..00000000 --- a/src/app/thrift-services/damsel/operations/create-add-terminal-to-provider-operation.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { ProviderObject } from '@vality/domain-proto/lib/domain'; -import { UpdateOp } from '@vality/domain-proto/lib/domain_config'; - -import { AddDecisionToProvider } from './add-decision-to-provider-commit'; -import { addTerminalDecision } from './add-terminal-decision'; - -export const createAddTerminalToProviderOperation = ( - providerObject: ProviderObject, - params: AddDecisionToProvider -): UpdateOp => ({ - old_object: { provider: providerObject }, - new_object: { - provider: addTerminalDecision( - providerObject, - params.partyID, - params.shopID, - params.terminalID - ), - }, -}); diff --git a/src/app/thrift-services/damsel/operations/create-remove-terminal-from-provider-operation.ts b/src/app/thrift-services/damsel/operations/create-remove-terminal-from-provider-operation.ts deleted file mode 100644 index b2e4cb07..00000000 --- a/src/app/thrift-services/damsel/operations/create-remove-terminal-from-provider-operation.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { ProviderObject } from '@vality/domain-proto/lib/domain'; -import { UpdateOp } from '@vality/domain-proto/lib/domain_config'; - -import { removeTerminalDecision } from './remove-terminal-decision'; -import { RemoveTerminalFromShopParams } from './remove-terminal-from-shop-params'; - -export const createRemoveTerminalFromProviderOperation = ( - providerObject: ProviderObject, - params: RemoveTerminalFromShopParams -): UpdateOp => ({ - old_object: { provider: providerObject }, - new_object: { - provider: removeTerminalDecision( - providerObject, - params.partyID, - params.shopID, - params.terminalID - ), - }, -}); diff --git a/src/app/thrift-services/damsel/operations/create-remove-terminal-from-shop-commit.ts b/src/app/thrift-services/damsel/operations/create-remove-terminal-from-shop-commit.ts deleted file mode 100644 index 7a2160ec..00000000 --- a/src/app/thrift-services/damsel/operations/create-remove-terminal-from-shop-commit.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ProviderObject } from '@vality/domain-proto/lib/domain'; -import { Commit } from '@vality/domain-proto/lib/domain_config'; - -import { createRemoveTerminalFromProviderOperation } from './create-remove-terminal-from-provider-operation'; -import { RemoveTerminalFromShopParams } from './remove-terminal-from-shop-params'; - -export const createRemoveTerminalFromShopCommit = ( - providerObject: ProviderObject, - params: RemoveTerminalFromShopParams -): Commit => ({ - ops: [ - { - update: createRemoveTerminalFromProviderOperation(providerObject, params), - }, - ], -}); diff --git a/src/app/thrift-services/damsel/operations/create-terminal-object.ts b/src/app/thrift-services/damsel/operations/create-terminal-object.ts deleted file mode 100644 index 757be50a..00000000 --- a/src/app/thrift-services/damsel/operations/create-terminal-object.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { TerminalObject } from '@vality/domain-proto/lib/domain'; - -import { CreateTerminalParams } from './create-terminal-params'; -import { generateId, toMap } from './utils'; - -const convert = (id: number, params: CreateTerminalParams): TerminalObject => ({ - ref: { - id, - }, - data: { - name: params.terminalName, - description: params.terminalDescription, - risk_coverage: params.riskCoverage, - options: toMap(params.options), - }, -}); - -export interface CreateTerminalObject { - id: number; - terminal: TerminalObject; -} - -export const createTerminalObject = ( - terminalObjects: TerminalObject[], - params: CreateTerminalParams -): CreateTerminalObject => { - const id = generateId(terminalObjects); - return { terminal: convert(id, params), id }; -}; diff --git a/src/app/thrift-services/damsel/operations/create-terminal-params.ts b/src/app/thrift-services/damsel/operations/create-terminal-params.ts deleted file mode 100644 index 18d4a5c1..00000000 --- a/src/app/thrift-services/damsel/operations/create-terminal-params.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { RiskScore } from '@vality/domain-proto/lib/domain'; - -export class TerminalOption { - key: string; - value: string; -} - -export class CreateTerminalParams { - terminalName: string; - terminalDescription: string; - riskCoverage: RiskScore; - options: TerminalOption[]; -} diff --git a/src/app/thrift-services/damsel/operations/edit-terminal-decision-operations.ts b/src/app/thrift-services/damsel/operations/edit-terminal-decision-operations.ts deleted file mode 100644 index 8cc329f8..00000000 --- a/src/app/thrift-services/damsel/operations/edit-terminal-decision-operations.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ProviderObject } from '@vality/domain-proto/lib/domain'; -import { UpdateOp } from '@vality/domain-proto/lib/domain_config'; - -import { editTerminalDecisionPropertyForShop } from './edit-terminal-decision-property-for-shop'; -import { EditTerminalDecisionPropertyParams } from './edit-terminal-decision-property-params'; - -export const editTerminalDecisionPropertyForShopOperation = ( - providerObject: ProviderObject, - params: EditTerminalDecisionPropertyParams -): UpdateOp => ({ - old_object: { provider: providerObject }, - new_object: { - provider: editTerminalDecisionPropertyForShop(providerObject, params), - }, -}); diff --git a/src/app/thrift-services/damsel/operations/edit-terminal-decision-property-for-shop-commit.ts b/src/app/thrift-services/damsel/operations/edit-terminal-decision-property-for-shop-commit.ts deleted file mode 100644 index 13e728cc..00000000 --- a/src/app/thrift-services/damsel/operations/edit-terminal-decision-property-for-shop-commit.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ProviderObject } from '@vality/domain-proto/lib/domain'; -import { Commit } from '@vality/domain-proto/lib/domain_config'; - -import { editTerminalDecisionPropertyForShopOperation } from './edit-terminal-decision-operations'; -import { EditTerminalDecisionPropertyParams } from './edit-terminal-decision-property-params'; - -export const editTerminalDecisionPropertyForShopCommit = ( - providerObject: ProviderObject, - params: EditTerminalDecisionPropertyParams -): Commit => ({ - ops: [ - { - update: editTerminalDecisionPropertyForShopOperation(providerObject, params), - }, - ], -}); diff --git a/src/app/thrift-services/damsel/operations/edit-terminal-decision-property-for-shop.ts b/src/app/thrift-services/damsel/operations/edit-terminal-decision-property-for-shop.ts deleted file mode 100644 index 892f1674..00000000 --- a/src/app/thrift-services/damsel/operations/edit-terminal-decision-property-for-shop.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { PartyID, ProviderObject, ShopID, TerminalDecision } from '@vality/domain-proto/lib/domain'; -import cloneDeep from 'lodash-es/cloneDeep'; -import get from 'lodash-es/get'; - -import { EditTerminalDecisionPropertyParams } from './edit-terminal-decision-property-params'; -import { checkSelector } from './utils'; - -const editDecision = ( - decisions: TerminalDecision[], - partyID: PartyID, - shopID: ShopID, - terminalID: number, - property: string, - value: any -): TerminalDecision[] => - decisions.reduce((acc: TerminalDecision[], decision: TerminalDecision) => { - const decisionPredicatePartyID = get(decision, 'if_.condition.party.id'); - const decisionPredicateShopID = get(decision, 'if_.condition.party.definition.shop_is'); - if (decisionPredicatePartyID === partyID && decisionPredicateShopID === shopID) { - const terminalIndex = decision.then_.value - ? Array.from(decision.then_.value).findIndex((item) => item.id === terminalID) - : -1; - if (terminalIndex !== -1) { - Array.from(decision.then_.value)[terminalIndex][property] = value; - } - } - return acc.concat(decision); - }, []); - -export const editTerminalDecisionPropertyForShop = ( - providerObject: ProviderObject, - params: EditTerminalDecisionPropertyParams -): ProviderObject => { - checkSelector(providerObject.data.terminal); - const result = cloneDeep(providerObject); - result.data.terminal.decisions = editDecision( - result.data.terminal.decisions, - params.partyID, - params.shopID, - params.terminalID, - params.property, - params.value - ); - return result; -}; diff --git a/src/app/thrift-services/damsel/operations/edit-terminal-decision-property-params.ts b/src/app/thrift-services/damsel/operations/edit-terminal-decision-property-params.ts deleted file mode 100644 index 59b1180b..00000000 --- a/src/app/thrift-services/damsel/operations/edit-terminal-decision-property-params.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { PartyID, ShopID } from '@vality/domain-proto'; -import { TerminalID } from '@vality/fistful-proto'; - -export class EditTerminalDecisionPropertyParams { - providerID: number; - terminalID: TerminalID; - partyID: PartyID; - shopID: ShopID; - property: 'weight' | 'priority'; - value: number; -} diff --git a/src/app/thrift-services/damsel/operations/get-create-terminal-commit.ts b/src/app/thrift-services/damsel/operations/get-create-terminal-commit.ts deleted file mode 100644 index c7f1eb7d..00000000 --- a/src/app/thrift-services/damsel/operations/get-create-terminal-commit.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { TerminalObject } from '@vality/domain-proto/lib/domain'; -import { Commit } from '@vality/domain-proto/lib/domain_config'; - -import { createTerminalObject } from './create-terminal-object'; -import { CreateTerminalParams } from './create-terminal-params'; - -export interface GetCreateTerminalCommit { - commit: Commit; - id: number; -} - -export const getCreateTerminalCommit = ( - terminalObjects: TerminalObject[], - params: CreateTerminalParams -): GetCreateTerminalCommit => { - const { terminal, id } = createTerminalObject(terminalObjects, params); - return { - commit: { - ops: [ - { - insert: { - object: { terminal }, - }, - }, - ], - }, - id, - }; -}; diff --git a/src/app/thrift-services/damsel/operations/index.ts b/src/app/thrift-services/damsel/operations/index.ts deleted file mode 100644 index 840bbc7d..00000000 --- a/src/app/thrift-services/damsel/operations/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './add-decision-to-provider-commit'; -export * from './add-terminal-decision'; -export * from './create-terminal-object'; -export * from './create-terminal-params'; -export * from './get-create-terminal-commit'; -export * from './create-remove-terminal-from-provider-operation'; -export * from './remove-terminal-decision'; diff --git a/src/app/thrift-services/damsel/operations/remove-terminal-decision.ts b/src/app/thrift-services/damsel/operations/remove-terminal-decision.ts deleted file mode 100644 index f4476804..00000000 --- a/src/app/thrift-services/damsel/operations/remove-terminal-decision.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { PartyID, ProviderObject, ShopID, TerminalDecision } from '@vality/domain-proto/lib/domain'; -import cloneDeep from 'lodash-es/cloneDeep'; - -import { checkSelector } from './utils'; - -const checkCondition = (condition: any, partyID: PartyID, shopID: ShopID): boolean => { - const isPartyEquals = condition.party.id === partyID; - const isShopEquals = condition.party.definition.shop_is === shopID; - return isPartyEquals && isShopEquals; -}; - -const filterDecision = ( - decision: TerminalDecision, - partyID: PartyID, - shopID: ShopID -): TerminalDecision => { - const { condition, any_of } = decision.if_; - if (condition && condition.party) { - const matched = checkCondition(condition, partyID, shopID); - return matched ? null : decision; - } - if (any_of) { - const newPredicates = [...decision.if_.any_of].filter((predicate: any) => { - if (predicate.condition) { - return !checkCondition(predicate.condition, partyID, shopID); - } - return true; - }); - if (newPredicates.length > 0) { - decision.if_.any_of = new Set(newPredicates); - } else { - return null; - } - } - return decision; -}; - -const removeDecision = ( - decisions: TerminalDecision[], - partyID: PartyID, - shopID: ShopID, - terminalID: number -): TerminalDecision[] => - decisions.reduce((acc: TerminalDecision[], decision: TerminalDecision) => { - const isTerminalMatched = - decision.then_.value && - Array.from(decision.then_.value) - .map((item) => item.id) - .includes(terminalID); - if (isTerminalMatched) { - const newDecision = filterDecision(decision, partyID, shopID); - return newDecision ? acc.concat(newDecision) : acc; - } - return acc.concat(decision); - }, []); - -export const removeTerminalDecision = ( - providerObject: ProviderObject, - partyID: PartyID, - shopID: ShopID, - terminalID: number -): ProviderObject => { - checkSelector(providerObject.data.terminal); - const result = cloneDeep(providerObject); - result.data.terminal.decisions = removeDecision( - result.data.terminal.decisions, - partyID, - shopID, - terminalID - ); - return result; -}; diff --git a/src/app/thrift-services/damsel/operations/remove-terminal-from-shop-params.ts b/src/app/thrift-services/damsel/operations/remove-terminal-from-shop-params.ts deleted file mode 100644 index 566ac354..00000000 --- a/src/app/thrift-services/damsel/operations/remove-terminal-from-shop-params.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { PartyID, ShopID } from '@vality/domain-proto'; -import { TerminalID } from '@vality/fistful-proto'; - -export class RemoveTerminalFromShopParams { - partyID: PartyID; - shopID: ShopID; - terminalID: TerminalID; - providerID: number; -} diff --git a/src/app/thrift-services/damsel/operations/utils.ts b/src/app/thrift-services/damsel/operations/utils.ts deleted file mode 100644 index dc69cc36..00000000 --- a/src/app/thrift-services/damsel/operations/utils.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { TerminalSelector } from '@vality/domain-proto/lib/domain'; - -export const generateId = (objectsWithRefId: { ref: { id: number } }[]): number => { - const ids = objectsWithRefId.map(({ ref }) => ref.id); - return Math.max(...ids) + 1; -}; - -export const toMap = (domainMap: { key: any; value: any }[]): Map => { - const result = new Map(); - domainMap.forEach((item) => result.set(item.key, item.value)); - return result; -}; - -export const findDomainObject = ( - domainObjects: T[], - id: number | string -): T => domainObjects.find((object) => object.ref.id === id); - -export const checkSelector = (selector: TerminalSelector) => { - if (selector.value) { - throw new Error( - 'Wrong ProviderObject terminal selector: "value". Expected ProviderObject with terminal decisions' - ); - } -}; diff --git a/src/app/thrift-services/damsel/payment-processing.service.ts b/src/app/thrift-services/damsel/payment-processing.service.ts index 56ab1d3a..07297d12 100644 --- a/src/app/thrift-services/damsel/payment-processing.service.ts +++ b/src/app/thrift-services/damsel/payment-processing.service.ts @@ -10,15 +10,12 @@ import { InvoicePaymentAdjustmentParams, InvoicePaymentChargebackParams, InvoiceRepairScenario, - UserInfo, } from '@vality/domain-proto/lib/payment_processing'; import * as Invoicing from '@vality/domain-proto/lib/payment_processing/gen-nodejs/Invoicing'; import { InvoicePaymentAdjustmentParams as InvoicePaymentAdjustmentParamsObject, InvoiceRepairScenario as InvoiceRepairScenarioObject, - UserInfo as UserInfoObject, } from '@vality/domain-proto/lib/payment_processing/gen-nodejs/payment_processing_types'; -import { KeycloakService } from 'keycloak-angular'; import { Observable, timer } from 'rxjs'; import { first, map, share, switchMap } from 'rxjs/operators'; @@ -28,44 +25,30 @@ import { createDamselInstance, damselInstanceToObject } from './utils/create-dam @Injectable() export class PaymentProcessingService extends ThriftService { - constructor( - zone: NgZone, - keycloakTokenInfoService: KeycloakTokenInfoService, - private keycloakService: KeycloakService - ) { + constructor(zone: NgZone, keycloakTokenInfoService: KeycloakTokenInfoService) { super(zone, keycloakTokenInfoService, '/v1/processing/invoicing', Invoicing); } getPaymentAdjustment = ( - user: UserInfo, id: string, paymentId: string, paymentAdjustmentId: string ): Observable => - this.toObservableAction('GetPaymentAdjustment')( - new UserInfoObject(user), - id, - paymentId, - paymentAdjustmentId - ); + this.toObservableAction('GetPaymentAdjustment')(id, paymentId, paymentAdjustmentId); createPaymentAdjustment = ( - user: UserInfo, id: string, paymentId: string, params: InvoicePaymentAdjustmentParams ): Observable => this.toObservableAction('CreatePaymentAdjustment')( - new UserInfoObject(user), id, paymentId, new InvoicePaymentAdjustmentParamsObject(params) ).pipe( switchMap((paymentAdjustment: InvoicePaymentAdjustment) => timer(1000, 2500).pipe( - switchMap(() => - this.getPaymentAdjustment(user, id, paymentId, paymentAdjustment.id) - ), + switchMap(() => this.getPaymentAdjustment(id, paymentId, paymentAdjustment.id)), first(({ status }: InvoicePaymentAdjustment) => !status.pending) ) ), @@ -73,38 +56,21 @@ export class PaymentProcessingService extends ThriftService { ); capturePaymentAdjustment = ( - user: UserInfo, id: string, paymentId: string, adjustmentId: string ): Observable => - this.toObservableAction('CapturePaymentAdjustment')( - new UserInfoObject(user), - id, - paymentId, - adjustmentId - ); + this.toObservableAction('CapturePaymentAdjustment')(id, paymentId, adjustmentId); cancelPaymentAdjustment = ( - user: UserInfo, id: string, paymentId: string, adjustmentId: string ): Observable => - this.toObservableAction('CancelPaymentAdjustment')( - new UserInfoObject(user), - id, - paymentId, - adjustmentId - ); + this.toObservableAction('CancelPaymentAdjustment')(id, paymentId, adjustmentId); - repairWithScenario = ( - user: UserInfo, - id: InvoiceID, - scenario: InvoiceRepairScenario - ): Observable => + repairWithScenario = (id: InvoiceID, scenario: InvoiceRepairScenario): Observable => this.toObservableAction('RepairWithScenario')( - new UserInfoObject(user), id, new InvoiceRepairScenarioObject(scenario) ); @@ -115,7 +81,6 @@ export class PaymentProcessingService extends ThriftService { params: InvoicePaymentChargebackParams ): Observable => this.toObservableAction('CreateChargeback')( - this.getUser(), createDamselInstance('domain', 'InvoiceID', invoiceID), createDamselInstance('domain', 'InvoicePaymentID', paymentID), createDamselInstance('payment_processing', 'InvoicePaymentChargebackParams', params) @@ -127,16 +92,8 @@ export class PaymentProcessingService extends ThriftService { chargebackID: InvoicePaymentChargebackID ): Observable => this.toObservableAction('GetPaymentChargeback')( - this.getUser(), createDamselInstance('domain', 'InvoiceID', invoiceID), createDamselInstance('domain', 'InvoicePaymentID', paymentID), createDamselInstance('domain', 'InvoicePaymentChargebackID', chargebackID) ).pipe(map((r) => damselInstanceToObject('domain', 'InvoicePaymentChargeback', r))); - - private getUser(): UserInfo { - return createDamselInstance('payment_processing', 'UserInfo', { - id: this.keycloakService.getUsername(), - type: { internal_user: {} }, - }); - } } diff --git a/src/app/thrift-services/damsel/provider.service.ts b/src/app/thrift-services/damsel/provider.service.ts deleted file mode 100644 index d5197fa7..00000000 --- a/src/app/thrift-services/damsel/provider.service.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Injectable } from '@angular/core'; -import { ProviderObject } from '@vality/domain-proto/lib/domain'; -import { combineLatest, Observable, of } from 'rxjs'; -import { map, take } from 'rxjs/operators'; - -import { DomainStoreService } from './domain-store.service'; -import { findDomainObject } from './operations/utils'; - -@Injectable() -export class ProviderService { - constructor(private domainStoreService: DomainStoreService) {} - - getProviderFromParams( - p: T - ): Observable { - return combineLatest([of(p), this.domainStoreService.getObjects('provider')]).pipe( - take(1), - map( - ([params, providerObject]) => - [params, findDomainObject(providerObject, params.providerID)] as const - ) - ); - } -} diff --git a/src/app/thrift-services/damsel/routing-rules/routing-rules.service.ts b/src/app/thrift-services/damsel/routing-rules/routing-rules.service.ts index 5f3cff6b..5862edb9 100644 --- a/src/app/thrift-services/damsel/routing-rules/routing-rules.service.ts +++ b/src/app/thrift-services/damsel/routing-rules/routing-rules.service.ts @@ -1,14 +1,15 @@ import { Injectable } from '@angular/core'; import { + Terminal, Predicate, RoutingCandidate, RoutingDelegate, RoutingRulesObject, -} from '@vality/domain-proto/lib/domain'; +} from '@vality/domain-proto'; import { Version } from '@vality/domain-proto/lib/domain_config'; import cloneDeep from 'lodash-es/cloneDeep'; import { combineLatest, Observable } from 'rxjs'; -import { map, pluck, shareReplay, switchMap, take } from 'rxjs/operators'; +import { first, map, pluck, shareReplay, switchMap, take } from 'rxjs/operators'; import { DomainStoreService } from '../domain-store.service'; import { createNextId } from './utils/create-next-id'; @@ -431,6 +432,27 @@ export class RoutingRulesService { ); } + createTerminal(terminal: Terminal): Observable { + return this.domainStoreService.getObjects('terminal').pipe( + first(), + map((objs) => objs.map(({ ref }) => ref.id)), + map(createNextId), + switchMap((id) => { + return this.domainStoreService.commit({ + ops: [ + { + insert: { + object: { + terminal: { ref: { id }, data: terminal }, + }, + }, + }, + ], + }); + }) + ); + } + cloneDelegateRuleset({ mainRulesetRefID, delegateIdx, diff --git a/src/app/thrift-services/damsel/services/edit-terminal-decision-property-for-shop.service.ts b/src/app/thrift-services/damsel/services/edit-terminal-decision-property-for-shop.service.ts deleted file mode 100644 index 47279c82..00000000 --- a/src/app/thrift-services/damsel/services/edit-terminal-decision-property-for-shop.service.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { Injectable } from '@angular/core'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { EMPTY, merge, Subject } from 'rxjs'; -import { catchError, shareReplay, switchMap } from 'rxjs/operators'; - -import { progress } from '@cc/app/shared/custom-operators'; - -import { DomainStoreService } from '../domain-store.service'; -import { editTerminalDecisionPropertyForShopCommit } from '../operations/edit-terminal-decision-property-for-shop-commit'; -import { EditTerminalDecisionPropertyParams } from '../operations/edit-terminal-decision-property-params'; -import { ProviderService } from '../provider.service'; - -@Injectable() -export class EditTerminalDecisionPropertyForShopService { - private editProperty$ = new Subject(); - - // eslint-disable-next-line @typescript-eslint/member-ordering - error$ = new Subject(); - - // eslint-disable-next-line @typescript-eslint/member-ordering - edited$ = this.editProperty$.pipe( - switchMap((params) => - this.providerService.getProviderFromParams(params) - ), - switchMap(([params, provider]) => - this.domainStoreService - .commit(editTerminalDecisionPropertyForShopCommit(provider, params)) - .pipe( - catchError(() => { - this.error$.next(); - return EMPTY; - }) - ) - ), - shareReplay(1) - ); - - // eslint-disable-next-line @typescript-eslint/member-ordering - inProgress$ = progress(this.editProperty$, merge(this.edited$, this.error$)); - - constructor( - private domainStoreService: DomainStoreService, - private snackBar: MatSnackBar, - private providerService: ProviderService - ) { - this.error$.subscribe(() => { - this.snackBar.open('An error occurred while editing providerObject'); - }); - } - - editTerminalDecisionPropertyForShop(params: EditTerminalDecisionPropertyParams) { - this.editProperty$.next(params); - } -} diff --git a/src/app/thrift-services/damsel/services/index.ts b/src/app/thrift-services/damsel/services/index.ts deleted file mode 100644 index d0024216..00000000 --- a/src/app/thrift-services/damsel/services/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './edit-terminal-decision-property-for-shop.service'; diff --git a/src/app/thrift-services/damsel/terminal/index.ts b/src/app/thrift-services/damsel/terminal/index.ts deleted file mode 100644 index 1c894770..00000000 --- a/src/app/thrift-services/damsel/terminal/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './terminal.service'; -export * from './terminal.module'; diff --git a/src/app/thrift-services/damsel/terminal/terminal.module.ts b/src/app/thrift-services/damsel/terminal/terminal.module.ts deleted file mode 100644 index 4928b8e8..00000000 --- a/src/app/thrift-services/damsel/terminal/terminal.module.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { NgModule } from '@angular/core'; - -import { TerminalService } from './terminal.service'; - -@NgModule({ - providers: [TerminalService], -}) -export class TerminalModule {} diff --git a/src/app/thrift-services/damsel/terminal/terminal.service.spec.ts b/src/app/thrift-services/damsel/terminal/terminal.service.spec.ts deleted file mode 100644 index 7ec4348d..00000000 --- a/src/app/thrift-services/damsel/terminal/terminal.service.spec.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { TestBed } from '@angular/core/testing'; - -import { TerminalService } from './terminal.service'; - -describe('TerminalService', () => { - let service: TerminalService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [], - providers: [TerminalService], - }); - - service = TestBed.inject(TerminalService); - }); - - it('should be created', () => { - expect(service).toBeTruthy(); - }); -}); diff --git a/src/app/thrift-services/damsel/terminal/terminal.service.ts b/src/app/thrift-services/damsel/terminal/terminal.service.ts deleted file mode 100644 index cedf3aef..00000000 --- a/src/app/thrift-services/damsel/terminal/terminal.service.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { mapTo, switchMap, take } from 'rxjs/operators'; - -import { DomainStoreService } from '../domain-store.service'; -import { CreateTerminalParams, getCreateTerminalCommit } from '../operations'; - -@Injectable() -export class TerminalService { - constructor(private domainStoreService: DomainStoreService) {} - - createTerminal(params: CreateTerminalParams): Observable { - return this.domainStoreService.getObjects('terminal').pipe( - take(1), - switchMap((terminalObjects) => { - const { commit, id } = getCreateTerminalCommit(terminalObjects, params); - return this.domainStoreService.commit(commit).pipe(mapTo(id)); - }) - ); - } -} diff --git a/src/app/thrift-services/filters/filter-providers-by-terminal-selector.ts b/src/app/thrift-services/filters/filter-providers-by-terminal-selector.ts deleted file mode 100644 index ea13e728..00000000 --- a/src/app/thrift-services/filters/filter-providers-by-terminal-selector.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ProviderObject } from '@vality/domain-proto/lib/domain'; - -export const filterProvidersByTerminalSelector = ( - objects: ProviderObject[], - filterValue: 'decisions' | 'value' -): ProviderObject[] => - objects.filter((object) => { - const selector = object.data.terminal; - switch (filterValue) { - case 'decisions': - return selector?.decisions; - case 'value': - return selector?.value; - } - }); diff --git a/src/app/thrift-services/filters/index.ts b/src/app/thrift-services/filters/index.ts index c71103d8..00226088 100644 --- a/src/app/thrift-services/filters/index.ts +++ b/src/app/thrift-services/filters/index.ts @@ -1,2 +1 @@ -export * from './filter-providers-by-terminal-selector'; export * from './filter-providers-by-category-id'; diff --git a/src/components/select-search-field/select-search-field.component.ts b/src/components/select-search-field/select-search-field.component.ts index 446e84f6..ada5468e 100644 --- a/src/components/select-search-field/select-search-field.component.ts +++ b/src/components/select-search-field/select-search-field.component.ts @@ -11,13 +11,13 @@ import { } from '@angular/core'; import { FormControl } from '@ngneat/reactive-forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import { FormComponentSuperclass } from '@s-libs/ng-core'; +import { FormComponentSuperclass, provideValueAccessor } from '@s-libs/ng-core'; import { coerceBoolean } from 'coerce-property'; import { BehaviorSubject, combineLatest, defer, Observable } from 'rxjs'; import { distinctUntilChanged, map } from 'rxjs/operators'; import { ComponentChanges } from '@cc/app/shared/utils'; -import { createControlProviders, getFormValueChanges } from '@cc/utils/forms'; +import { getFormValueChanges } from '@cc/utils/forms'; import { SelectSearchFieldOptions, SELECT_SEARCH_FIELD_OPTIONS } from './tokens'; import { Option } from './types'; @@ -28,7 +28,7 @@ import { filterOptions } from './utils'; selector: 'cc-select-search-field', templateUrl: 'select-search-field.component.html', styleUrls: ['select-search-field.component.scss'], - providers: createControlProviders(SelectSearchFieldComponent), + providers: [provideValueAccessor(SelectSearchFieldComponent)], }) export class SelectSearchFieldComponent extends FormComponentSuperclass diff --git a/src/utils/forms/validated-control-superclass/validated-control-superclass.directive.ts b/src/utils/forms/validated-control-superclass/validated-control-superclass.directive.ts index a4882580..7c758462 100644 --- a/src/utils/forms/validated-control-superclass/validated-control-superclass.directive.ts +++ b/src/utils/forms/validated-control-superclass/validated-control-superclass.directive.ts @@ -1,5 +1,5 @@ import { Directive, OnInit } from '@angular/core'; -import { ValidationErrors, Validator } from '@angular/forms'; +import { FormGroup, ValidationErrors, Validator } from '@angular/forms'; import { WrappedControlSuperclass } from '@s-libs/ng-core'; import { EMPTY, Observable } from 'rxjs'; @@ -34,9 +34,13 @@ export abstract class ValidatedControlSuperclass