mirror of
https://github.com/valitydev/control-center.git
synced 2024-11-06 10:35:18 +00:00
Merge branch 'master' into ft/to-wachter
# Conflicts: # package.json
This commit is contained in:
commit
5216a1dad6
42
package-lock.json
generated
42
package-lock.json
generated
@ -29,12 +29,12 @@
|
|||||||
"@s-libs/ng-core": "14.0.0",
|
"@s-libs/ng-core": "14.0.0",
|
||||||
"@s-libs/rxjs-core": "14.0.0",
|
"@s-libs/rxjs-core": "14.0.0",
|
||||||
"@vality/deanonimus-proto": "1.0.1-c9a6cae.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/dominant-cache-proto": "1.0.1-5b29d81.0",
|
||||||
"@vality/file-storage-proto": "1.0.1-447212b.0",
|
"@vality/file-storage-proto": "1.0.1-447212b.0",
|
||||||
"@vality/fistful-proto": "1.0.1-ea0fe7a.0",
|
"@vality/fistful-proto": "1.0.1-ea0fe7a.0",
|
||||||
"@vality/machinegun-proto": "1.0.1-277f06e.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/messages-proto": "1.0.1-8c5435c.0",
|
||||||
"@vality/payout-manager-proto": "1.0.1-dbed280.0",
|
"@vality/payout-manager-proto": "1.0.1-dbed280.0",
|
||||||
"@vality/repairer-proto": "1.0.1-675b6f4.0",
|
"@vality/repairer-proto": "1.0.1-675b6f4.0",
|
||||||
@ -51,7 +51,7 @@
|
|||||||
"lodash-es": "4.17.21",
|
"lodash-es": "4.17.21",
|
||||||
"moment": "2.29.4",
|
"moment": "2.29.4",
|
||||||
"monaco-editor": "0.21.2",
|
"monaco-editor": "0.21.2",
|
||||||
"ngx-mat-select-search": "4.2.0",
|
"ngx-mat-select-search": "4.2.1",
|
||||||
"rxjs": "7.5.4",
|
"rxjs": "7.5.4",
|
||||||
"short-uuid": "4.1.0",
|
"short-uuid": "4.1.0",
|
||||||
"transliteration": "2.1.8",
|
"transliteration": "2.1.8",
|
||||||
@ -5470,9 +5470,9 @@
|
|||||||
"integrity": "sha512-GjD4N6ZXyuYaGXv4od+lcCGKfIJFi640I6wJ3+O1eA9VrUI4Ro+Ljpu+TLjckMQ6nS1DkXuu+06Dk7Hr5nK1og=="
|
"integrity": "sha512-GjD4N6ZXyuYaGXv4od+lcCGKfIJFi640I6wJ3+O1eA9VrUI4Ro+Ljpu+TLjckMQ6nS1DkXuu+06Dk7Hr5nK1og=="
|
||||||
},
|
},
|
||||||
"node_modules/@vality/domain-proto": {
|
"node_modules/@vality/domain-proto": {
|
||||||
"version": "1.0.1-3efe7df.0",
|
"version": "1.0.1-9362c08.0",
|
||||||
"resolved": "https://registry.npmjs.org/@vality/domain-proto/-/domain-proto-1.0.1-3efe7df.0.tgz",
|
"resolved": "https://registry.npmjs.org/@vality/domain-proto/-/domain-proto-1.0.1-9362c08.0.tgz",
|
||||||
"integrity": "sha512-cILZ0VttIGWLMRATT4/OblgACFraOn5Udnxhi6QiDPC3wd3wSm8YnHiOwFNx8HjydaSOw/5nzf5c+0G9gk27dA=="
|
"integrity": "sha512-B7JksaSacuNVNS/xyXa8IciOwIkh99vvME34482q1voMu4irVGRwCxovvpWcQKxfmEXoBvV5FTn1mkNNDiIWcA=="
|
||||||
},
|
},
|
||||||
"node_modules/@vality/dominant-cache-proto": {
|
"node_modules/@vality/dominant-cache-proto": {
|
||||||
"version": "1.0.1-5b29d81.0",
|
"version": "1.0.1-5b29d81.0",
|
||||||
@ -5495,9 +5495,9 @@
|
|||||||
"integrity": "sha512-qSotrFM8SY/rrfaIRWiyDFeu8ncMqPw8ohrerrGp5S+UZtGvqF0cHQiXytglK+fbAFJ0scyHgvSFBjc1bUtAzA=="
|
"integrity": "sha512-qSotrFM8SY/rrfaIRWiyDFeu8ncMqPw8ohrerrGp5S+UZtGvqF0cHQiXytglK+fbAFJ0scyHgvSFBjc1bUtAzA=="
|
||||||
},
|
},
|
||||||
"node_modules/@vality/magista-proto": {
|
"node_modules/@vality/magista-proto": {
|
||||||
"version": "1.0.1-9f37374.0",
|
"version": "1.0.1-5352f74.0",
|
||||||
"resolved": "https://registry.npmjs.org/@vality/magista-proto/-/magista-proto-1.0.1-9f37374.0.tgz",
|
"resolved": "https://registry.npmjs.org/@vality/magista-proto/-/magista-proto-1.0.1-5352f74.0.tgz",
|
||||||
"integrity": "sha512-jgcC0nrH1hZleK9rNgIcUUFmcj6mEK3aMb4h+oa2EWvTSxhSGcjmbGiGXYNnVnoWy+z3CeZoW3hcwGLPPXFieg=="
|
"integrity": "sha512-lpTKcF/61zn5kfohCE+YionuaK5S0/sN4TiFvdkk853A5v4CFOs0L+O2z7pqKtiVhPIjXhE9bU5pfnLvJzEg6w=="
|
||||||
},
|
},
|
||||||
"node_modules/@vality/messages-proto": {
|
"node_modules/@vality/messages-proto": {
|
||||||
"version": "1.0.1-8c5435c.0",
|
"version": "1.0.1-8c5435c.0",
|
||||||
@ -15539,9 +15539,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ngx-mat-select-search": {
|
"node_modules/ngx-mat-select-search": {
|
||||||
"version": "4.2.0",
|
"version": "4.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/ngx-mat-select-search/-/ngx-mat-select-search-4.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/ngx-mat-select-search/-/ngx-mat-select-search-4.2.1.tgz",
|
||||||
"integrity": "sha512-vPlq2s8mJPZ8W+HDrhen95YzW/H+0zI2+EDOhju5zrKLoFZi0pQ7SDLHMmfOpPDcSAttGjVZ3lA9N0bCq3RHMw==",
|
"integrity": "sha512-bKHpOSIXyqwZw35OB6yi87tcRRV/69mu49PN0M2ZzVbiWBPg/IN58aJnCHUDxDG6CdK0vbGJ/2eCPniZ1nf9KA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0"
|
||||||
},
|
},
|
||||||
@ -25739,9 +25739,9 @@
|
|||||||
"integrity": "sha512-GjD4N6ZXyuYaGXv4od+lcCGKfIJFi640I6wJ3+O1eA9VrUI4Ro+Ljpu+TLjckMQ6nS1DkXuu+06Dk7Hr5nK1og=="
|
"integrity": "sha512-GjD4N6ZXyuYaGXv4od+lcCGKfIJFi640I6wJ3+O1eA9VrUI4Ro+Ljpu+TLjckMQ6nS1DkXuu+06Dk7Hr5nK1og=="
|
||||||
},
|
},
|
||||||
"@vality/domain-proto": {
|
"@vality/domain-proto": {
|
||||||
"version": "1.0.1-3efe7df.0",
|
"version": "1.0.1-9362c08.0",
|
||||||
"resolved": "https://registry.npmjs.org/@vality/domain-proto/-/domain-proto-1.0.1-3efe7df.0.tgz",
|
"resolved": "https://registry.npmjs.org/@vality/domain-proto/-/domain-proto-1.0.1-9362c08.0.tgz",
|
||||||
"integrity": "sha512-cILZ0VttIGWLMRATT4/OblgACFraOn5Udnxhi6QiDPC3wd3wSm8YnHiOwFNx8HjydaSOw/5nzf5c+0G9gk27dA=="
|
"integrity": "sha512-B7JksaSacuNVNS/xyXa8IciOwIkh99vvME34482q1voMu4irVGRwCxovvpWcQKxfmEXoBvV5FTn1mkNNDiIWcA=="
|
||||||
},
|
},
|
||||||
"@vality/dominant-cache-proto": {
|
"@vality/dominant-cache-proto": {
|
||||||
"version": "1.0.1-5b29d81.0",
|
"version": "1.0.1-5b29d81.0",
|
||||||
@ -25764,9 +25764,9 @@
|
|||||||
"integrity": "sha512-qSotrFM8SY/rrfaIRWiyDFeu8ncMqPw8ohrerrGp5S+UZtGvqF0cHQiXytglK+fbAFJ0scyHgvSFBjc1bUtAzA=="
|
"integrity": "sha512-qSotrFM8SY/rrfaIRWiyDFeu8ncMqPw8ohrerrGp5S+UZtGvqF0cHQiXytglK+fbAFJ0scyHgvSFBjc1bUtAzA=="
|
||||||
},
|
},
|
||||||
"@vality/magista-proto": {
|
"@vality/magista-proto": {
|
||||||
"version": "1.0.1-9f37374.0",
|
"version": "1.0.1-5352f74.0",
|
||||||
"resolved": "https://registry.npmjs.org/@vality/magista-proto/-/magista-proto-1.0.1-9f37374.0.tgz",
|
"resolved": "https://registry.npmjs.org/@vality/magista-proto/-/magista-proto-1.0.1-5352f74.0.tgz",
|
||||||
"integrity": "sha512-jgcC0nrH1hZleK9rNgIcUUFmcj6mEK3aMb4h+oa2EWvTSxhSGcjmbGiGXYNnVnoWy+z3CeZoW3hcwGLPPXFieg=="
|
"integrity": "sha512-lpTKcF/61zn5kfohCE+YionuaK5S0/sN4TiFvdkk853A5v4CFOs0L+O2z7pqKtiVhPIjXhE9bU5pfnLvJzEg6w=="
|
||||||
},
|
},
|
||||||
"@vality/messages-proto": {
|
"@vality/messages-proto": {
|
||||||
"version": "1.0.1-8c5435c.0",
|
"version": "1.0.1-8c5435c.0",
|
||||||
@ -33618,9 +33618,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ngx-mat-select-search": {
|
"ngx-mat-select-search": {
|
||||||
"version": "4.2.0",
|
"version": "4.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/ngx-mat-select-search/-/ngx-mat-select-search-4.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/ngx-mat-select-search/-/ngx-mat-select-search-4.2.1.tgz",
|
||||||
"integrity": "sha512-vPlq2s8mJPZ8W+HDrhen95YzW/H+0zI2+EDOhju5zrKLoFZi0pQ7SDLHMmfOpPDcSAttGjVZ3lA9N0bCq3RHMw==",
|
"integrity": "sha512-bKHpOSIXyqwZw35OB6yi87tcRRV/69mu49PN0M2ZzVbiWBPg/IN58aJnCHUDxDG6CdK0vbGJ/2eCPniZ1nf9KA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0"
|
||||||
},
|
},
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"start": "ng serve --proxy-config proxy.conf.js --port 4200",
|
"start": "ng serve --proxy-config proxy.conf.js --port 4200",
|
||||||
"build": "ng build --extra-webpack-config webpack.extra.js",
|
"build": "ng build --extra-webpack-config webpack.extra.js",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"lint-cmd": "eslint \"src/**/*.{ts,js,html}\" --max-warnings 1193",
|
"lint-cmd": "eslint \"src/**/*.{ts,js,html}\" --max-warnings 1115",
|
||||||
"lint": "npm run lint-cmd -- --cache",
|
"lint": "npm run lint-cmd -- --cache",
|
||||||
"lint-fix": "npm run lint -- --fix",
|
"lint-fix": "npm run lint -- --fix",
|
||||||
"lint-errors": "npm run lint -- --quiet",
|
"lint-errors": "npm run lint -- --quiet",
|
||||||
@ -37,12 +37,12 @@
|
|||||||
"@s-libs/ng-core": "14.0.0",
|
"@s-libs/ng-core": "14.0.0",
|
||||||
"@s-libs/rxjs-core": "14.0.0",
|
"@s-libs/rxjs-core": "14.0.0",
|
||||||
"@vality/deanonimus-proto": "1.0.1-c9a6cae.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/dominant-cache-proto": "1.0.1-5b29d81.0",
|
||||||
"@vality/file-storage-proto": "1.0.1-447212b.0",
|
"@vality/file-storage-proto": "1.0.1-447212b.0",
|
||||||
"@vality/fistful-proto": "1.0.1-ea0fe7a.0",
|
"@vality/fistful-proto": "1.0.1-ea0fe7a.0",
|
||||||
"@vality/machinegun-proto": "1.0.1-277f06e.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/messages-proto": "1.0.1-8c5435c.0",
|
||||||
"@vality/payout-manager-proto": "1.0.1-dbed280.0",
|
"@vality/payout-manager-proto": "1.0.1-dbed280.0",
|
||||||
"@vality/repairer-proto": "1.0.1-675b6f4.0",
|
"@vality/repairer-proto": "1.0.1-675b6f4.0",
|
||||||
@ -59,7 +59,7 @@
|
|||||||
"lodash-es": "4.17.21",
|
"lodash-es": "4.17.21",
|
||||||
"moment": "2.29.4",
|
"moment": "2.29.4",
|
||||||
"monaco-editor": "0.21.2",
|
"monaco-editor": "0.21.2",
|
||||||
"ngx-mat-select-search": "4.2.0",
|
"ngx-mat-select-search": "4.2.1",
|
||||||
"rxjs": "7.5.4",
|
"rxjs": "7.5.4",
|
||||||
"short-uuid": "4.1.0",
|
"short-uuid": "4.1.0",
|
||||||
"transliteration": "2.1.8",
|
"transliteration": "2.1.8",
|
||||||
|
@ -1,3 +1 @@
|
|||||||
export * from './party-management.service';
|
export * from './party-management.service';
|
||||||
export * from './services/user-info';
|
|
||||||
export * from './services/party-management-with-user';
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
export * from './party-management-with-user.service';
|
|
@ -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)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from './user-info.service';
|
|
@ -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<UserInfo> = 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());
|
|
||||||
}
|
|
||||||
}
|
|
@ -43,9 +43,11 @@ export function parseNamespaceObjectType(
|
|||||||
include?: JsonAST['include']
|
include?: JsonAST['include']
|
||||||
): NamespaceObjectType {
|
): NamespaceObjectType {
|
||||||
// metadata reverse find - search for the last matching protocol if the names match (files are overwritten in the same order)
|
// metadata reverse find - search for the last matching protocol if the names match (files are overwritten in the same order)
|
||||||
const namespaceMetadata = include
|
let namespaceMetadata: ThriftAstMetadata;
|
||||||
? metadata.reverse().find((m) => m.path === include[namespace].path)
|
if (include)
|
||||||
: metadata.reverse().find((m) => m.name === namespace);
|
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(
|
const objectType = (Object.keys(namespaceMetadata.ast) as StructureType[]).find(
|
||||||
(t) => namespaceMetadata.ast[t][type]
|
(t) => namespaceMetadata.ast[t][type]
|
||||||
);
|
);
|
||||||
|
@ -3,17 +3,17 @@ import { Contract, Party, PartyContractor, Shop } from '@vality/domain-proto/lib
|
|||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
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 { PartyTarget } from '../party-target';
|
||||||
import { SelectableItem } from './selectable-item';
|
import { SelectableItem } from './selectable-item';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PartyTargetService {
|
export class PartyTargetService {
|
||||||
constructor(private partyManagementWithUserService: PartyManagementWithUserService) {}
|
constructor(private partyManagementService: PartyManagementService) {}
|
||||||
|
|
||||||
getSelectableItems(partyID: string, targetName: PartyTarget): Observable<SelectableItem[]> {
|
getSelectableItems(partyID: string, targetName: PartyTarget): Observable<SelectableItem[]> {
|
||||||
return this.partyManagementWithUserService.getParty(partyID).pipe(
|
return this.partyManagementService.Get(partyID).pipe(
|
||||||
map((party) => {
|
map((party) => {
|
||||||
const result = [];
|
const result = [];
|
||||||
const target = this.getTarget(party, targetName);
|
const target = this.getTarget(party, targetName);
|
||||||
|
@ -2,7 +2,6 @@ import {
|
|||||||
InvoicePaymentFlow,
|
InvoicePaymentFlow,
|
||||||
InvoicePaymentStatus,
|
InvoicePaymentStatus,
|
||||||
PaymentTool,
|
PaymentTool,
|
||||||
TerminalPaymentProvider,
|
|
||||||
} from '@vality/domain-proto/lib/merch_stat';
|
} from '@vality/domain-proto/lib/merch_stat';
|
||||||
|
|
||||||
export interface Payment {
|
export interface Payment {
|
||||||
@ -11,7 +10,6 @@ export interface Payment {
|
|||||||
payment_email?: string;
|
payment_email?: string;
|
||||||
payment_flow?: InvoicePaymentFlow;
|
payment_flow?: InvoicePaymentFlow;
|
||||||
payment_method?: PaymentTool;
|
payment_method?: PaymentTool;
|
||||||
payment_terminal_provider?: TerminalPaymentProvider;
|
|
||||||
payment_ip?: string;
|
payment_ip?: string;
|
||||||
payment_provider_id?: string;
|
payment_provider_id?: string;
|
||||||
payment_terminal_id?: string;
|
payment_terminal_id?: string;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
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 { RepairScenario } from '@vality/fistful-proto/lib/withdrawal_session';
|
||||||
import { KeycloakService } from 'keycloak-angular';
|
import { KeycloakService } from 'keycloak-angular';
|
||||||
import { BehaviorSubject, Observable } from 'rxjs';
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
@ -51,13 +51,6 @@ export class RepairingService {
|
|||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
getUser(): UserInfo {
|
|
||||||
return {
|
|
||||||
id: this.keycloakService.getUsername(),
|
|
||||||
type: { internal_user: {} },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
remove<E>(currentElements: E[], elements: E[]) {
|
remove<E>(currentElements: E[], elements: E[]) {
|
||||||
const resultDataSource = currentElements.slice();
|
const resultDataSource = currentElements.slice();
|
||||||
for (const element of elements) {
|
for (const element of elements) {
|
||||||
@ -105,13 +98,12 @@ export class RepairingService {
|
|||||||
elements: E[],
|
elements: E[],
|
||||||
scenario: InvoiceRepairScenario
|
scenario: InvoiceRepairScenario
|
||||||
) {
|
) {
|
||||||
const user = this.getUser();
|
|
||||||
this._progress$.next(0);
|
this._progress$.next(0);
|
||||||
return execute(
|
return execute(
|
||||||
elements.map(
|
elements.map(
|
||||||
({ id }) =>
|
({ id }) =>
|
||||||
() =>
|
() =>
|
||||||
this.paymentProcessingService.repairWithScenario(user, id, scenario)
|
this.paymentProcessingService.repairWithScenario(id, scenario)
|
||||||
)
|
)
|
||||||
).pipe(tap(({ progress }) => this._progress$.next(progress)));
|
).pipe(tap(({ progress }) => this._progress$.next(progress)));
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import {
|
|||||||
import { catchError, first, map, shareReplay } from 'rxjs/operators';
|
import { catchError, first, map, shareReplay } from 'rxjs/operators';
|
||||||
|
|
||||||
import { ClaimManagementService } from '@cc/app/api/claim-management';
|
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 { 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 { AllowedClaimStatusesService } from '@cc/app/sections/claim/services/allowed-claim-statuses.service';
|
||||||
import { UploadFileService } from '@cc/app/sections/claim/services/upload-file.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 {
|
export class ClaimComponent {
|
||||||
party$ = (this.route.params as Observable<Record<string, string>>).pipe(
|
party$ = (this.route.params as Observable<Record<string, string>>).pipe(
|
||||||
switchMap(({ partyID }) =>
|
switchMap(({ partyID }) =>
|
||||||
this.partyManagementWithUserService.getParty(partyID).pipe(
|
this.partyManagementService.Get(partyID).pipe(
|
||||||
progressTo(this.progress$),
|
progressTo(this.progress$),
|
||||||
catchError((err) => {
|
catchError((err) => {
|
||||||
this.notificationService.error('The party was not loaded');
|
this.notificationService.error('The party was not loaded');
|
||||||
@ -81,7 +81,7 @@ export class ClaimComponent {
|
|||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private claimManagementService: ClaimManagementService,
|
private claimManagementService: ClaimManagementService,
|
||||||
private partyManagementWithUserService: PartyManagementWithUserService,
|
private partyManagementService: PartyManagementService,
|
||||||
private notificationService: NotificationService,
|
private notificationService: NotificationService,
|
||||||
private uploadFileService: UploadFileService,
|
private uploadFileService: UploadFileService,
|
||||||
private allowedClaimStatusesService: AllowedClaimStatusesService,
|
private allowedClaimStatusesService: AllowedClaimStatusesService,
|
||||||
|
@ -7,7 +7,7 @@ import { BehaviorSubject, switchMap } from 'rxjs';
|
|||||||
import { filter, first } from 'rxjs/operators';
|
import { filter, first } from 'rxjs/operators';
|
||||||
|
|
||||||
import { ClaimManagementService } from '@cc/app/api/claim-management';
|
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 { getModificationName } from '@cc/app/sections/claim/utils/get-modification-name';
|
||||||
import { Patch } from '@cc/app/shared/components/json-viewer';
|
import { Patch } from '@cc/app/shared/components/json-viewer';
|
||||||
import { NotificationService } from '@cc/app/shared/services/notification';
|
import { NotificationService } from '@cc/app/shared/services/notification';
|
||||||
@ -43,7 +43,7 @@ export class ModificationUnitTimelineItemComponent {
|
|||||||
private progress$ = new BehaviorSubject(0);
|
private progress$ = new BehaviorSubject(0);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private partyManagementWithUserService: PartyManagementWithUserService,
|
private partyManagementService: PartyManagementService,
|
||||||
private baseDialogService: BaseDialogService,
|
private baseDialogService: BaseDialogService,
|
||||||
private claimManagementService: ClaimManagementService,
|
private claimManagementService: ClaimManagementService,
|
||||||
private notificationService: NotificationService
|
private notificationService: NotificationService
|
||||||
@ -62,8 +62,8 @@ export class ModificationUnitTimelineItemComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
this.partyManagementWithUserService
|
this.partyManagementService
|
||||||
.getParty(this.claim.party_id)
|
.Get(this.claim.party_id)
|
||||||
.pipe(
|
.pipe(
|
||||||
first(),
|
first(),
|
||||||
switchMap((party) =>
|
switchMap((party) =>
|
||||||
@ -88,7 +88,7 @@ export class ModificationUnitTimelineItemComponent {
|
|||||||
.afterClosed()
|
.afterClosed()
|
||||||
.pipe(
|
.pipe(
|
||||||
filter(({ status }) => status === BaseDialogResponseStatus.Success),
|
filter(({ status }) => status === BaseDialogResponseStatus.Success),
|
||||||
switchMap(() => this.partyManagementWithUserService.getParty(this.claim.party_id)),
|
switchMap(() => this.partyManagementService.Get(this.claim.party_id)),
|
||||||
switchMap((party) =>
|
switchMap((party) =>
|
||||||
this.claimManagementService.RemoveModification(
|
this.claimManagementService.RemoveModification(
|
||||||
party.id,
|
party.id,
|
||||||
|
@ -4,7 +4,7 @@ import { Party } from '@vality/domain-proto/lib/domain';
|
|||||||
import { defer, Observable } from 'rxjs';
|
import { defer, Observable } from 'rxjs';
|
||||||
import { map, pluck, shareReplay, switchMap } from 'rxjs/operators';
|
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()
|
@Injectable()
|
||||||
export class PartyShopsService {
|
export class PartyShopsService {
|
||||||
@ -15,12 +15,12 @@ export class PartyShopsService {
|
|||||||
|
|
||||||
private party$: Observable<Party> = this.route.params.pipe(
|
private party$: Observable<Party> = this.route.params.pipe(
|
||||||
pluck('partyID'),
|
pluck('partyID'),
|
||||||
switchMap((partyID) => this.partyManagementWithUserService.getParty(partyID)),
|
switchMap((partyID) => this.partyManagementService.Get(partyID)),
|
||||||
shareReplay(1)
|
shareReplay(1)
|
||||||
);
|
);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private partyManagementWithUserService: PartyManagementWithUserService,
|
private partyManagementService: PartyManagementService,
|
||||||
private route: ActivatedRoute
|
private route: ActivatedRoute
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,18 @@
|
|||||||
import {
|
import { InvoicePaymentAdjustmentParams } from '@vality/domain-proto/lib/payment_processing';
|
||||||
InvoicePaymentAdjustmentParams,
|
|
||||||
UserInfo,
|
|
||||||
} from '@vality/domain-proto/lib/payment_processing';
|
|
||||||
|
|
||||||
export interface PaymentAdjustmentCreationParams {
|
export interface PaymentAdjustmentCreationParams {
|
||||||
user: UserInfo;
|
|
||||||
invoice_id: string;
|
invoice_id: string;
|
||||||
payment_id: string;
|
payment_id: string;
|
||||||
params: InvoicePaymentAdjustmentParams;
|
params: InvoicePaymentAdjustmentParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PaymentAdjustmentCancelParams {
|
export interface PaymentAdjustmentCancelParams {
|
||||||
user: UserInfo;
|
|
||||||
invoice_id: string;
|
invoice_id: string;
|
||||||
payment_id: string;
|
payment_id: string;
|
||||||
adjustment_id: string;
|
adjustment_id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PaymentAdjustmentCaptureParams {
|
export interface PaymentAdjustmentCaptureParams {
|
||||||
user: UserInfo;
|
|
||||||
invoice_id: string;
|
invoice_id: string;
|
||||||
payment_id: string;
|
payment_id: string;
|
||||||
adjustment_id: string;
|
adjustment_id: string;
|
||||||
|
@ -82,8 +82,7 @@ export class CancelActionsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
recreate() {
|
recreate() {
|
||||||
const createParams = this.cancelResult.map(({ user, invoice_id, payment_id }) => ({
|
const createParams = this.cancelResult.map(({ invoice_id, payment_id }) => ({
|
||||||
user,
|
|
||||||
invoice_id,
|
invoice_id,
|
||||||
payment_id,
|
payment_id,
|
||||||
params: this.adjustmentParams,
|
params: this.adjustmentParams,
|
||||||
|
@ -73,8 +73,7 @@ export class CreateActionsComponent implements OnInit {
|
|||||||
|
|
||||||
capture() {
|
capture() {
|
||||||
const captureParams = this.createResult.map(
|
const captureParams = this.createResult.map(
|
||||||
({ adjustmentId, creationParams: { user, invoice_id, payment_id } }) => ({
|
({ adjustmentId, creationParams: { invoice_id, payment_id } }) => ({
|
||||||
user,
|
|
||||||
invoice_id,
|
invoice_id,
|
||||||
payment_id,
|
payment_id,
|
||||||
adjustment_id: adjustmentId,
|
adjustment_id: adjustmentId,
|
||||||
@ -95,10 +94,9 @@ export class CreateActionsComponent implements OnInit {
|
|||||||
({
|
({
|
||||||
operationScope: {
|
operationScope: {
|
||||||
adjustmentId,
|
adjustmentId,
|
||||||
creationParams: { user, invoice_id, payment_id },
|
creationParams: { invoice_id, payment_id },
|
||||||
},
|
},
|
||||||
}) => ({
|
}) => ({
|
||||||
user,
|
|
||||||
invoice_id,
|
invoice_id,
|
||||||
payment_id,
|
payment_id,
|
||||||
adjustment_id: adjustmentId,
|
adjustment_id: adjustmentId,
|
||||||
|
@ -13,7 +13,6 @@ import { StatPayment } from '@vality/domain-proto/lib/merch_stat';
|
|||||||
import {
|
import {
|
||||||
InvoicePaymentAdjustmentParams,
|
InvoicePaymentAdjustmentParams,
|
||||||
InvoicePaymentAdjustmentScenario,
|
InvoicePaymentAdjustmentScenario,
|
||||||
UserInfo,
|
|
||||||
} from '@vality/domain-proto/lib/payment_processing';
|
} from '@vality/domain-proto/lib/payment_processing';
|
||||||
import { KeycloakService } from 'keycloak-angular';
|
import { KeycloakService } from 'keycloak-angular';
|
||||||
import isEqual from 'lodash-es/isEqual';
|
import isEqual from 'lodash-es/isEqual';
|
||||||
@ -142,7 +141,6 @@ export class CreateAndCaptureComponent implements OnInit {
|
|||||||
this.createStarted = true;
|
this.createStarted = true;
|
||||||
this.form.disable();
|
this.form.disable();
|
||||||
const createParams = this.payments.map(({ invoice_id, id }) => ({
|
const createParams = this.payments.map(({ invoice_id, id }) => ({
|
||||||
user: this.getUser(),
|
|
||||||
invoice_id,
|
invoice_id,
|
||||||
payment_id: id,
|
payment_id: id,
|
||||||
params: this.adjustmentParams,
|
params: this.adjustmentParams,
|
||||||
@ -197,11 +195,4 @@ export class CreateAndCaptureComponent implements OnInit {
|
|||||||
scenario,
|
scenario,
|
||||||
} as InvoicePaymentAdjustmentParams;
|
} as InvoicePaymentAdjustmentParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getUser(): UserInfo {
|
|
||||||
return {
|
|
||||||
id: this.keycloakService.getUsername(),
|
|
||||||
type: { internal_user: {} },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { ActivatedRoute } from '@angular/router';
|
|||||||
import { combineLatest, of } from 'rxjs';
|
import { combineLatest, of } from 'rxjs';
|
||||||
import { map, pluck, shareReplay, switchMap, tap } from 'rxjs/operators';
|
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 { progress } from '@cc/app/shared/custom-operators';
|
||||||
|
|
||||||
import { QueryDsl } from '../../query-dsl';
|
import { QueryDsl } from '../../query-dsl';
|
||||||
@ -49,14 +49,12 @@ export class PaymentDetailsService {
|
|||||||
// eslint-disable-next-line @typescript-eslint/member-ordering
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
||||||
shop$ = this.payment$.pipe(
|
shop$ = this.payment$.pipe(
|
||||||
switchMap((payment) => combineLatest([this.partyID$, of(payment.shop_id)])),
|
switchMap((payment) => combineLatest([this.partyID$, of(payment.shop_id)])),
|
||||||
switchMap(([partyID, shopID]) =>
|
switchMap(([partyID, shopID]) => this.partyManagementService.GetShop(partyID, shopID)),
|
||||||
this.partyManagementWithUserService.getShop(partyID, shopID)
|
|
||||||
),
|
|
||||||
shareReplay(1)
|
shareReplay(1)
|
||||||
);
|
);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private partyManagementWithUserService: PartyManagementWithUserService,
|
private partyManagementService: PartyManagementService,
|
||||||
private merchantStatisticsService: MerchantStatisticsService,
|
private merchantStatisticsService: MerchantStatisticsService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private snackBar: MatSnackBar
|
private snackBar: MatSnackBar
|
||||||
|
@ -3,7 +3,7 @@ import { ContractID, PartyID } from '@vality/domain-proto';
|
|||||||
import { forkJoin, merge, Observable, of, Subject } from 'rxjs';
|
import { forkJoin, merge, Observable, of, Subject } from 'rxjs';
|
||||||
import { catchError, filter, map, shareReplay, startWith, switchMap } from 'rxjs/operators';
|
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';
|
import { progress } from '@cc/app/shared/custom-operators';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -17,7 +17,7 @@ export class FetchContractorService {
|
|||||||
({ partyID, contractID }): Observable<[ContractID, any]> =>
|
({ partyID, contractID }): Observable<[ContractID, any]> =>
|
||||||
forkJoin([
|
forkJoin([
|
||||||
of(contractID),
|
of(contractID),
|
||||||
this.partyManagementWithUserService.getParty(partyID).pipe(
|
this.partyManagementService.Get(partyID).pipe(
|
||||||
catchError(() => {
|
catchError(() => {
|
||||||
this.hasError$.next();
|
this.hasError$.next();
|
||||||
return of('error');
|
return of('error');
|
||||||
@ -38,7 +38,7 @@ export class FetchContractorService {
|
|||||||
startWith(true)
|
startWith(true)
|
||||||
);
|
);
|
||||||
|
|
||||||
constructor(private partyManagementWithUserService: PartyManagementWithUserService) {
|
constructor(private partyManagementService: PartyManagementService) {
|
||||||
this.contractor$.subscribe();
|
this.contractor$.subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,27 +1,28 @@
|
|||||||
<div fxLayout fxLayoutAlign="start center" fxLayoutGap="8px">
|
<div fxLayout fxLayoutAlign="start center" fxLayoutGap="8px">
|
||||||
<div>{{ bankCard | toCardNumber }}</div>
|
<div>{{ bankCard | toCardNumber }}</div>
|
||||||
<mat-icon
|
<!-- TODO Need migration according to: https://github.com/rbkmoney/damsel/commit/61677b86006d405619bdc5f23d6416a929688180-->
|
||||||
*ngIf="bankCard.payment_system_deprecated === legacyPaymentSystems?.visa"
|
<!-- <mat-icon-->
|
||||||
svgIcon="visa"
|
<!-- *ngIf="bankCard.payment_system_deprecated === legacyPaymentSystems?.visa"-->
|
||||||
></mat-icon>
|
<!-- svgIcon="visa"-->
|
||||||
<mat-icon
|
<!-- ></mat-icon>-->
|
||||||
*ngIf="bankCard.payment_system_deprecated === legacyPaymentSystems?.mastercard"
|
<!-- <mat-icon-->
|
||||||
svgIcon="mastercard"
|
<!-- *ngIf="bankCard.payment_system_deprecated === legacyPaymentSystems?.mastercard"-->
|
||||||
></mat-icon>
|
<!-- svgIcon="mastercard"-->
|
||||||
<mat-icon
|
<!-- ></mat-icon>-->
|
||||||
*ngIf="bankCard.payment_system_deprecated === legacyPaymentSystems?.nspkmir"
|
<!-- <mat-icon-->
|
||||||
svgIcon="mir"
|
<!-- *ngIf="bankCard.payment_system_deprecated === legacyPaymentSystems?.nspkmir"-->
|
||||||
></mat-icon>
|
<!-- svgIcon="mir"-->
|
||||||
<mat-icon
|
<!-- ></mat-icon>-->
|
||||||
*ngIf="bankCard.token_provider_deprecated === legacyTokenProviders?.applepay"
|
<!-- <mat-icon-->
|
||||||
svgIcon="apple_pay"
|
<!-- *ngIf="bankCard.token_provider_deprecated === legacyTokenProviders?.applepay"-->
|
||||||
></mat-icon>
|
<!-- svgIcon="apple_pay"-->
|
||||||
<mat-icon
|
<!-- ></mat-icon>-->
|
||||||
*ngIf="bankCard.token_provider_deprecated === legacyTokenProviders?.samsungpay"
|
<!-- <mat-icon-->
|
||||||
svgIcon="samsung_pay"
|
<!-- *ngIf="bankCard.token_provider_deprecated === legacyTokenProviders?.samsungpay"-->
|
||||||
></mat-icon>
|
<!-- svgIcon="samsung_pay"-->
|
||||||
<mat-icon
|
<!-- ></mat-icon>-->
|
||||||
*ngIf="bankCard.token_provider_deprecated === legacyTokenProviders?.googlepay"
|
<!-- <mat-icon-->
|
||||||
svgIcon="google_pay"
|
<!-- *ngIf="bankCard.token_provider_deprecated === legacyTokenProviders?.googlepay"-->
|
||||||
></mat-icon>
|
<!-- svgIcon="google_pay"-->
|
||||||
|
<!-- ></mat-icon>-->
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
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';
|
import { BankCard } from '@vality/domain-proto/lib/merch_stat';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -12,8 +8,4 @@ import { BankCard } from '@vality/domain-proto/lib/merch_stat';
|
|||||||
})
|
})
|
||||||
export class BankCardComponent {
|
export class BankCardComponent {
|
||||||
@Input() bankCard: BankCard;
|
@Input() bankCard: BankCard;
|
||||||
|
|
||||||
// TODO Need migration according to: https://github.com/rbkmoney/damsel/commit/61677b86006d405619bdc5f23d6416a929688180
|
|
||||||
legacyPaymentSystems = LegacyBankCardPaymentSystem;
|
|
||||||
legacyTokenProviders = LegacyBankCardTokenProvider;
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
<cc-bank-card *ngIf="paymentTool.bank_card" [bankCard]="paymentTool.bank_card"></cc-bank-card>
|
<cc-bank-card *ngIf="paymentTool.bank_card" [bankCard]="paymentTool.bank_card"></cc-bank-card>
|
||||||
<div *ngIf="paymentTool.crypto_currency">
|
<div *ngIf="paymentTool.crypto_currency">
|
||||||
{{ paymentTool.crypto_currency | toCryptoCurrency }}
|
{{ paymentTool.crypto_currency?.crypto_currency?.id }}
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="paymentTool.digital_wallet">
|
<div *ngIf="paymentTool.digital_wallet">
|
||||||
{{ paymentTool.digital_wallet?.provider | toDigitalWallet }}
|
{{ paymentTool.digital_wallet?.id }}
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="paymentTool.mobile_commerce">
|
<div *ngIf="paymentTool.mobile_commerce">
|
||||||
{{ paymentTool.mobile_commerce.phone }}
|
{{ paymentTool.mobile_commerce.phone }}
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="paymentTool.payment_terminal">
|
<div *ngIf="paymentTool.payment_terminal">
|
||||||
{{ paymentTool.payment_terminal?.terminal_type_deprecated | toPaymentTerminal }}
|
{{ paymentTool.payment_terminal?.payment_service?.id }}
|
||||||
{{ paymentTool.payment_terminal?.payment_service }}
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,17 +4,9 @@ import { FlexLayoutModule } from '@angular/flex-layout';
|
|||||||
|
|
||||||
import { BankCardModule } from './bank-card';
|
import { BankCardModule } from './bank-card';
|
||||||
import { PaymentToolComponent } from './payment-tool.component';
|
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({
|
@NgModule({
|
||||||
imports: [CommonModule, FlexLayoutModule, BankCardModule],
|
imports: [CommonModule, FlexLayoutModule, BankCardModule],
|
||||||
declarations: [
|
declarations: [PaymentToolComponent],
|
||||||
PaymentToolComponent,
|
|
||||||
ToCryptoCurrencyPipe,
|
|
||||||
ToDigitalWalletPipe,
|
|
||||||
ToPaymentTerminalPipe,
|
|
||||||
],
|
|
||||||
exports: [PaymentToolComponent],
|
exports: [PaymentToolComponent],
|
||||||
})
|
})
|
||||||
export class PaymentToolModule {}
|
export class PaymentToolModule {}
|
||||||
|
@ -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';
|
|
||||||
}
|
|
||||||
};
|
|
@ -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';
|
|
||||||
}
|
|
||||||
};
|
|
@ -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';
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,5 +1,25 @@
|
|||||||
<div *ngIf="payout$ | async as payout" fxLayout="column" fxLayoutGap="24px">
|
<div *ngIf="payout$ | async as payout" fxLayout="column" fxLayoutGap="24px">
|
||||||
<cc-headline>Payout details</cc-headline>
|
<div fxLayoutAlign="space-between">
|
||||||
|
<cc-headline>Payout details</cc-headline>
|
||||||
|
<div fxLayoutGap="16px">
|
||||||
|
<button
|
||||||
|
[disabled]="canBeCancelled(payout.status | ccUnionKey)"
|
||||||
|
color="warn"
|
||||||
|
mat-button
|
||||||
|
(click)="cancel(payout.id)"
|
||||||
|
>
|
||||||
|
CANCEL
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
[disabled]="canBeConfirmed(payout.status | ccUnionKey)"
|
||||||
|
color="primary"
|
||||||
|
mat-button
|
||||||
|
(click)="confirm(payout.id)"
|
||||||
|
>
|
||||||
|
CONFIRM
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<mat-card>
|
<mat-card>
|
||||||
<mat-card-content gdGap="16px">
|
<mat-card-content gdGap="16px">
|
||||||
<div gdColumns="1fr 1fr 1fr" gdGap="16px">
|
<div gdColumns="1fr 1fr 1fr" gdGap="16px">
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { PayoutID, PayoutStatus } from '@vality/magista-proto';
|
||||||
import { combineLatest } from 'rxjs';
|
import { combineLatest } from 'rxjs';
|
||||||
import { map, pluck, shareReplay, startWith, switchMap } from 'rxjs/operators';
|
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 { PayoutManagementService } from '@cc/app/api/payout-manager';
|
||||||
|
|
||||||
|
import { PayoutActionsService } from '../services/payout-actions.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'cc-payout-details',
|
selector: 'cc-payout-details',
|
||||||
templateUrl: './payout-details.component.html',
|
templateUrl: './payout-details.component.html',
|
||||||
styleUrls: ['./payout-details.component.scss'],
|
styleUrls: ['./payout-details.component.scss'],
|
||||||
|
providers: [PayoutActionsService],
|
||||||
})
|
})
|
||||||
export class PayoutDetailsComponent {
|
export class PayoutDetailsComponent {
|
||||||
payout$ = this.route.params.pipe(
|
payout$ = this.route.params.pipe(
|
||||||
@ -20,18 +24,18 @@ export class PayoutDetailsComponent {
|
|||||||
);
|
);
|
||||||
shop$ = this.payout$.pipe(
|
shop$ = this.payout$.pipe(
|
||||||
switchMap(({ party_id, shop_id }) =>
|
switchMap(({ party_id, shop_id }) =>
|
||||||
this.partyManagementWithUserService.getShop(party_id, shop_id)
|
this.partyManagementService.GetShop(party_id, shop_id)
|
||||||
),
|
),
|
||||||
shareReplay({ refCount: true, bufferSize: 1 })
|
shareReplay({ refCount: true, bufferSize: 1 })
|
||||||
);
|
);
|
||||||
party$ = this.payout$.pipe(
|
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 })
|
shareReplay({ refCount: true, bufferSize: 1 })
|
||||||
);
|
);
|
||||||
payoutTool$ = combineLatest([this.payout$, this.shop$]).pipe(
|
payoutTool$ = combineLatest([this.payout$, this.shop$]).pipe(
|
||||||
switchMap(([{ party_id, payout_tool_id }, { contract_id }]) =>
|
switchMap(([{ party_id, payout_tool_id }, { contract_id }]) =>
|
||||||
this.partyManagementWithUserService
|
this.partyManagementService
|
||||||
.getContract(party_id, contract_id)
|
.GetContract(party_id, contract_id)
|
||||||
.pipe(map((contract) => contract.payout_tools.find((t) => t.id === payout_tool_id)))
|
.pipe(map((contract) => contract.payout_tools.find((t) => t.id === payout_tool_id)))
|
||||||
),
|
),
|
||||||
shareReplay({ refCount: true, bufferSize: 1 })
|
shareReplay({ refCount: true, bufferSize: 1 })
|
||||||
@ -41,6 +45,23 @@ export class PayoutDetailsComponent {
|
|||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private payoutManagementService: PayoutManagementService,
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatCardModule } from '@angular/material/card';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
import { MatDividerModule } from '@angular/material/divider';
|
import { MatDividerModule } from '@angular/material/divider';
|
||||||
import { MatPaginatorModule } from '@angular/material/paginator';
|
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 { EmptySearchResultModule } from '@cc/components/empty-search-result';
|
||||||
import { HeadlineModule } from '@cc/components/headline';
|
import { HeadlineModule } from '@cc/components/headline';
|
||||||
|
|
||||||
|
import { ActionsModule } from '../../../../components/actions';
|
||||||
import { PayoutDetailsRoutingModule } from './payout-details-routing.module';
|
import { PayoutDetailsRoutingModule } from './payout-details-routing.module';
|
||||||
import { PayoutDetailsComponent } from './payout-details.component';
|
import { PayoutDetailsComponent } from './payout-details.component';
|
||||||
|
|
||||||
@ -33,6 +35,8 @@ import { PayoutDetailsComponent } from './payout-details.component';
|
|||||||
MatTableModule,
|
MatTableModule,
|
||||||
EmptySearchResultModule,
|
EmptySearchResultModule,
|
||||||
MatPaginatorModule,
|
MatPaginatorModule,
|
||||||
|
MatButtonModule,
|
||||||
|
ActionsModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class PayoutDetailsModule {}
|
export class PayoutDetailsModule {}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { Component, Inject } from '@angular/core';
|
import { Component, Injector } from '@angular/core';
|
||||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
|
||||||
import { FormControl } from '@ngneat/reactive-forms';
|
import { FormControl } from '@ngneat/reactive-forms';
|
||||||
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
||||||
import { PayoutID } from '@vality/payout-manager-proto';
|
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 { NotificationService } from '@cc/app/shared/services/notification';
|
||||||
import { progressTo } from '@cc/utils/operators';
|
import { progressTo } from '@cc/utils/operators';
|
||||||
|
|
||||||
|
import {
|
||||||
|
BaseDialogResponseStatus,
|
||||||
|
BaseDialogSuperclass,
|
||||||
|
} from '../../../../../../components/base-dialog';
|
||||||
|
|
||||||
@UntilDestroy()
|
@UntilDestroy()
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'cc-cancel-payout-dialog',
|
selector: 'cc-cancel-payout-dialog',
|
||||||
templateUrl: './cancel-payout-dialog.component.html',
|
templateUrl: './cancel-payout-dialog.component.html',
|
||||||
})
|
})
|
||||||
export class CancelPayoutDialogComponent {
|
export class CancelPayoutDialogComponent extends BaseDialogSuperclass<
|
||||||
|
CancelPayoutDialogComponent,
|
||||||
|
{ id: PayoutID }
|
||||||
|
> {
|
||||||
detailsControl = new FormControl<string>();
|
detailsControl = new FormControl<string>();
|
||||||
progress$ = new BehaviorSubject(0);
|
progress$ = new BehaviorSubject(0);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dialogRef: MatDialogRef<CancelPayoutDialogComponent, boolean>,
|
injector: Injector,
|
||||||
@Inject(MAT_DIALOG_DATA) private data: { id: PayoutID },
|
|
||||||
private payoutManagementService: PayoutManagementService,
|
private payoutManagementService: PayoutManagementService,
|
||||||
private notificationService: NotificationService
|
private notificationService: NotificationService
|
||||||
) {}
|
) {
|
||||||
|
super(injector);
|
||||||
|
}
|
||||||
|
|
||||||
accept() {
|
accept() {
|
||||||
this.payoutManagementService
|
this.payoutManagementService
|
||||||
.CancelPayout(this.data.id, this.detailsControl.value)
|
.CancelPayout(this.dialogData.id, this.detailsControl.value)
|
||||||
.pipe(progressTo(this.progress$), untilDestroyed(this))
|
.pipe(progressTo(this.progress$), untilDestroyed(this))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.dialogRef.close(true);
|
this.dialogRef.close({ status: BaseDialogResponseStatus.Success });
|
||||||
|
this.notificationService.success('Payout canceled successfully');
|
||||||
},
|
},
|
||||||
error: (err) => {
|
error: (err) => {
|
||||||
this.notificationService.error('Payout cancellation error');
|
this.notificationService.error('Payout cancellation error');
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, Injector } from '@angular/core';
|
||||||
import { MatDialogRef } from '@angular/material/dialog';
|
|
||||||
import { FormBuilder } from '@ngneat/reactive-forms';
|
import { FormBuilder } from '@ngneat/reactive-forms';
|
||||||
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
||||||
import { PayoutParams } from '@vality/payout-manager-proto';
|
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 { progressTo } from '@cc/utils/operators';
|
||||||
import { toMinor } from '@cc/utils/to-minor';
|
import { toMinor } from '@cc/utils/to-minor';
|
||||||
|
|
||||||
|
import {
|
||||||
|
BaseDialogResponseStatus,
|
||||||
|
BaseDialogSuperclass,
|
||||||
|
} from '../../../../../../components/base-dialog';
|
||||||
|
|
||||||
interface CreatePayoutDialogForm {
|
interface CreatePayoutDialogForm {
|
||||||
partyId: string;
|
partyId: string;
|
||||||
shopId: string;
|
shopId: string;
|
||||||
@ -26,7 +30,7 @@ interface CreatePayoutDialogForm {
|
|||||||
templateUrl: './create-payout-dialog.component.html',
|
templateUrl: './create-payout-dialog.component.html',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class CreatePayoutDialogComponent {
|
export class CreatePayoutDialogComponent extends BaseDialogSuperclass<CreatePayoutDialogComponent> {
|
||||||
progress$ = new BehaviorSubject(0);
|
progress$ = new BehaviorSubject(0);
|
||||||
control = this.fb.group<CreatePayoutDialogForm>({
|
control = this.fb.group<CreatePayoutDialogForm>({
|
||||||
partyId: null,
|
partyId: null,
|
||||||
@ -37,11 +41,13 @@ export class CreatePayoutDialogComponent {
|
|||||||
});
|
});
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
injector: Injector,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private payoutManagementService: PayoutManagementService,
|
private payoutManagementService: PayoutManagementService,
|
||||||
private dialogRef: MatDialogRef<CreatePayoutDialogComponent, boolean>,
|
|
||||||
private notificationService: NotificationService
|
private notificationService: NotificationService
|
||||||
) {}
|
) {
|
||||||
|
super(injector);
|
||||||
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
const { value } = this.control;
|
const { value } = this.control;
|
||||||
@ -65,7 +71,8 @@ export class CreatePayoutDialogComponent {
|
|||||||
.pipe(untilDestroyed(this), progressTo(this.progress$))
|
.pipe(untilDestroyed(this), progressTo(this.progress$))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.dialogRef.close(true);
|
this.notificationService.error('Payout created successfully');
|
||||||
|
this.dialogRef.close({ status: BaseDialogResponseStatus.Success });
|
||||||
},
|
},
|
||||||
error: (err) => {
|
error: (err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
@ -1,20 +1,10 @@
|
|||||||
import { Component, Inject, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { UntilDestroy } from '@ngneat/until-destroy';
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
|
||||||
import { PayoutID, PayoutStatus, StatPayout } from '@vality/magista-proto';
|
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 { 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 { PayoutActionsService } from '../../../services/payout-actions.service';
|
||||||
import { CancelPayoutDialogComponent } from '../cancel-payout-dialog/cancel-payout-dialog.component';
|
|
||||||
|
|
||||||
@UntilDestroy()
|
@UntilDestroy()
|
||||||
@Component({
|
@Component({
|
||||||
@ -37,14 +27,7 @@ export class PayoutsTableComponent {
|
|||||||
'actions',
|
'actions',
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(
|
constructor(private payoutActionsService: PayoutActionsService) {}
|
||||||
private router: Router,
|
|
||||||
private payoutManagementService: PayoutManagementService,
|
|
||||||
private dialog: MatDialog,
|
|
||||||
private baseDialogService: BaseDialogService,
|
|
||||||
@Inject(DIALOG_CONFIG) private dialogConfig: DialogConfig,
|
|
||||||
private notificationService: NotificationService
|
|
||||||
) {}
|
|
||||||
|
|
||||||
getColorByStatus(status: keyof PayoutStatus) {
|
getColorByStatus(status: keyof PayoutStatus) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
@ -61,37 +44,18 @@ export class PayoutsTableComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canBeConfirmed(status: keyof PayoutStatus) {
|
canBeConfirmed(status: keyof PayoutStatus) {
|
||||||
return (['paid'] as (keyof PayoutStatus)[]).includes(status);
|
return this.payoutActionsService.canBeConfirmed(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
canBeCancelled(status: keyof PayoutStatus) {
|
canBeCancelled(status: keyof PayoutStatus) {
|
||||||
return (['paid', 'confirmed', 'unpaid'] as (keyof PayoutStatus)[]).includes(status);
|
return this.payoutActionsService.canBeCancelled(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel(id: PayoutID) {
|
cancel(id: PayoutID) {
|
||||||
this.dialog
|
this.payoutActionsService.cancel(id);
|
||||||
.open(CancelPayoutDialogComponent, {
|
|
||||||
...this.dialogConfig.medium,
|
|
||||||
data: { id },
|
|
||||||
})
|
|
||||||
.afterClosed()
|
|
||||||
.subscribe();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
confirm(id: PayoutID) {
|
confirm(id: PayoutID) {
|
||||||
this.baseDialogService
|
this.payoutActionsService.confirm(id);
|
||||||
.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);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<div fxLayout="column" fxLayoutGap="24px">
|
<div fxLayout="column" fxLayoutGap="24px">
|
||||||
<div fxLayout="row" fxLayoutAlign="space-between">
|
<div fxLayout="row" fxLayoutAlign="space-between">
|
||||||
<h1 class="cc-headline">Payouts</h1>
|
<h1 class="cc-headline">Payouts</h1>
|
||||||
<div><button mat-button (click)="create()">CREATE</button></div>
|
<div><button color="primary" mat-button (click)="create()">CREATE</button></div>
|
||||||
</div>
|
</div>
|
||||||
<mat-card>
|
<mat-card>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { ChangeDetectionStrategy, Component, Inject, OnInit } from '@angular/core';
|
import { Component, Inject, OnInit } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
|
||||||
import { FormControl } from '@ngneat/reactive-forms';
|
import { FormControl } from '@ngneat/reactive-forms';
|
||||||
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
||||||
import omitBy from 'lodash-es/omitBy';
|
import omitBy from 'lodash-es/omitBy';
|
||||||
import { debounceTime } from 'rxjs/operators';
|
|
||||||
|
|
||||||
import { QueryParamsService } from '@cc/app/shared/services';
|
import { QueryParamsService } from '@cc/app/shared/services';
|
||||||
import { isNilOrEmptyString } from '@cc/utils/is-nil-or-empty-string';
|
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 { DIALOG_CONFIG, DialogConfig } from '../../../tokens';
|
||||||
|
import { PayoutActionsService } from '../services/payout-actions.service';
|
||||||
import { CreatePayoutDialogComponent } from './components/create-payout-dialog/create-payout-dialog.component';
|
import { CreatePayoutDialogComponent } from './components/create-payout-dialog/create-payout-dialog.component';
|
||||||
import { PayoutsSearchForm } from './components/payouts-search-form/payouts-search-form.component';
|
import { PayoutsSearchForm } from './components/payouts-search-form/payouts-search-form.component';
|
||||||
import { FetchPayoutsService, SearchParams } from './services/fetch-payouts.service';
|
import { FetchPayoutsService, SearchParams } from './services/fetch-payouts.service';
|
||||||
@ -18,34 +18,33 @@ import { FetchPayoutsService, SearchParams } from './services/fetch-payouts.serv
|
|||||||
selector: 'cc-payouts',
|
selector: 'cc-payouts',
|
||||||
templateUrl: './payouts.component.html',
|
templateUrl: './payouts.component.html',
|
||||||
styleUrls: ['./payouts.component.scss'],
|
styleUrls: ['./payouts.component.scss'],
|
||||||
providers: [FetchPayoutsService],
|
providers: [FetchPayoutsService, PayoutActionsService],
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
||||||
})
|
})
|
||||||
export class PayoutsComponent implements OnInit {
|
export class PayoutsComponent implements OnInit {
|
||||||
control = new FormControl<PayoutsSearchForm>(this.qp.params);
|
control = new FormControl<PayoutsSearchForm>(this.qp.params as PayoutsSearchForm);
|
||||||
inProgress$ = this.fetchPayoutsService.doAction$;
|
inProgress$ = this.fetchPayoutsService.doAction$;
|
||||||
payouts$ = this.fetchPayoutsService.searchResult$;
|
payouts$ = this.fetchPayoutsService.searchResult$;
|
||||||
hasMore$ = this.fetchPayoutsService.hasMore$;
|
hasMore$ = this.fetchPayoutsService.hasMore$;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private fetchPayoutsService: FetchPayoutsService,
|
private fetchPayoutsService: FetchPayoutsService,
|
||||||
private qp: QueryParamsService<PayoutsSearchForm>,
|
private qp: QueryParamsService<Partial<PayoutsSearchForm>>,
|
||||||
private dialog: MatDialog,
|
private baseDialogService: BaseDialogService,
|
||||||
@Inject(DIALOG_CONFIG) private dialogConfig: DialogConfig
|
@Inject(DIALOG_CONFIG) private dialogConfig: DialogConfig
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.control.valueChanges
|
this.control.valueChanges
|
||||||
.pipe(debounceTime(250), untilDestroyed(this))
|
.pipe(untilDestroyed(this))
|
||||||
.subscribe((value) => this.search(value));
|
.subscribe((value) => void this.qp.set(omitBy(value, isNilOrEmptyString)));
|
||||||
|
this.qp.params$.pipe(untilDestroyed(this)).subscribe((value) => this.search(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchMore() {
|
fetchMore() {
|
||||||
this.fetchPayoutsService.fetchMore();
|
this.fetchPayoutsService.fetchMore();
|
||||||
}
|
}
|
||||||
|
|
||||||
search(value: PayoutsSearchForm) {
|
search(value: Partial<PayoutsSearchForm>) {
|
||||||
void this.qp.set(omitBy(value, isNilOrEmptyString) as PayoutsSearchForm);
|
|
||||||
this.fetchPayoutsService.search(
|
this.fetchPayoutsService.search(
|
||||||
omitBy(
|
omitBy(
|
||||||
{
|
{
|
||||||
@ -68,10 +67,6 @@ export class PayoutsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
this.dialog
|
this.baseDialogService.open(CreatePayoutDialogComponent);
|
||||||
.open(CreatePayoutDialogComponent, this.dialogConfig.medium)
|
|
||||||
.afterClosed()
|
|
||||||
.pipe(untilDestroyed(this))
|
|
||||||
.subscribe();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import { MerchantFieldModule } from '@cc/app/shared/components/merchant-field';
|
|||||||
import { ApiModelPipesModule, CommonPipesModule, ThriftPipesModule } from '@cc/app/shared/pipes';
|
import { ApiModelPipesModule, CommonPipesModule, ThriftPipesModule } from '@cc/app/shared/pipes';
|
||||||
import { EmptySearchResultModule } from '@cc/components/empty-search-result';
|
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 { CancelPayoutDialogComponent } from './components/cancel-payout-dialog/cancel-payout-dialog.component';
|
||||||
import { CreatePayoutDialogComponent } from './components/create-payout-dialog/create-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';
|
import { PayoutsSearchFormComponent } from './components/payouts-search-form/payouts-search-form.component';
|
||||||
@ -59,6 +60,7 @@ import { PayoutsComponent } from './payouts.component';
|
|||||||
MatDialogModule,
|
MatDialogModule,
|
||||||
ShopFieldModule,
|
ShopFieldModule,
|
||||||
PayoutToolFieldModule,
|
PayoutToolFieldModule,
|
||||||
|
BaseDialogModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class PayoutsModule {}
|
export class PayoutsModule {}
|
||||||
|
@ -32,7 +32,7 @@ export class FetchPayoutsService extends PartialFetcher<StatPayout, SearchParams
|
|||||||
...params,
|
...params,
|
||||||
common_search_query_params: {
|
common_search_query_params: {
|
||||||
...params.common_search_query_params,
|
...params.common_search_query_params,
|
||||||
continuation_token: continuationToken,
|
...(continuationToken ? { continuation_token: continuationToken } : {}),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.pipe(
|
.pipe(
|
||||||
|
51
src/app/sections/payouts/services/payout-actions.service.ts
Normal file
51
src/app/sections/payouts/services/payout-actions.service.ts
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
||||||
|
import { PayoutID, PayoutStatus } from '@vality/magista-proto';
|
||||||
|
import { switchMap } from 'rxjs';
|
||||||
|
import { filter } from 'rxjs/operators';
|
||||||
|
|
||||||
|
import { BaseDialogResponseStatus } from '../../../../components/base-dialog';
|
||||||
|
import { BaseDialogService } from '../../../../components/base-dialog/services/base-dialog.service';
|
||||||
|
import { ConfirmActionDialogComponent } from '../../../../components/confirm-action-dialog';
|
||||||
|
import { PayoutManagementService } from '../../../api/payout-manager';
|
||||||
|
import { NotificationService } from '../../../shared/services/notification';
|
||||||
|
import { CancelPayoutDialogComponent } from '../payouts/components/cancel-payout-dialog/cancel-payout-dialog.component';
|
||||||
|
|
||||||
|
@UntilDestroy()
|
||||||
|
@Injectable()
|
||||||
|
export class PayoutActionsService {
|
||||||
|
constructor(
|
||||||
|
private payoutManagementService: PayoutManagementService,
|
||||||
|
private baseDialogService: BaseDialogService,
|
||||||
|
private notificationService: NotificationService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
canBeConfirmed(status: keyof PayoutStatus) {
|
||||||
|
return (['paid'] as (keyof PayoutStatus)[]).includes(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
canBeCancelled(status: keyof PayoutStatus) {
|
||||||
|
return (['paid', 'confirmed', 'unpaid'] as (keyof PayoutStatus)[]).includes(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
cancel(id: PayoutID) {
|
||||||
|
this.baseDialogService.open(CancelPayoutDialogComponent, { 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);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@ import { combineLatest, defer, Observable } from 'rxjs';
|
|||||||
import { map, pluck, shareReplay, switchMap } from 'rxjs/operators';
|
import { map, pluck, shareReplay, switchMap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { FistfulStatisticsService } from '@cc/app/api/fistful-stat';
|
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 { createDsl } from '../../../query-dsl';
|
||||||
import { RoutingRulesService } from '../../../thrift-services';
|
import { RoutingRulesService } from '../../../thrift-services';
|
||||||
@ -48,14 +48,14 @@ export class PartyRoutingRulesetService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private party$ = this.partyID$.pipe(
|
private party$ = this.partyID$.pipe(
|
||||||
switchMap((partyID) => this.partyManagementWithUserService.getParty(partyID)),
|
switchMap((partyID) => this.partyManagementService.Get(partyID)),
|
||||||
untilDestroyed(this),
|
untilDestroyed(this),
|
||||||
shareReplay(1)
|
shareReplay(1)
|
||||||
);
|
);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private partyManagementWithUserService: PartyManagementWithUserService,
|
private partyManagementService: PartyManagementService,
|
||||||
private domainStoreService: DomainStoreService,
|
private domainStoreService: DomainStoreService,
|
||||||
private routingRulesService: RoutingRulesService,
|
private routingRulesService: RoutingRulesService,
|
||||||
private fistfulStatistics: FistfulStatisticsService
|
private fistfulStatistics: FistfulStatisticsService
|
||||||
|
@ -7,7 +7,7 @@ import { startWith, switchMap, take } from 'rxjs/operators';
|
|||||||
|
|
||||||
import { BaseDialogResponseStatus } from '@cc/components/base-dialog';
|
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';
|
import { AddRoutingRuleDialogComponent } from './add-routing-rule-dialog.component';
|
||||||
|
|
||||||
export enum TerminalType {
|
export enum TerminalType {
|
||||||
@ -38,8 +38,7 @@ export class AddRoutingRuleDialogService {
|
|||||||
constructor(
|
constructor(
|
||||||
private fb: UntypedFormBuilder,
|
private fb: UntypedFormBuilder,
|
||||||
private dialogRef: MatDialogRef<AddRoutingRuleDialogComponent>,
|
private dialogRef: MatDialogRef<AddRoutingRuleDialogComponent>,
|
||||||
private routingRulesService: RoutingRulesService,
|
private routingRulesService: RoutingRulesService
|
||||||
private terminalService: TerminalService
|
|
||||||
) {
|
) {
|
||||||
this.form
|
this.form
|
||||||
.get('terminalType')
|
.get('terminalType')
|
||||||
@ -67,10 +66,10 @@ export class AddRoutingRuleDialogService {
|
|||||||
const { description, weight, priority, terminalType, existentTerminalID, newTerminal } =
|
const { description, weight, priority, terminalType, existentTerminalID, newTerminal } =
|
||||||
this.form.value;
|
this.form.value;
|
||||||
(terminalType === TerminalType.New
|
(terminalType === TerminalType.New
|
||||||
? this.terminalService.createTerminal({
|
? this.routingRulesService.createTerminal({
|
||||||
terminalName: newTerminal.name,
|
name: newTerminal.name,
|
||||||
terminalDescription: newTerminal.description,
|
description: newTerminal.description,
|
||||||
riskCoverage: newTerminal.riskCoverage,
|
risk_coverage: newTerminal.riskCoverage,
|
||||||
options: newTerminal.options,
|
options: newTerminal.options,
|
||||||
})
|
})
|
||||||
: of(existentTerminalID)
|
: of(existentTerminalID)
|
||||||
|
@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router';
|
|||||||
import { combineLatest, Observable } from 'rxjs';
|
import { combineLatest, Observable } from 'rxjs';
|
||||||
import { map, pluck, shareReplay, switchMap, take } from 'rxjs/operators';
|
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 { handleError } from '../../../../utils/operators/handle-error';
|
||||||
import { ErrorService } from '../../../shared/services/error';
|
import { ErrorService } from '../../../shared/services/error';
|
||||||
@ -27,7 +27,7 @@ export class RoutingRulesetService {
|
|||||||
shareReplay(1)
|
shareReplay(1)
|
||||||
);
|
);
|
||||||
private party$ = this.partyID$.pipe(
|
private party$ = this.partyID$.pipe(
|
||||||
switchMap((partyID) => this.partyManagementWithUserService.getParty(partyID)),
|
switchMap((partyID) => this.partyManagementService.Get(partyID)),
|
||||||
shareReplay(1)
|
shareReplay(1)
|
||||||
);
|
);
|
||||||
// eslint-disable-next-line @typescript-eslint/member-ordering
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
||||||
@ -45,7 +45,7 @@ export class RoutingRulesetService {
|
|||||||
constructor(
|
constructor(
|
||||||
private routingRulesService: RoutingRulesDamselService,
|
private routingRulesService: RoutingRulesDamselService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private partyManagementWithUserService: PartyManagementWithUserService,
|
private partyManagementService: PartyManagementService,
|
||||||
private errorService: ErrorService
|
private errorService: ErrorService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import { PartyID, ShopID } from '@vality/domain-proto';
|
|||||||
import { BehaviorSubject, merge, of, Subject } from 'rxjs';
|
import { BehaviorSubject, merge, of, Subject } from 'rxjs';
|
||||||
import { catchError, filter, shareReplay, startWith, switchMap } from 'rxjs/operators';
|
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';
|
import { progress } from '@cc/app/shared/custom-operators';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -15,7 +15,7 @@ export class FetchShopService {
|
|||||||
// eslint-disable-next-line @typescript-eslint/member-ordering
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
||||||
shop$ = this.getShop$.pipe(
|
shop$ = this.getShop$.pipe(
|
||||||
switchMap(({ partyID, shopID }) =>
|
switchMap(({ partyID, shopID }) =>
|
||||||
this.partyManagementWithUserService.getShop(partyID, shopID).pipe(
|
this.partyManagementService.GetShop(partyID, shopID).pipe(
|
||||||
catchError((e) => {
|
catchError((e) => {
|
||||||
this.hasError$.next(e);
|
this.hasError$.next(e);
|
||||||
this.snackBar.open('An error occurred while fetching shop', 'OK');
|
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));
|
inProgress$ = progress(this.getShop$, merge(this.shop$, this.hasError$)).pipe(startWith(true));
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private partyManagementWithUserService: PartyManagementWithUserService,
|
private partyManagementService: PartyManagementService,
|
||||||
private snackBar: MatSnackBar
|
private snackBar: MatSnackBar
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
@ -8,14 +8,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
<div class="cc-headline">Providers</div>
|
|
||||||
<mat-card>
|
|
||||||
<mat-card-content>
|
|
||||||
<cc-shop-providers
|
|
||||||
[categoryID]="categoryID$ | async"
|
|
||||||
[partyID]="partyID$ | async"
|
|
||||||
[shopID]="shopID$ | async"
|
|
||||||
></cc-shop-providers>
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,7 +9,6 @@ import { HeadlineModule } from '@cc/components/headline';
|
|||||||
import { ShopDetailsRoutingModule } from './shop-details-routing.module';
|
import { ShopDetailsRoutingModule } from './shop-details-routing.module';
|
||||||
import { ShopDetailsComponent } from './shop-details.component';
|
import { ShopDetailsComponent } from './shop-details.component';
|
||||||
import { ShopMainInfoModule } from './shop-main-info';
|
import { ShopMainInfoModule } from './shop-main-info';
|
||||||
import { ShopProvidersModule } from './shop-providers';
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@ -20,7 +19,6 @@ import { ShopProvidersModule } from './shop-providers';
|
|||||||
MatCardModule,
|
MatCardModule,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
MatProgressSpinnerModule,
|
MatProgressSpinnerModule,
|
||||||
ShopProvidersModule,
|
|
||||||
],
|
],
|
||||||
declarations: [ShopDetailsComponent],
|
declarations: [ShopDetailsComponent],
|
||||||
})
|
})
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
<div class="mat-dialog-title">Add terminal</div>
|
|
||||||
<mat-dialog-content>
|
|
||||||
<mat-horizontal-stepper [linear]="true">
|
|
||||||
<mat-step [stepControl]="providerForm">
|
|
||||||
<ng-template matStepLabel>Select provider:</ng-template>
|
|
||||||
<div fxLayout="column" fxLayoutGap="20px">
|
|
||||||
<cc-select-provider
|
|
||||||
[providers]="providers$ | async"
|
|
||||||
(providerIDSelected)="providerIDSelected($event)"
|
|
||||||
></cc-select-provider>
|
|
||||||
<div>
|
|
||||||
<button
|
|
||||||
[disabled]="!providerForm.valid"
|
|
||||||
color="primary"
|
|
||||||
mat-button
|
|
||||||
matStepperNext
|
|
||||||
>
|
|
||||||
NEXT
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</mat-step>
|
|
||||||
<mat-step [stepControl]="terminalForm">
|
|
||||||
<ng-template matStepLabel>Select or create terminal:</ng-template>
|
|
||||||
<div fxLayout="column" fxLayoutGap="20px">
|
|
||||||
<cc-terminals-table
|
|
||||||
[terminals]="terminals$ | async"
|
|
||||||
(terminalIDSelected)="terminalIDSelected($event)"
|
|
||||||
></cc-terminals-table>
|
|
||||||
<div><button color="primary" mat-button matStepperPrevious>BACK</button></div>
|
|
||||||
</div>
|
|
||||||
</mat-step>
|
|
||||||
</mat-horizontal-stepper>
|
|
||||||
</mat-dialog-content>
|
|
||||||
<mat-dialog-actions>
|
|
||||||
<div>
|
|
||||||
<button
|
|
||||||
[disabled]="!(providerForm.valid && terminalForm.valid) || (inProgress$ | async)"
|
|
||||||
mat-button
|
|
||||||
(click)="add()"
|
|
||||||
>
|
|
||||||
ADD
|
|
||||||
</button>
|
|
||||||
<button [disabled]="inProgress$ | async" [mat-dialog-close]="false" mat-button>
|
|
||||||
CANCEL
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<mat-progress-bar *ngIf="inProgress$ | async" mode="indeterminate"></mat-progress-bar>
|
|
||||||
</mat-dialog-actions>
|
|
@ -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<AddTerminalDialogComponent, AddTerminalDialogResponse>,
|
|
||||||
@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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 {}
|
|
@ -1,2 +0,0 @@
|
|||||||
export * from './select-provider';
|
|
||||||
export * from './terminals-table';
|
|
@ -1 +0,0 @@
|
|||||||
export * from './select-provider.component';
|
|
@ -1,43 +0,0 @@
|
|||||||
<div fxLayout fxLayoutAlign="space-between">
|
|
||||||
<mat-form-field fxFlex>
|
|
||||||
<input
|
|
||||||
matInput
|
|
||||||
placeholder="Filter"
|
|
||||||
type="text"
|
|
||||||
(keyup)="applyFilter($event.target.value)"
|
|
||||||
/>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
<table [dataSource]="dataSource" mat-table>
|
|
||||||
<ng-container matColumnDef="select">
|
|
||||||
<th *matHeaderCellDef mat-header-cell></th>
|
|
||||||
<td *matCellDef="let row" mat-cell>
|
|
||||||
<mat-checkbox
|
|
||||||
[checked]="selection.isSelected(row)"
|
|
||||||
(change)="$event ? selection.toggle(row) : null"
|
|
||||||
(click)="$event.stopPropagation()"
|
|
||||||
>
|
|
||||||
</mat-checkbox>
|
|
||||||
</td>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container matColumnDef="id">
|
|
||||||
<th *matHeaderCellDef class="th" mat-header-cell>ID</th>
|
|
||||||
<td *matCellDef="let provider" class="td" mat-cell>{{ provider.ref.id }}</td>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container matColumnDef="name">
|
|
||||||
<th *matHeaderCellDef class="th" mat-header-cell>Name</th>
|
|
||||||
<td *matCellDef="let provider" class="td" mat-cell>{{ provider.data.name }}</td>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container matColumnDef="description">
|
|
||||||
<th *matHeaderCellDef class="th" mat-header-cell>Description</th>
|
|
||||||
<td *matCellDef="let provider" class="td" mat-cell>{{ provider.data.description }}</td>
|
|
||||||
</ng-container>
|
|
||||||
<tr *matHeaderRowDef="displayedColumns" mat-header-row></tr>
|
|
||||||
<tr
|
|
||||||
*matRowDef="let row; columns: displayedColumns"
|
|
||||||
mat-row
|
|
||||||
(click)="selection.toggle(row)"
|
|
||||||
></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<mat-paginator [pageSizeOptions]="[5, 10, 20, 50]" showFirstLastButtons></mat-paginator>
|
|
@ -1,8 +0,0 @@
|
|||||||
table {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.th,
|
|
||||||
.td {
|
|
||||||
padding: 5px 10px;
|
|
||||||
}
|
|
@ -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<number> = new EventEmitter();
|
|
||||||
|
|
||||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
|
||||||
|
|
||||||
displayedColumns: string[] = ['select', 'id', 'name', 'description'];
|
|
||||||
dataSource: MatTableDataSource<ProviderObject> = new MatTableDataSource([]);
|
|
||||||
selection = new SelectionModel<ProviderObject>(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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from './terminals-table.component';
|
|
@ -1,43 +0,0 @@
|
|||||||
<div fxLayout fxLayoutAlign="space-between">
|
|
||||||
<mat-form-field fxFlex>
|
|
||||||
<input
|
|
||||||
matInput
|
|
||||||
placeholder="Filter"
|
|
||||||
type="text"
|
|
||||||
(keyup)="applyFilter($event.target.value)"
|
|
||||||
/>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
<table [dataSource]="dataSource" mat-table>
|
|
||||||
<ng-container matColumnDef="select">
|
|
||||||
<th *matHeaderCellDef mat-header-cell></th>
|
|
||||||
<td *matCellDef="let row" mat-cell>
|
|
||||||
<mat-checkbox
|
|
||||||
[checked]="selection.isSelected(row)"
|
|
||||||
(change)="$event ? selection.toggle(row) : null"
|
|
||||||
(click)="$event.stopPropagation()"
|
|
||||||
>
|
|
||||||
</mat-checkbox>
|
|
||||||
</td>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container matColumnDef="id">
|
|
||||||
<th *matHeaderCellDef class="th" mat-header-cell>ID</th>
|
|
||||||
<td *matCellDef="let terminal" class="td" mat-cell>{{ terminal.ref.id }}</td>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container matColumnDef="name">
|
|
||||||
<th *matHeaderCellDef class="th" mat-header-cell>Name</th>
|
|
||||||
<td *matCellDef="let terminal" class="td" mat-cell>{{ terminal.data.name }}</td>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container matColumnDef="description">
|
|
||||||
<th *matHeaderCellDef class="th" mat-header-cell>Description</th>
|
|
||||||
<td *matCellDef="let terminal" class="td" mat-cell>{{ terminal.data.description }}</td>
|
|
||||||
</ng-container>
|
|
||||||
<tr *matHeaderRowDef="displayedColumns" mat-header-row></tr>
|
|
||||||
<tr
|
|
||||||
*matRowDef="let row; columns: displayedColumns"
|
|
||||||
mat-row
|
|
||||||
(click)="selection.toggle(row)"
|
|
||||||
></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<mat-paginator [pageSizeOptions]="[5, 10, 20, 50]" showFirstLastButtons></mat-paginator>
|
|
@ -1,8 +0,0 @@
|
|||||||
table {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.th,
|
|
||||||
.td {
|
|
||||||
padding: 5px 10px;
|
|
||||||
}
|
|
@ -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<number> = new EventEmitter();
|
|
||||||
|
|
||||||
displayedColumns: string[] = ['select', 'id', 'name', 'description'];
|
|
||||||
dataSource: MatTableDataSource<TerminalObject> = new MatTableDataSource([]);
|
|
||||||
selection = new SelectionModel<TerminalObject>(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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from './add-terminal-dialog.module';
|
|
@ -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<AddDecisionToProvider>(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<ProviderObject[]> {
|
|
||||||
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],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from './add-terminal-decision.service';
|
|
@ -1 +0,0 @@
|
|||||||
export * from './add-terminal-decision';
|
|
@ -1,39 +0,0 @@
|
|||||||
<div class="mat-dialog-title">
|
|
||||||
{{ data.type === terminalActionTypes.EditWeight ? 'Edit weight' : null }}
|
|
||||||
{{ data.type === terminalActionTypes.EditPriority ? 'Edit priority' : null }}
|
|
||||||
</div>
|
|
||||||
<mat-dialog-content>
|
|
||||||
<mat-form-field fxFlex>
|
|
||||||
<input [formControl]="editValueControl" matInput type="number" />
|
|
||||||
</mat-form-field>
|
|
||||||
</mat-dialog-content>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="dialog-actions"
|
|
||||||
fxLayout="row"
|
|
||||||
fxLayout.xs="column"
|
|
||||||
fxLayoutAlign="space-between stretch"
|
|
||||||
fxLayoutGap="20px"
|
|
||||||
fxLayoutGap.xs="10px"
|
|
||||||
mat-dialog-actions
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
[disabled]="!editValueControl.valid || (inProgress$ | async)"
|
|
||||||
fxFlex
|
|
||||||
fxFlex.xs="none"
|
|
||||||
mat-button
|
|
||||||
(click)="save()"
|
|
||||||
>
|
|
||||||
SAVE
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
[disabled]="inProgress$ | async"
|
|
||||||
[mat-dialog-close]="false"
|
|
||||||
fxFlex
|
|
||||||
fxFlex.xs="none"
|
|
||||||
mat-button
|
|
||||||
>
|
|
||||||
CANCEL
|
|
||||||
</button>
|
|
||||||
<mat-progress-bar *ngIf="inProgress$ | async" mode="indeterminate"></mat-progress-bar>
|
|
||||||
</div>
|
|
@ -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<EditTerminalDialogComponent, EditTerminalDialogResponse>,
|
|
||||||
@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!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from './edit-terminal-dialog.component';
|
|
@ -1 +0,0 @@
|
|||||||
export * from './edit-terminal-dialog';
|
|
@ -1 +0,0 @@
|
|||||||
export * from './shop-providers.module';
|
|
@ -1 +0,0 @@
|
|||||||
export * from './provider.module';
|
|
@ -1,5 +0,0 @@
|
|||||||
<div class="mat-body-1">{{ providerInfo.provider.data.name }}</div>
|
|
||||||
<cc-terminals-info-table
|
|
||||||
[terminalsInfo]="providerInfo.terminalsInfo"
|
|
||||||
(action)="action.emit($event)"
|
|
||||||
></cc-terminals-info-table>
|
|
@ -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<TerminalAction> = new EventEmitter();
|
|
||||||
}
|
|
@ -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 {}
|
|
@ -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';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
<table [dataSource]="terminalsInfo" fxFlex mat-table>
|
|
||||||
<ng-container matColumnDef="name">
|
|
||||||
<th *matHeaderCellDef class="cc-caption" mat-header-cell>Name</th>
|
|
||||||
<td *matCellDef="let terminalInfo" mat-cell>{{ terminalInfo.terminal.data.name }}</td>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container matColumnDef="description">
|
|
||||||
<th *matHeaderCellDef class="cc-caption" mat-header-cell>Description</th>
|
|
||||||
<td *matCellDef="let terminalInfo" mat-cell>
|
|
||||||
{{ terminalInfo.terminal.data.description }}
|
|
||||||
</td>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container matColumnDef="type">
|
|
||||||
<th *matHeaderCellDef class="cc-caption" mat-header-cell>Type</th>
|
|
||||||
<td *matCellDef="let terminalInfo" mat-cell>{{ terminalInfo.predicateType }}</td>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container matColumnDef="priority">
|
|
||||||
<th *matHeaderCellDef class="cc-caption" mat-header-cell>Priority</th>
|
|
||||||
<td *matCellDef="let terminalInfo" mat-cell>
|
|
||||||
{{ terminalInfo.priority }}
|
|
||||||
</td>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container matColumnDef="weight">
|
|
||||||
<th *matHeaderCellDef class="cc-caption" mat-header-cell>Weight</th>
|
|
||||||
<td *matCellDef="let terminalInfo" mat-cell>{{ terminalInfo.weight }}</td>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container matColumnDef="status">
|
|
||||||
<th *matHeaderCellDef class="cc-caption" mat-header-cell>Status</th>
|
|
||||||
<td *matCellDef="let terminalInfo" mat-cell>
|
|
||||||
{{ !terminalInfo.disabled | ccIsActive }}
|
|
||||||
</td>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container matColumnDef="actions">
|
|
||||||
<th *matHeaderCellDef class="action-cell" mat-header-cell></th>
|
|
||||||
<td *matCellDef="let terminalInfo" class="action-cell" mat-cell>
|
|
||||||
<button [matMenuTriggerFor]="menu" mat-icon-button>
|
|
||||||
<mat-icon>more_vert</mat-icon>
|
|
||||||
</button>
|
|
||||||
<mat-menu #menu="matMenu">
|
|
||||||
<button
|
|
||||||
mat-menu-item
|
|
||||||
(click)="actions(terminalActionTypes.EditWeight, terminalInfo.terminal.ref.id)"
|
|
||||||
>
|
|
||||||
Edit weight
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
mat-menu-item
|
|
||||||
(click)="
|
|
||||||
actions(terminalActionTypes.EditPriority, terminalInfo.terminal.ref.id)
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Edit priority
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
mat-menu-item
|
|
||||||
(click)="
|
|
||||||
actions(terminalActionTypes.RemoveTerminal, terminalInfo.terminal.ref.id)
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Remove terminal
|
|
||||||
</button>
|
|
||||||
</mat-menu>
|
|
||||||
</td>
|
|
||||||
</ng-container>
|
|
||||||
<tr *matHeaderRowDef="displayedColumns" mat-header-row></tr>
|
|
||||||
<tr *matRowDef="let shop; columns: displayedColumns" mat-row></tr>
|
|
||||||
</table>
|
|
@ -1,3 +0,0 @@
|
|||||||
table {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
@ -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<TerminalAction> = new EventEmitter();
|
|
||||||
|
|
||||||
displayedColumns = ['name', 'description', 'type', 'priority', 'weight', 'status', 'actions'];
|
|
||||||
terminalActionTypes = TerminalActionTypes;
|
|
||||||
|
|
||||||
actions(type: TerminalActionTypes, terminalID: TerminalID) {
|
|
||||||
this.action.emit({ type, terminalID });
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 {}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from './add-provider.service';
|
|
@ -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<ChangeProviderParams>();
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from './edit-terminal-decision.service';
|
|
@ -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<Predicate>, 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<Predicate>): 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<Predicate>, shopID, partyID),
|
|
||||||
predicateType: PredicateType.AllOf,
|
|
||||||
disabled: isDisabled(v as Set<Predicate>),
|
|
||||||
};
|
|
||||||
case 'any_of':
|
|
||||||
return {
|
|
||||||
shopPartyContain: inPredicates(v as Set<Predicate>, 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);
|
|
||||||
}
|
|
@ -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 });
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from './fetch-shop-providers.service';
|
|
@ -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,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}, []);
|
|
@ -1,4 +0,0 @@
|
|||||||
export * from './fetch-shop-providers';
|
|
||||||
export * from './remove-terminal-decision';
|
|
||||||
export * from './edit-terminal-decision';
|
|
||||||
export * from './add-provider';
|
|
@ -1 +0,0 @@
|
|||||||
export * from './remove-terminal-decision.service';
|
|
@ -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<ChangeProviderParams>();
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
||||||
error$ = new Subject<void>();
|
|
||||||
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
||||||
cancelled$ = new Subject<void>();
|
|
||||||
|
|
||||||
// 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<RemoveTerminalFromShopParams>(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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
<div fxLayout fxLayoutAlign="end">
|
|
||||||
<button color="primary" mat-raised-button (click)="addTerminal()">ADD TERMINAL</button>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
*ngIf="(providersInfo$ | async)?.length && !(fetchProgress$ | async)"
|
|
||||||
fxLayout="column"
|
|
||||||
fxLayoutGap="24px"
|
|
||||||
>
|
|
||||||
<cc-provider
|
|
||||||
*ngFor="let providerInfo of providersInfo$ | async"
|
|
||||||
[partyID]="partyID"
|
|
||||||
[providerInfo]="providerInfo"
|
|
||||||
[shopID]="shopID"
|
|
||||||
(action)="action($event, providerInfo.provider.ref.id)"
|
|
||||||
></cc-provider>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="fetchProgress$ | async" fxLayout fxLayoutAlign="center center">
|
|
||||||
<mat-spinner diameter="64"></mat-spinner>
|
|
||||||
</div>
|
|
||||||
<cc-empty-search-result
|
|
||||||
*ngIf="!(providersInfo$ | async)?.length && !(fetchProgress$ | async)"
|
|
||||||
unwrapped
|
|
||||||
></cc-empty-search-result>
|
|
||||||
<mat-progress-bar *ngIf="removeProgress$ | async" mode="indeterminate"></mat-progress-bar>
|
|
@ -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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 {}
|
|
@ -1 +0,0 @@
|
|||||||
export type AddTerminalDialogResponse = 'added' | 'canceled';
|
|
@ -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;
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export type EditTerminalDialogResponse = 'edited' | 'canceled';
|
|
@ -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;
|
|
||||||
}
|
|
@ -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';
|
|
@ -1,7 +0,0 @@
|
|||||||
import { PredicateType } from './predicate-type';
|
|
||||||
|
|
||||||
export interface PredicateInfo {
|
|
||||||
shopPartyContain: boolean;
|
|
||||||
predicateType?: PredicateType;
|
|
||||||
disabled?: boolean;
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
export enum PredicateType {
|
|
||||||
Condition = 'condition',
|
|
||||||
IsNot = 'is_not',
|
|
||||||
AllOf = 'all_of',
|
|
||||||
AnyOf = 'any_of',
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
import { ProviderObject } from '@vality/domain-proto/lib/domain';
|
|
||||||
|
|
||||||
import { TerminalInfo } from './terminal-info';
|
|
||||||
|
|
||||||
export interface ProviderInfo {
|
|
||||||
provider: ProviderObject;
|
|
||||||
terminalsInfo: TerminalInfo[];
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
export enum TerminalActionTypes {
|
|
||||||
EditWeight = 'editWeight',
|
|
||||||
EditPriority = 'editPriority',
|
|
||||||
RemoveTerminal = 'removeTerminal',
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
import { TerminalID } from '@vality/fistful-proto';
|
|
||||||
|
|
||||||
import { TerminalActionTypes } from './terminal-action-types';
|
|
||||||
|
|
||||||
export interface TerminalAction {
|
|
||||||
type: TerminalActionTypes;
|
|
||||||
terminalID: TerminalID;
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user