From 67741284024e6a8729004ff62a92c83ab51f9cb6 Mon Sep 17 00:00:00 2001 From: Aleksandra Usacheva Date: Fri, 23 Oct 2020 21:31:58 +0300 Subject: [PATCH] Merchants section (#199) --- src/app/app.component.ts | 2 +- src/app/app.module.ts | 4 +- src/app/parties/parties.component.html | 26 ---------- src/app/parties/parties.component.ts | 47 ------------------- src/app/parties/parties.module.ts | 33 ------------- src/app/parties/parties.service.ts | 17 ------- .../search-parties/fetch-parties.service.ts | 34 ++++++++++++++ .../parties-search-filters/index.ts | 2 + .../parties-search-filters-params.ts | 3 ++ .../parties-search-filters.component.html | 14 ++++++ .../parties-search-filters.component.ts | 29 ++++++++++++ .../parties-search-filters.module.ts | 14 ++++++ .../parties-search-filters.service.ts | 24 ++++++++++ .../search-parties/parties-table/index.ts | 1 + .../parties-table.component.html | 36 ++++++++++++++ .../parties-table.component.scss | 7 +++ .../parties-table/parties-table.component.ts | 33 +++++++++++++ .../parties-table/parties-table.module.ts | 16 +++++++ .../parties-table/party-actions.pipe.ts | 16 +++++++ .../parties-table/party-actions.ts | 3 ++ .../parties-table/party-menu-item-event.ts | 7 +++ .../search-parties-routing.module.ts} | 6 +-- .../search-parties.component.html | 24 ++++++++++ .../search-parties.component.scss | 8 ++++ .../search-parties.component.ts | 37 +++++++++++++++ .../search-parties/search-parties.module.ts | 29 ++++++++++++ .../search-parties/search-parties.service.ts | 21 +++++++++ .../payments-table.component.ts | 12 +---- .../deanonimus/deanonimus.module.ts | 1 + .../deanonimus/deanonimus.service.ts | 5 +- 30 files changed, 369 insertions(+), 142 deletions(-) delete mode 100644 src/app/parties/parties.component.html delete mode 100644 src/app/parties/parties.component.ts delete mode 100644 src/app/parties/parties.module.ts delete mode 100644 src/app/parties/parties.service.ts create mode 100644 src/app/sections/search-parties/fetch-parties.service.ts create mode 100644 src/app/sections/search-parties/parties-search-filters/index.ts create mode 100644 src/app/sections/search-parties/parties-search-filters/parties-search-filters-params.ts create mode 100644 src/app/sections/search-parties/parties-search-filters/parties-search-filters.component.html create mode 100644 src/app/sections/search-parties/parties-search-filters/parties-search-filters.component.ts create mode 100644 src/app/sections/search-parties/parties-search-filters/parties-search-filters.module.ts create mode 100644 src/app/sections/search-parties/parties-search-filters/parties-search-filters.service.ts create mode 100644 src/app/sections/search-parties/parties-table/index.ts create mode 100644 src/app/sections/search-parties/parties-table/parties-table.component.html create mode 100644 src/app/sections/search-parties/parties-table/parties-table.component.scss create mode 100644 src/app/sections/search-parties/parties-table/parties-table.component.ts create mode 100644 src/app/sections/search-parties/parties-table/parties-table.module.ts create mode 100644 src/app/sections/search-parties/parties-table/party-actions.pipe.ts create mode 100644 src/app/sections/search-parties/parties-table/party-actions.ts create mode 100644 src/app/sections/search-parties/parties-table/party-menu-item-event.ts rename src/app/{parties/parties-routing.module.ts => sections/search-parties/search-parties-routing.module.ts} (74%) create mode 100644 src/app/sections/search-parties/search-parties.component.html create mode 100644 src/app/sections/search-parties/search-parties.component.scss create mode 100644 src/app/sections/search-parties/search-parties.component.ts create mode 100644 src/app/sections/search-parties/search-parties.module.ts create mode 100644 src/app/sections/search-parties/search-parties.service.ts diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 5730127b..554d82c1 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -53,7 +53,7 @@ export class AppComponent implements OnInit { route: '/payment-adjustment', activateRoles: [PaymentAdjustmentRole.Create], }, - { name: 'Parties', route: '/parties', activateRoles: [PartyRole.Get] }, + { name: 'Merchants', route: '/parties', activateRoles: [PartyRole.Get] }, { name: 'Repairing', route: '/repairing', activateRoles: [DomainConfigRole.Checkout] }, { name: 'Deposits', route: '/deposits', activateRoles: [DepositRole.Write] }, { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 00bc7569..690ad32d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -25,7 +25,6 @@ import { CoreModule } from './core/core.module'; import { DepositsModule } from './deposits/deposits.module'; import { DomainModule } from './domain'; import icons from './icons.json'; -import { PartiesModule } from './parties/parties.module'; import { PartyModule as OldPartyModule } from './party/party.module'; import { PaymentAdjustmentModule } from './payment-adjustment/payment-adjustment.module'; import { PayoutsModule } from './payouts/payouts.module'; @@ -33,6 +32,7 @@ import { RepairingModule } from './repairing/repairing.module'; import { OperationsModule } from './sections/operations/operations.module'; import { PartyModule } from './sections/party/party.module'; import { SearchClaimsModule } from './sections/search-claims/search-claims.module'; +import { SearchPartiesModule } from './sections/search-parties/search-parties.module'; import { SettingsModule } from './settings'; import { ThemeManager, ThemeManagerModule, ThemeName } from './theme-manager'; @@ -59,7 +59,6 @@ moment.locale('en'); ClaimModule, PayoutsModule, PaymentAdjustmentModule, - PartiesModule, PartyModule, DomainModule, RepairingModule, @@ -68,6 +67,7 @@ moment.locale('en'); DepositsModule, ClaimMgtModule, PartyModule, + SearchPartiesModule, OldPartyModule, SearchClaimsModule, OperationsModule, diff --git a/src/app/parties/parties.component.html b/src/app/parties/parties.component.html deleted file mode 100644 index 9daad5f7..00000000 --- a/src/app/parties/parties.component.html +++ /dev/null @@ -1,26 +0,0 @@ - - - Search Parties - -
- - - - -
-
-
-
diff --git a/src/app/parties/parties.component.ts b/src/app/parties/parties.component.ts deleted file mode 100644 index a4f38119..00000000 --- a/src/app/parties/parties.component.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { FormGroup } from '@angular/forms'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { Router } from '@angular/router'; - -import { PartyService } from '../party/party.service'; -import { PartiesService } from './parties.service'; - -@Component({ - templateUrl: 'parties.component.html', - styleUrls: [], - providers: [PartiesService, PartyService], -}) -export class PartiesComponent implements OnInit { - public form: FormGroup; - isLoading = false; - - constructor( - private partiesService: PartiesService, - private partyService: PartyService, - private snackBar: MatSnackBar, - private router: Router - ) {} - - ngOnInit(): void { - this.form = this.partiesService.form; - } - - goToParty() { - this.isLoading = true; - let { partyId } = this.form.value; - partyId = partyId.trim(); - this.partyService.getParty(partyId).subscribe( - () => { - this.isLoading = false; - this.router.navigate(['party', partyId]); - }, - () => { - this.isLoading = false; - this.snackBar - .open(`An error occurred while receiving party`, 'RETRY') - .onAction() - .subscribe(() => this.goToParty()); - } - ); - } -} diff --git a/src/app/parties/parties.module.ts b/src/app/parties/parties.module.ts deleted file mode 100644 index eec6516e..00000000 --- a/src/app/parties/parties.module.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { FlexLayoutModule } from '@angular/flex-layout'; -import { ReactiveFormsModule } from '@angular/forms'; -import { MatButtonModule } from '@angular/material/button'; -import { MatCardModule } from '@angular/material/card'; -import { MatFormFieldModule } from '@angular/material/form-field'; -import { MatInputModule } from '@angular/material/input'; -import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; - -import { SharedPipesModule } from '@cc/app/shared/pipes'; -import { CardContainerModule } from '@cc/components/card-container/card-container.module'; - -import { PartiesRoutingModule } from './parties-routing.module'; -import { PartiesComponent } from './parties.component'; - -@NgModule({ - imports: [ - CommonModule, - PartiesRoutingModule, - FlexLayoutModule, - ReactiveFormsModule, - MatCardModule, - MatFormFieldModule, - MatInputModule, - MatButtonModule, - MatProgressSpinnerModule, - SharedPipesModule, - CardContainerModule, - ], - declarations: [PartiesComponent], -}) -export class PartiesModule {} diff --git a/src/app/parties/parties.service.ts b/src/app/parties/parties.service.ts deleted file mode 100644 index c34bcb1b..00000000 --- a/src/app/parties/parties.service.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Injectable } from '@angular/core'; -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; - -@Injectable() -export class PartiesService { - form: FormGroup; - - constructor(private fb: FormBuilder) { - this.form = this.prepareForm(); - } - - private prepareForm(): FormGroup { - return this.fb.group({ - partyId: ['', Validators.required], - }); - } -} diff --git a/src/app/sections/search-parties/fetch-parties.service.ts b/src/app/sections/search-parties/fetch-parties.service.ts new file mode 100644 index 00000000..1ba3fa43 --- /dev/null +++ b/src/app/sections/search-parties/fetch-parties.service.ts @@ -0,0 +1,34 @@ +import { Injectable } from '@angular/core'; +import { progress } from '@rbkmoney/partial-fetcher/dist/progress'; +import { merge, of, Subject } from 'rxjs'; +import { catchError, filter, map, switchMap } from 'rxjs/operators'; + +import { DeanonimusService } from '../../thrift-services/deanonimus'; +import { SearchHit } from '../../thrift-services/deanonimus/gen-model/deanonimus'; +import { PartiesSearchFiltersParams } from './parties-search-filters'; + +@Injectable() +export class FetchPartiesService { + private searchParties$: Subject = new Subject(); + private hasError$: Subject = new Subject(); + + parties$ = this.searchParties$.pipe( + switchMap((params) => + this.deanonimusService.searchParty(params).pipe( + catchError((_) => { + this.hasError$.next(); + return of('error'); + }) + ) + ), + filter((r) => r !== 'error'), + map((hits: SearchHit[]) => hits.map((hit) => hit.party)) + ); + inProgress$ = progress(this.searchParties$, merge(this.parties$, this.hasError$)); + + constructor(private deanonimusService: DeanonimusService) {} + + search(params: PartiesSearchFiltersParams) { + this.searchParties$.next(params); + } +} diff --git a/src/app/sections/search-parties/parties-search-filters/index.ts b/src/app/sections/search-parties/parties-search-filters/index.ts new file mode 100644 index 00000000..1c4c299e --- /dev/null +++ b/src/app/sections/search-parties/parties-search-filters/index.ts @@ -0,0 +1,2 @@ +export * from './parties-search-filters.module'; +export * from './parties-search-filters-params'; diff --git a/src/app/sections/search-parties/parties-search-filters/parties-search-filters-params.ts b/src/app/sections/search-parties/parties-search-filters/parties-search-filters-params.ts new file mode 100644 index 00000000..d837aaac --- /dev/null +++ b/src/app/sections/search-parties/parties-search-filters/parties-search-filters-params.ts @@ -0,0 +1,3 @@ +export interface PartiesSearchFiltersParams { + text: string; +} diff --git a/src/app/sections/search-parties/parties-search-filters/parties-search-filters.component.html b/src/app/sections/search-parties/parties-search-filters/parties-search-filters.component.html new file mode 100644 index 00000000..6840db1d --- /dev/null +++ b/src/app/sections/search-parties/parties-search-filters/parties-search-filters.component.html @@ -0,0 +1,14 @@ +
+ + + + Email, ID, INN, Registred name, Legal name, Trading name, Russian bank account + + +
diff --git a/src/app/sections/search-parties/parties-search-filters/parties-search-filters.component.ts b/src/app/sections/search-parties/parties-search-filters/parties-search-filters.component.ts new file mode 100644 index 00000000..cd8ecfb8 --- /dev/null +++ b/src/app/sections/search-parties/parties-search-filters/parties-search-filters.component.ts @@ -0,0 +1,29 @@ +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; + +import { PartiesSearchFiltersParams } from './parties-search-filters-params'; +import { PartiesSearchFiltersService } from './parties-search-filters.service'; + +@Component({ + selector: 'cc-parties-search-filters', + templateUrl: 'parties-search-filters.component.html', + providers: [PartiesSearchFiltersService], +}) +export class PartiesSearchFiltersComponent implements OnInit { + @Input() + initParams: PartiesSearchFiltersParams; + + @Output() + searchParamsChanged$: EventEmitter = new EventEmitter(); + + form = this.partiesSearchFiltersService.form; + + constructor(private partiesSearchFiltersService: PartiesSearchFiltersService) { + this.partiesSearchFiltersService.searchParamsChanged$.subscribe((params) => + this.searchParamsChanged$.emit(params) + ); + } + + ngOnInit() { + this.partiesSearchFiltersService.init(this.initParams); + } +} diff --git a/src/app/sections/search-parties/parties-search-filters/parties-search-filters.module.ts b/src/app/sections/search-parties/parties-search-filters/parties-search-filters.module.ts new file mode 100644 index 00000000..cb85aae4 --- /dev/null +++ b/src/app/sections/search-parties/parties-search-filters/parties-search-filters.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { FlexModule } from '@angular/flex-layout'; +import { ReactiveFormsModule } from '@angular/forms'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatInputModule } from '@angular/material/input'; + +import { PartiesSearchFiltersComponent } from './parties-search-filters.component'; + +@NgModule({ + imports: [FlexModule, ReactiveFormsModule, MatFormFieldModule, MatInputModule], + exports: [PartiesSearchFiltersComponent], + declarations: [PartiesSearchFiltersComponent], +}) +export class PartiesSearchFiltersModule {} diff --git a/src/app/sections/search-parties/parties-search-filters/parties-search-filters.service.ts b/src/app/sections/search-parties/parties-search-filters/parties-search-filters.service.ts new file mode 100644 index 00000000..2a45e77e --- /dev/null +++ b/src/app/sections/search-parties/parties-search-filters/parties-search-filters.service.ts @@ -0,0 +1,24 @@ +import { Injectable } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; +import { debounceTime, filter, shareReplay } from 'rxjs/operators'; + +import { PartiesSearchFiltersParams } from './parties-search-filters-params'; + +@Injectable() +export class PartiesSearchFiltersService { + form = this.fb.group({ + text: '', + }); + + searchParamsChanged$ = this.form.valueChanges.pipe( + debounceTime(600), + filter(() => this.form.valid), + shareReplay(1) + ); + + constructor(private fb: FormBuilder) {} + + init(params: PartiesSearchFiltersParams) { + this.form.patchValue(params); + } +} diff --git a/src/app/sections/search-parties/parties-table/index.ts b/src/app/sections/search-parties/parties-table/index.ts new file mode 100644 index 00000000..7ba71b64 --- /dev/null +++ b/src/app/sections/search-parties/parties-table/index.ts @@ -0,0 +1 @@ +export * from './parties-table.module'; diff --git a/src/app/sections/search-parties/parties-table/parties-table.component.html b/src/app/sections/search-parties/parties-table/parties-table.component.html new file mode 100644 index 00000000..e93ee0e6 --- /dev/null +++ b/src/app/sections/search-parties/parties-table/parties-table.component.html @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + +
Email + {{ party.email }} + ID + {{ party.id }} + + + + + +
diff --git a/src/app/sections/search-parties/parties-table/parties-table.component.scss b/src/app/sections/search-parties/parties-table/parties-table.component.scss new file mode 100644 index 00000000..f7335e41 --- /dev/null +++ b/src/app/sections/search-parties/parties-table/parties-table.component.scss @@ -0,0 +1,7 @@ +table { + width: 100%; +} + +.action-cell { + width: 8px; +} diff --git a/src/app/sections/search-parties/parties-table/parties-table.component.ts b/src/app/sections/search-parties/parties-table/parties-table.component.ts new file mode 100644 index 00000000..b4fd2649 --- /dev/null +++ b/src/app/sections/search-parties/parties-table/parties-table.component.ts @@ -0,0 +1,33 @@ +import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; + +import { PartyID } from '../../../thrift-services/damsel/gen-model/domain'; +import { Party } from '../../../thrift-services/deanonimus/gen-model/deanonimus'; +import { PartyActions } from './party-actions'; +import { PartyMenuItemEvent } from './party-menu-item-event'; + +@Component({ + selector: 'cc-parties-table', + templateUrl: 'parties-table.component.html', + styleUrls: ['parties-table.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class PartiesTableComponent { + @Input() + parties: Party[]; + + @Output() + menuItemSelected$: EventEmitter = new EventEmitter(); + + partyActions = Object.keys(PartyActions); + displayedColumns = ['email', 'id', 'actions']; + + menuItemSelected(action: string, partyID: PartyID) { + switch (action) { + case PartyActions.navigateToParty: + this.menuItemSelected$.emit({ action, partyID }); + break; + default: + console.log('Wrong party action type.'); + } + } +} diff --git a/src/app/sections/search-parties/parties-table/parties-table.module.ts b/src/app/sections/search-parties/parties-table/parties-table.module.ts new file mode 100644 index 00000000..48df3c8e --- /dev/null +++ b/src/app/sections/search-parties/parties-table/parties-table.module.ts @@ -0,0 +1,16 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +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 { PartiesTableComponent } from './parties-table.component'; +import { PartyActionsPipe } from './party-actions.pipe'; + +@NgModule({ + exports: [PartiesTableComponent], + declarations: [PartiesTableComponent, PartyActionsPipe], + imports: [MatTableModule, MatMenuModule, MatButtonModule, MatIconModule, CommonModule], +}) +export class PartiesTableModule {} diff --git a/src/app/sections/search-parties/parties-table/party-actions.pipe.ts b/src/app/sections/search-parties/parties-table/party-actions.pipe.ts new file mode 100644 index 00000000..1850e166 --- /dev/null +++ b/src/app/sections/search-parties/parties-table/party-actions.pipe.ts @@ -0,0 +1,16 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +import { PartyActions } from './party-actions'; + +const partyActionNames: { [N in PartyActions]: string } = { + [PartyActions.navigateToParty]: 'Merchant Details', +}; + +@Pipe({ + name: 'ccPartyActions', +}) +export class PartyActionsPipe implements PipeTransform { + transform(action: string): string { + return partyActionNames[action] || action; + } +} diff --git a/src/app/sections/search-parties/parties-table/party-actions.ts b/src/app/sections/search-parties/parties-table/party-actions.ts new file mode 100644 index 00000000..a60bf1cc --- /dev/null +++ b/src/app/sections/search-parties/parties-table/party-actions.ts @@ -0,0 +1,3 @@ +export enum PartyActions { + navigateToParty = 'navigateToParty', +} diff --git a/src/app/sections/search-parties/parties-table/party-menu-item-event.ts b/src/app/sections/search-parties/parties-table/party-menu-item-event.ts new file mode 100644 index 00000000..ecc8a80a --- /dev/null +++ b/src/app/sections/search-parties/parties-table/party-menu-item-event.ts @@ -0,0 +1,7 @@ +import { PartyID } from '../../../thrift-services/damsel/gen-model/domain'; +import { PartyActions } from './party-actions'; + +export interface PartyMenuItemEvent { + action: PartyActions; + partyID: PartyID; +} diff --git a/src/app/parties/parties-routing.module.ts b/src/app/sections/search-parties/search-parties-routing.module.ts similarity index 74% rename from src/app/parties/parties-routing.module.ts rename to src/app/sections/search-parties/search-parties-routing.module.ts index 22781e27..caa01a90 100644 --- a/src/app/parties/parties-routing.module.ts +++ b/src/app/sections/search-parties/search-parties-routing.module.ts @@ -3,14 +3,14 @@ import { RouterModule } from '@angular/router'; import { AppAuthGuardService, PartyRole } from '@cc/app/shared/services'; -import { PartiesComponent } from './parties.component'; +import { SearchPartiesComponent } from './search-parties.component'; @NgModule({ imports: [ RouterModule.forChild([ { path: 'parties', - component: PartiesComponent, + component: SearchPartiesComponent, canActivate: [AppAuthGuardService], data: { roles: [PartyRole.Get], @@ -20,4 +20,4 @@ import { PartiesComponent } from './parties.component'; ], exports: [RouterModule], }) -export class PartiesRoutingModule {} +export class SearchPartiesRoutingModule {} diff --git a/src/app/sections/search-parties/search-parties.component.html b/src/app/sections/search-parties/search-parties.component.html new file mode 100644 index 00000000..12c30182 --- /dev/null +++ b/src/app/sections/search-parties/search-parties.component.html @@ -0,0 +1,24 @@ +
+

Search merchants

+ + + + + + + + + + + + + + + +
diff --git a/src/app/sections/search-parties/search-parties.component.scss b/src/app/sections/search-parties/search-parties.component.scss new file mode 100644 index 00000000..3407c2ec --- /dev/null +++ b/src/app/sections/search-parties/search-parties.component.scss @@ -0,0 +1,8 @@ +.parties-container { + max-width: 936px; + margin: 24px auto; +} + +router-outlet { + margin-bottom: 0 !important; +} diff --git a/src/app/sections/search-parties/search-parties.component.ts b/src/app/sections/search-parties/search-parties.component.ts new file mode 100644 index 00000000..25c9bd4f --- /dev/null +++ b/src/app/sections/search-parties/search-parties.component.ts @@ -0,0 +1,37 @@ +import { Component } from '@angular/core'; +import { Router } from '@angular/router'; + +import { FetchPartiesService } from './fetch-parties.service'; +import { PartiesSearchFiltersParams } from './parties-search-filters'; +import { PartyActions } from './parties-table/party-actions'; +import { PartyMenuItemEvent } from './parties-table/party-menu-item-event'; +import { SearchPartiesService } from './search-parties.service'; + +@Component({ + templateUrl: 'search-parties.component.html', + styleUrls: ['search-parties.component.scss'], + providers: [SearchPartiesService, FetchPartiesService], +}) +export class SearchPartiesComponent { + initSearchParams$ = this.partiesService.data$; + inProgress$ = this.fetchPartiesService.inProgress$; + parties$ = this.fetchPartiesService.parties$; + + constructor( + private partiesService: SearchPartiesService, + private fetchPartiesService: FetchPartiesService, + private router: Router + ) {} + + searchParamsUpdated($event: PartiesSearchFiltersParams) { + this.partiesService.preserve($event); + this.fetchPartiesService.search($event); + } + + partyMenuItemSelected(event: PartyMenuItemEvent) { + switch (event.action) { + case PartyActions.navigateToParty: + this.router.navigate([`/party/${event.partyID}`]); + } + } +} diff --git a/src/app/sections/search-parties/search-parties.module.ts b/src/app/sections/search-parties/search-parties.module.ts new file mode 100644 index 00000000..92819c2c --- /dev/null +++ b/src/app/sections/search-parties/search-parties.module.ts @@ -0,0 +1,29 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { FlexModule } from '@angular/flex-layout'; +import { MatCardModule } from '@angular/material/card'; +import { MatProgressBarModule } from '@angular/material/progress-bar'; + +import { EmptySearchResultModule } from '@cc/components/empty-search-result'; + +import { DeanonimusModule } from '../../thrift-services/deanonimus'; +import { PartiesSearchFiltersModule } from './parties-search-filters'; +import { PartiesTableModule } from './parties-table'; +import { SearchPartiesRoutingModule } from './search-parties-routing.module'; +import { SearchPartiesComponent } from './search-parties.component'; + +@NgModule({ + imports: [ + SearchPartiesRoutingModule, + FlexModule, + MatCardModule, + PartiesSearchFiltersModule, + PartiesTableModule, + CommonModule, + DeanonimusModule, + EmptySearchResultModule, + MatProgressBarModule, + ], + declarations: [SearchPartiesComponent], +}) +export class SearchPartiesModule {} diff --git a/src/app/sections/search-parties/search-parties.service.ts b/src/app/sections/search-parties/search-parties.service.ts new file mode 100644 index 00000000..39b86549 --- /dev/null +++ b/src/app/sections/search-parties/search-parties.service.ts @@ -0,0 +1,21 @@ +import { Injectable } from '@angular/core'; +import { ActivatedRoute, Params, Router } from '@angular/router'; + +import { QueryParamsStore } from '@cc/app/shared/services'; + +import { PartiesSearchFiltersParams } from './parties-search-filters'; + +@Injectable() +export class SearchPartiesService extends QueryParamsStore { + constructor(protected route: ActivatedRoute, protected router: Router) { + super(router, route); + } + + mapToData(queryParams: Params): PartiesSearchFiltersParams { + return queryParams as PartiesSearchFiltersParams; + } + + mapToParams(data: PartiesSearchFiltersParams): Params { + return data; + } +} diff --git a/src/app/shared/components/payments-table/payments-table.component.ts b/src/app/shared/components/payments-table/payments-table.component.ts index c88acd4f..6c358c98 100644 --- a/src/app/shared/components/payments-table/payments-table.component.ts +++ b/src/app/shared/components/payments-table/payments-table.component.ts @@ -1,12 +1,4 @@ -import { - ChangeDetectionStrategy, - Component, - EventEmitter, - Input, - Output, - ViewChild, -} from '@angular/core'; -import { MatTable } from '@angular/material/table'; +import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; import { InvoiceID, @@ -28,8 +20,6 @@ export class PaymentsTableComponent { @Input() payments: StatPayment[]; - @ViewChild(MatTable) table: MatTable; - partyID: string; @Input() diff --git a/src/app/thrift-services/deanonimus/deanonimus.module.ts b/src/app/thrift-services/deanonimus/deanonimus.module.ts index 9540ee34..32b62cd6 100644 --- a/src/app/thrift-services/deanonimus/deanonimus.module.ts +++ b/src/app/thrift-services/deanonimus/deanonimus.module.ts @@ -1,4 +1,5 @@ import { NgModule } from '@angular/core'; + import { DeanonimusService } from './deanonimus.service'; @NgModule({ diff --git a/src/app/thrift-services/deanonimus/deanonimus.service.ts b/src/app/thrift-services/deanonimus/deanonimus.service.ts index a067e5e6..6e191ac4 100644 --- a/src/app/thrift-services/deanonimus/deanonimus.service.ts +++ b/src/app/thrift-services/deanonimus/deanonimus.service.ts @@ -1,5 +1,6 @@ import { Injectable, NgZone } from '@angular/core'; import { Observable } from 'rxjs'; + import { KeycloakTokenInfoService } from '../../keycloak-token-info.service'; import { ThriftService } from '../thrift-service'; import { SearchHit } from './gen-model/deanonimus'; @@ -11,6 +12,6 @@ export class DeanonimusService extends ThriftService { super(zone, keycloakTokenInfoService, '/deanonimus', Deanonimus); } - searchParty = (text: string): Observable => - this.toObservableAction('searchParty')(text); + searchParty = (params: { text: string }): Observable => + this.toObservableAction('searchParty')(params.text); }