diff --git a/src/app/papi/category.service.ts b/src/app/papi/category.service.ts index 19442d41..e9aa0a95 100644 --- a/src/app/papi/category.service.ts +++ b/src/app/papi/category.service.ts @@ -3,7 +3,7 @@ import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { ConfigService } from '../core/config.service'; -import { Category } from './model/category'; +import { Category } from './model'; @Injectable() export class CategoryService { diff --git a/src/app/party/party.service.ts b/src/app/party/party.service.ts index dffe7e72..abe98fd8 100644 --- a/src/app/party/party.service.ts +++ b/src/app/party/party.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { Party, Shop } from '../gen-damsel/domain'; +import { Contract, Party, PayoutTool, Shop } from '../gen-damsel/domain'; import { PartyService as PapiPartyService } from '../papi/party.service'; import { map, tap } from 'rxjs/operators'; @@ -33,4 +33,30 @@ export class PartyService { getShop(partyID: string, shopID: string): Observable { return this.getShops(partyID).pipe(map(shops => shops.find(shop => shop.id === shopID))); } + + getContracts(partyID: string): Observable { + return this.getParty(partyID).pipe(map(party => Array.from(party.contracts.values()))); + } + + getContract(partyID: string, contractID: string): Observable { + return this.getContracts(partyID).pipe( + map(contracts => contracts.find(contract => contract.id === contractID)) + ); + } + + getPayoutTools(partyID: string, contractID: string): Observable { + return this.getContract(partyID, contractID).pipe( + map(contract => Array.from(contract.payout_tools.values())) + ); + } + + getPayoutTool( + partyID: string, + contractID: string, + payoutToolID: string + ): Observable { + return this.getPayoutTools(partyID, contractID).pipe( + map(payoutTools => payoutTools.find(payoutTool => payoutTool.id === payoutToolID)) + ); + } } diff --git a/src/app/party/shop-details/shop-details.component.html b/src/app/party/shop-details/shop-details.component.html index f7a3d7ce..b62512dc 100644 --- a/src/app/party/shop-details/shop-details.component.html +++ b/src/app/party/shop-details/shop-details.component.html @@ -7,9 +7,29 @@ Shop details - + +
+ + + + Contract details + + + + + + + + + Payout tool details + + + + + +
Shop actions diff --git a/src/app/party/shop-details/shop-details.component.ts b/src/app/party/shop-details/shop-details.component.ts index d9d92819..ef8f2544 100644 --- a/src/app/party/shop-details/shop-details.component.ts +++ b/src/app/party/shop-details/shop-details.component.ts @@ -4,7 +4,7 @@ import { filter, switchMap } from 'rxjs/operators'; import { MatDialog } from '@angular/material'; import { ShopDetailsService, ProviderInfo } from './shop-details.service'; -import { Shop } from '../../gen-damsel/domain'; +import { Contract, PayoutTool, Shop } from '../../gen-damsel/domain'; import { AddProviderComponent } from './add-provider/add-provider.component'; @Component({ @@ -15,6 +15,8 @@ import { AddProviderComponent } from './add-provider/add-provider.component'; export class ShopDetailsComponent implements OnInit { isLoading = false; shop: Shop; + contract: Contract; + payoutTool: PayoutTool; partyID: string; providerInfo: ProviderInfo[]; @@ -58,9 +60,11 @@ export class ShopDetailsComponent implements OnInit { return this.shopDetailsService.initialize(partyID, shopID); }) ) - .subscribe(({ shop, providerInfo }) => { + .subscribe(({ payoutTool, shop, contract, providerInfo }) => { this.isLoading = false; + this.payoutTool = payoutTool; this.shop = shop; + this.contract = contract; this.providerInfo = providerInfo; }); } diff --git a/src/app/party/shop-details/shop-details.module.ts b/src/app/party/shop-details/shop-details.module.ts index b705ed7c..ed4805e9 100644 --- a/src/app/party/shop-details/shop-details.module.ts +++ b/src/app/party/shop-details/shop-details.module.ts @@ -35,6 +35,8 @@ import { CreateTerminalFormComponent } from './add-provider/select-terminal/crea import { SelectTerminalComponent } from './add-provider/select-terminal/select-terminal.component'; import { SelectProviderComponent } from './add-provider/select-provider/select-provider.component'; import { IsActivePipe } from './is-active.pipe'; +import { CategoryComponent } from './shop-info/category/category.component'; +import { SharedModule } from '../../shared/shared.module'; @NgModule({ imports: [ @@ -59,7 +61,8 @@ import { IsActivePipe } from './is-active.pipe'; MatProgressBarModule, MatMenuModule, MatProgressBarModule, - MatChipsModule + MatChipsModule, + SharedModule ], declarations: [ ShopDetailsComponent, @@ -73,7 +76,8 @@ import { IsActivePipe } from './is-active.pipe'; CreateTerminalFormComponent, SelectProviderComponent, SelectTerminalComponent, - IsActivePipe + IsActivePipe, + CategoryComponent ], entryComponents: [AddProviderComponent] }) diff --git a/src/app/party/shop-details/shop-details.service.ts b/src/app/party/shop-details/shop-details.service.ts index 36975e7e..b8962e5e 100644 --- a/src/app/party/shop-details/shop-details.service.ts +++ b/src/app/party/shop-details/shop-details.service.ts @@ -1,9 +1,15 @@ import { Injectable } from '@angular/core'; import { Observable, combineLatest } from 'rxjs'; -import { map } from 'rxjs/operators'; +import { map, switchMap } from 'rxjs/operators'; import get from 'lodash-es/get'; -import { ProviderObject, Shop, TerminalObject } from '../../gen-damsel/domain'; +import { + Contract, + PayoutTool, + ProviderObject, + Shop, + TerminalObject +} from '../../gen-damsel/domain'; import { extractTerminalInfo, TerminalInfo } from './extract-terminal-info'; import { PartyService } from '../party.service'; import { DomainTypedManager } from '../../thrift'; @@ -15,6 +21,8 @@ export interface ProviderInfo { export interface Payload { shop: Shop; + contract: Contract; + payoutTool: PayoutTool; providerInfo: ProviderInfo[]; } @@ -28,10 +36,30 @@ export class ShopDetailsService { this.dtm.getProviderObjects(), this.dtm.getTerminalObjects() ]).pipe( - map(([shop, providers, terminalObjects]) => ({ - shop, - providerInfo: this.toProviderInfo(providers, terminalObjects, partyID, shopID) - })) + switchMap(([shop, providers, terminalObjects]) => + this.partyService.getContract(partyID, shop.contract_id).pipe( + map(contract => ({ + contract, + providerInfo: this.toProviderInfo( + providers, + terminalObjects, + partyID, + shopID + ), + shop + })) + ) + ), + switchMap(({ contract, providerInfo, shop }) => + this.partyService.getPayoutTool(partyID, contract.id, shop.payout_tool_id).pipe( + map(payoutTool => ({ + payoutTool, + shop, + providerInfo, + contract + })) + ) + ) ); } diff --git a/src/app/party/shop-details/shop-info/category/category.component.html b/src/app/party/shop-details/shop-info/category/category.component.html new file mode 100644 index 00000000..45584613 --- /dev/null +++ b/src/app/party/shop-details/shop-info/category/category.component.html @@ -0,0 +1 @@ +{{ category?.name }} (ID: {{ categoryID }}) diff --git a/src/app/party/shop-details/shop-info/category/category.component.ts b/src/app/party/shop-details/shop-info/category/category.component.ts new file mode 100644 index 00000000..d52200c7 --- /dev/null +++ b/src/app/party/shop-details/shop-info/category/category.component.ts @@ -0,0 +1,21 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { Category } from '../../../../gen-damsel/domain'; +import { CategoryService } from '../../../../papi/category.service'; + +@Component({ + templateUrl: 'category.component.html', + selector: 'cc-category', + providers: [CategoryService] +}) +export class CategoryComponent implements OnInit { + @Input() categoryID: number; + category: Category; + + constructor(private categoryService: CategoryService) {} + + ngOnInit(): void { + this.categoryService.getCategories().subscribe(categories => { + this.category = categories.find(category => category.id === this.categoryID); + }); + } +} diff --git a/src/app/party/shop-details/shop-info/shop-info.component.html b/src/app/party/shop-details/shop-info/shop-info.component.html index 9381dfa8..f84a6b12 100644 --- a/src/app/party/shop-details/shop-info/shop-info.component.html +++ b/src/app/party/shop-details/shop-info/shop-info.component.html @@ -36,7 +36,7 @@
-
{{ shop.category.id }}
+
diff --git a/src/app/party/shop-details/shop-info/shop-info.component.ts b/src/app/party/shop-details/shop-info/shop-info.component.ts index b9d7af12..65faa911 100644 --- a/src/app/party/shop-details/shop-info/shop-info.component.ts +++ b/src/app/party/shop-details/shop-info/shop-info.component.ts @@ -3,9 +3,10 @@ import { Component, Input } from '@angular/core'; import { Shop } from '../../../gen-damsel/domain'; @Component({ - selector: 'cc-shop-details', + selector: 'cc-shop-info', templateUrl: 'shop-info.component.html' }) export class ShopInfoComponent { @Input() shop: Shop; + @Input() partyID: string; }