From e047b1f0c2e57e8ec603284378e8efbbfb7bee7c Mon Sep 17 00:00:00 2001 From: Rinat Arsaev <11846445+A77AY@users.noreply.github.com> Date: Thu, 27 Jul 2023 12:18:23 +0400 Subject: [PATCH] MI-8,TD-678: Hide payouts, claims; hide calc amount: deposits, withdrawals (#136) --- src/app/api/wallet/downloads.service.ts | 10 +++++ src/app/api/wallet/index.ts | 1 + .../payment-section-routing.module.ts | 14 +++---- .../utils/to-navbar-item-config.ts | 13 +++--- src/app/sections/sections-routing.module.ts | 8 ++-- .../deposit-details.component.html | 41 ++++++++----------- .../deposit-details/deposit-details.module.ts | 3 +- .../webhook-list/webhook-list.module.ts | 2 + .../webhook-row/webhook-row.component.html | 2 +- .../webhook-row/webhook-row.component.ts | 16 +------- .../wallet-details.component.html | 8 +--- .../wallets-main-info.component.html | 27 ++++++++---- .../wallets-main-info.component.ts | 21 +++++++++- .../wallets-main-info.module.ts | 14 ++++++- .../withdrawal-details.component.html | 6 +-- .../deposit-revert-details.component.html | 8 ++-- src/app/shared/pipes/identity-name.pipe.ts | 25 +++++++++++ .../sections-links/section-links.service.ts | 12 +++--- src/assets/i18n/services/en.json | 1 - src/assets/i18n/services/ru.json | 1 - src/assets/i18n/wallet-section/en.json | 3 +- src/assets/i18n/wallet-section/ru.json | 3 +- src/environments/index.ts | 4 +- 23 files changed, 146 insertions(+), 97 deletions(-) create mode 100644 src/app/api/wallet/downloads.service.ts create mode 100644 src/app/shared/pipes/identity-name.pipe.ts diff --git a/src/app/api/wallet/downloads.service.ts b/src/app/api/wallet/downloads.service.ts new file mode 100644 index 00000000..a54ade83 --- /dev/null +++ b/src/app/api/wallet/downloads.service.ts @@ -0,0 +1,10 @@ +import { Injectable } from '@angular/core'; +import { DownloadsService as ApiService } from '@vality/swag-wallet'; + +import { createApi } from '../utils'; +import { PartyIdExtension } from '../utils/extensions'; + +@Injectable({ + providedIn: 'root', +}) +export class DownloadsService extends createApi(ApiService, [PartyIdExtension]) {} diff --git a/src/app/api/wallet/index.ts b/src/app/api/wallet/index.ts index 208dbeda..fafe2bac 100644 --- a/src/app/api/wallet/index.ts +++ b/src/app/api/wallet/index.ts @@ -6,3 +6,4 @@ export * from './identities.service'; export * from './deposits.service'; export * from './wallet-dictionary.service'; export * from './reports.service'; +export * from './downloads.service'; diff --git a/src/app/sections/payment-section/payment-section-routing.module.ts b/src/app/sections/payment-section/payment-section-routing.module.ts index 0f3aaaa4..1aede2c8 100644 --- a/src/app/sections/payment-section/payment-section-routing.module.ts +++ b/src/app/sections/payment-section/payment-section-routing.module.ts @@ -41,13 +41,13 @@ const PAYMENT_SECTION_ROUTES: Routes = [ }, [RoleAccessName.Reports] ), - createPrivateRoute( - { - path: 'payouts', - loadChildren: () => import('./payouts/payouts.module').then((m) => m.PayoutsModule), - }, - [RoleAccessName.ViewPayouts] - ), + // createPrivateRoute( + // { + // path: 'payouts', + // loadChildren: () => import('./payouts/payouts.module').then((m) => m.PayoutsModule), + // }, + // [RoleAccessName.ViewPayouts] + // ), { path: 'integrations', loadChildren: () => import('./integrations/integrations.module').then((m) => m.IntegrationsModule), diff --git a/src/app/sections/payment-section/utils/to-navbar-item-config.ts b/src/app/sections/payment-section/utils/to-navbar-item-config.ts index dda1ef11..40efec33 100644 --- a/src/app/sections/payment-section/utils/to-navbar-item-config.ts +++ b/src/app/sections/payment-section/utils/to-navbar-item-config.ts @@ -22,7 +22,6 @@ export const toNavbarItemConfig = ({ analytics, integrations, operations, - payouts, reports, }: Record< 'shops' | 'analytics' | 'integrations' | 'operations' | 'payouts' | 'reports', @@ -46,12 +45,12 @@ export const toNavbarItemConfig = ({ label: operations, roles: [RoleAccessName.ViewPayments, RoleAccessName.ViewInvoices, RoleAccessName.ViewRefunds], }, - { - routerLink: NavbarRouterLink.Payouts, - icon: BootstrapIconName.ArrowRightCircle, - label: payouts, - roles: [RoleAccessName.ViewPayouts], - }, + // { + // routerLink: NavbarRouterLink.Payouts, + // icon: BootstrapIconName.ArrowRightCircle, + // label: payouts, + // roles: [RoleAccessName.ViewPayouts], + // }, { routerLink: NavbarRouterLink.Reports, icon: BootstrapIconName.FileText, diff --git a/src/app/sections/sections-routing.module.ts b/src/app/sections/sections-routing.module.ts index ddcafc26..6d2b4172 100644 --- a/src/app/sections/sections-routing.module.ts +++ b/src/app/sections/sections-routing.module.ts @@ -2,10 +2,10 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; const ROUTES: Routes = [ - { - path: 'claim-section', - loadChildren: () => import('./claim-section').then((m) => m.ClaimSectionModule), - }, + // { + // path: 'claim-section', + // loadChildren: () => import('./claim-section').then((m) => m.ClaimSectionModule), + // }, { path: 'payment-section', loadChildren: () => import('./payment-section').then((m) => m.PaymentSectionModule), diff --git a/src/app/sections/wallet-section/deposits/deposit-panels/deposit-details/deposit-details.component.html b/src/app/sections/wallet-section/deposits/deposit-panels/deposit-details/deposit-details.component.html index 2ec3ae38..d2ab7d38 100644 --- a/src/app/sections/wallet-section/deposits/deposit-panels/deposit-details/deposit-details.component.html +++ b/src/app/sections/wallet-section/deposits/deposit-panels/deposit-details/deposit-details.component.html @@ -1,37 +1,28 @@ -
-
-
+ +
+
{{ deposit.body.amount | amountCurrency : deposit.body.currency }}
- - {{ deposit.body.amount | amountCurrency : deposit.body.currency }} - - + {{ deposit.fee.amount | amountCurrency : deposit.fee.currency }} -
-
- + {{ (depositStatusDict$ | async)?.[deposit.status] }} - + {{ deposit.wallet | walletDetails }} -
-
- - - {{ errors(deposit.failure.code) }} + + + {{ t('errors.' + deposit.failure.code) }}
-
+ diff --git a/src/app/sections/wallet-section/deposits/deposit-panels/deposit-details/deposit-details.module.ts b/src/app/sections/wallet-section/deposits/deposit-panels/deposit-details/deposit-details.module.ts index 24337dbd..8e36627a 100644 --- a/src/app/sections/wallet-section/deposits/deposit-panels/deposit-details/deposit-details.module.ts +++ b/src/app/sections/wallet-section/deposits/deposit-panels/deposit-details/deposit-details.module.ts @@ -1,6 +1,6 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import { FlexModule } from '@angular/flex-layout'; +import { FlexModule, GridModule } from '@angular/flex-layout'; import { TranslocoModule } from '@ngneat/transloco'; import { ApiModelRefsModule, ApiModelTypesModule, AmountCurrencyModule } from '@dsh/app/shared'; @@ -20,6 +20,7 @@ import { DepositDetailsComponent } from './deposit-details.component'; ApiModelTypesModule, AmountCurrencyModule, + GridModule, ], declarations: [DepositDetailsComponent], exports: [DepositDetailsComponent], diff --git a/src/app/sections/wallet-section/integrations/webhooks/webhook-list/webhook-list.module.ts b/src/app/sections/wallet-section/integrations/webhooks/webhook-list/webhook-list.module.ts index 96598bb0..d9a8882f 100644 --- a/src/app/sections/wallet-section/integrations/webhooks/webhook-list/webhook-list.module.ts +++ b/src/app/sections/wallet-section/integrations/webhooks/webhook-list/webhook-list.module.ts @@ -4,6 +4,7 @@ import { FlexLayoutModule } from '@angular/flex-layout'; import { MatSnackBarModule } from '@angular/material/snack-bar'; import { TranslocoModule } from '@ngneat/transloco'; +import { IdentityNamePipe } from '@dsh/app/shared/pipes/identity-name.pipe'; import { IndicatorsModule } from '@dsh/components/indicators'; import { LayoutModule } from '@dsh/components/layout'; @@ -23,6 +24,7 @@ import { WebhookDetailsModule } from '../webhook-details'; IndicatorsModule, WebhookDetailsModule, DeleteWebhookModule, + IdentityNamePipe, ], declarations: [WebhookListComponent, WebhookRowHeaderComponent, WebhookRowComponent], exports: [WebhookListComponent], diff --git a/src/app/sections/wallet-section/integrations/webhooks/webhook-list/webhook-row/webhook-row.component.html b/src/app/sections/wallet-section/integrations/webhooks/webhook-list/webhook-row/webhook-row.component.html index 0811bdce..9d57163c 100644 --- a/src/app/sections/wallet-section/integrations/webhooks/webhook-list/webhook-row/webhook-row.component.html +++ b/src/app/sections/wallet-section/integrations/webhooks/webhook-list/webhook-row/webhook-row.component.html @@ -2,5 +2,5 @@ {{ url }} - {{ identityID }} {{ getIdentityName(identityID) | async }} + {{ identityID | identityName }} diff --git a/src/app/sections/wallet-section/integrations/webhooks/webhook-list/webhook-row/webhook-row.component.ts b/src/app/sections/wallet-section/integrations/webhooks/webhook-list/webhook-row/webhook-row.component.ts index 8a3cea63..49731315 100644 --- a/src/app/sections/wallet-section/integrations/webhooks/webhook-list/webhook-row/webhook-row.component.ts +++ b/src/app/sections/wallet-section/integrations/webhooks/webhook-list/webhook-row/webhook-row.component.ts @@ -1,7 +1,4 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; -import { map } from 'rxjs/operators'; - -import { IdentitiesService } from '@dsh/app/api/wallet'; @Component({ selector: 'dsh-webhook-row', @@ -10,15 +7,6 @@ import { IdentitiesService } from '@dsh/app/api/wallet'; changeDetection: ChangeDetectionStrategy.OnPush, }) export class WebhookRowComponent { - @Input() - url: string; - - @Input() - identityID: string; - - constructor(private identitiesService: IdentitiesService) {} - - getIdentityName(identityID: string) { - return this.identitiesService.identities$.pipe(map((i) => i.find(({ id }) => id === identityID)?.name)); - } + @Input() url: string; + @Input() identityID: string; } diff --git a/src/app/sections/wallet-section/wallets/wallets-list/components/wallet-details/wallet-details.component.html b/src/app/sections/wallet-section/wallets/wallets-list/components/wallet-details/wallet-details.component.html index e893c652..b165681b 100644 --- a/src/app/sections/wallet-section/wallets/wallets-list/components/wallet-details/wallet-details.component.html +++ b/src/app/sections/wallet-section/wallets/wallets-list/components/wallet-details/wallet-details.component.html @@ -1,9 +1,5 @@
- - - - - - + +
diff --git a/src/app/sections/wallet-section/wallets/wallets-list/wallet-main-info/wallets-main-info.component.html b/src/app/sections/wallet-section/wallets/wallets-list/wallet-main-info/wallets-main-info.component.html index 58f75285..24ff603d 100644 --- a/src/app/sections/wallet-section/wallets/wallets-list/wallet-main-info/wallets-main-info.component.html +++ b/src/app/sections/wallet-section/wallets/wallets-list/wallet-main-info/wallets-main-info.component.html @@ -1,11 +1,24 @@
- {{ wallet.name }} - {{ - wallet.createdAt | date : 'dd.MM.yyyy, HH:mm' - }} +
+
+ {{ account.available.amount | amountCurrency : account.available.currency }} +
+
+ + + + +
{{ t('fetchWalletAccountError') }}
+
+ {{ wallet.name }} + {{ wallet.createdAt | date : 'dd.MM.yyyy, HH:mm' }}
diff --git a/src/app/sections/wallet-section/wallets/wallets-list/wallet-main-info/wallets-main-info.component.ts b/src/app/sections/wallet-section/wallets/wallets-list/wallet-main-info/wallets-main-info.component.ts index b9fa1924..2ac96492 100644 --- a/src/app/sections/wallet-section/wallets/wallets-list/wallet-main-info/wallets-main-info.component.ts +++ b/src/app/sections/wallet-section/wallets/wallets-list/wallet-main-info/wallets-main-info.component.ts @@ -1,11 +1,28 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core'; import { Wallet } from '@vality/swag-wallet'; +import { ComponentChanges } from '@dsh/type-utils'; + +import { FetchWalletAccountService } from '../wallet-account-info/services'; + @Component({ selector: 'dsh-wallet-main-info', templateUrl: 'wallets-main-info.component.html', changeDetection: ChangeDetectionStrategy.OnPush, + providers: [FetchWalletAccountService], }) -export class WalletsMainInfoComponent { +export class WalletsMainInfoComponent implements OnChanges { @Input() wallet: Wallet; + + walletAccount$ = this.fetchWalletAccountService.walletAccount$; + isLoading$ = this.fetchWalletAccountService.isLoading$; + error$ = this.fetchWalletAccountService.error$; + + constructor(private fetchWalletAccountService: FetchWalletAccountService) {} + + ngOnChanges({ wallet }: ComponentChanges): void { + if (wallet?.firstChange && wallet.currentValue) { + this.fetchWalletAccountService.fetchWalletAccount(this.wallet.id); + } + } } diff --git a/src/app/sections/wallet-section/wallets/wallets-list/wallet-main-info/wallets-main-info.module.ts b/src/app/sections/wallet-section/wallets/wallets-list/wallet-main-info/wallets-main-info.module.ts index d224b10a..bbac6e99 100644 --- a/src/app/sections/wallet-section/wallets/wallets-list/wallet-main-info/wallets-main-info.module.ts +++ b/src/app/sections/wallet-section/wallets/wallets-list/wallet-main-info/wallets-main-info.module.ts @@ -1,14 +1,24 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import { FlexModule } from '@angular/flex-layout'; +import { FlexModule, GridModule } from '@angular/flex-layout'; import { TranslocoModule } from '@ngneat/transloco'; +import { AmountCurrencyModule } from '@dsh/app/shared'; +import { SpinnerModule } from '@dsh/components/indicators'; import { DetailsItemModule } from '@dsh/components/layout'; import { WalletsMainInfoComponent } from './wallets-main-info.component'; @NgModule({ - imports: [CommonModule, FlexModule, DetailsItemModule, TranslocoModule], + imports: [ + CommonModule, + FlexModule, + DetailsItemModule, + TranslocoModule, + AmountCurrencyModule, + SpinnerModule, + GridModule, + ], declarations: [WalletsMainInfoComponent], exports: [WalletsMainInfoComponent], }) diff --git a/src/app/sections/wallet-section/withdrawals/withdrawals-list/components/withdrawal-details/withdrawal-details.component.html b/src/app/sections/wallet-section/withdrawals/withdrawals-list/components/withdrawal-details/withdrawal-details.component.html index 8c25a677..8b40778b 100644 --- a/src/app/sections/wallet-section/withdrawals/withdrawals-list/components/withdrawal-details/withdrawal-details.component.html +++ b/src/app/sections/wallet-section/withdrawals/withdrawals-list/components/withdrawal-details/withdrawal-details.component.html @@ -1,15 +1,13 @@
{{ withdrawal.body.amount | amountCurrency : withdrawal.body.currency }}
- - {{ withdrawal.body.amount + withdrawal.fee.amount | amountCurrency : withdrawal.body.currency }} - {{ withdrawal.fee.amount | amountCurrency : withdrawal.fee.currency }} ({{ withdrawal.fee.amount / withdrawal.body.amount | percent : '1.0-2' : 'en' diff --git a/src/app/shared/components/api-model-details/deposit-revert-details/deposit-revert-details.component.html b/src/app/shared/components/api-model-details/deposit-revert-details/deposit-revert-details.component.html index 53b6c757..fd6f5f3d 100644 --- a/src/app/shared/components/api-model-details/deposit-revert-details/deposit-revert-details.component.html +++ b/src/app/shared/components/api-model-details/deposit-revert-details/deposit-revert-details.component.html @@ -4,21 +4,21 @@ *transloco="let t; scope: 'components'; read: 'components.depositRevertDetails'" >
- + {{ revert.body.amount | amountCurrency : revert.body.currency }} - + {{ (depositRevertStatusDict$ | async)?.[revert.status] }} - + {{ revert.createdAt | date : 'dd MMMM yyyy, HH:mm' }}
diff --git a/src/app/shared/pipes/identity-name.pipe.ts b/src/app/shared/pipes/identity-name.pipe.ts new file mode 100644 index 00000000..8cae5f47 --- /dev/null +++ b/src/app/shared/pipes/identity-name.pipe.ts @@ -0,0 +1,25 @@ +import { AsyncPipe } from '@angular/common'; +import { Pipe, PipeTransform, ChangeDetectorRef } from '@angular/core'; +import { Identity } from '@vality/swag-wallet'; +import { map } from 'rxjs/operators'; + +import { IdentitiesService } from '@dsh/app/api/wallet'; + +@Pipe({ + name: 'identityName', + standalone: true, + pure: false, +}) +export class IdentityNamePipe implements PipeTransform { + async = new AsyncPipe(this.cdr); + + constructor(private cdr: ChangeDetectorRef, private identitiesService: IdentitiesService) {} + + transform(id: Identity['id']): Identity['name'] { + return this.async.transform( + this.identitiesService.identities$.pipe( + map((identities) => identities.find((identity) => identity.id === id)?.name || id) + ) + ); + } +} diff --git a/src/app/shared/services/sections-links/section-links.service.ts b/src/app/shared/services/sections-links/section-links.service.ts index dae06ac6..9da24aa2 100644 --- a/src/app/shared/services/sections-links/section-links.service.ts +++ b/src/app/shared/services/sections-links/section-links.service.ts @@ -13,10 +13,10 @@ export class SectionsLinksService { sectionLinks$: Observable = combineLatest([ this.walletsService.hasWallets$, this.roleAccessService.isAccessAllowed([RoleAccessName.Wallets]), - this.roleAccessService.isAccessAllowed([RoleAccessName.Claims]), + // this.roleAccessService.isAccessAllowed([RoleAccessName.Claims]), this.transloco.selectTranslation('services'), ]).pipe( - map(([hasWallets, allowWallets, allowClaims]) => + map(([hasWallets, allowWallets]) => [ { label: this.transloco.translate('sectionsLinks.links.payments', null, 'services'), @@ -27,10 +27,10 @@ export class SectionsLinksService { label: this.transloco.translate('sectionsLinks.links.wallets', null, 'services'), path: '/wallet-section', }, - allowClaims && { - label: this.transloco.translate('sectionsLinks.links.claims', null, 'services'), - path: '/claim-section', - }, + // allowClaims && { + // label: this.transloco.translate('sectionsLinks.links.claims', null, 'services'), + // path: '/claim-section', + // }, ].filter(Boolean) ), first() diff --git a/src/assets/i18n/services/en.json b/src/assets/i18n/services/en.json index 9c19b866..a9506264 100644 --- a/src/assets/i18n/services/en.json +++ b/src/assets/i18n/services/en.json @@ -10,7 +10,6 @@ }, "sectionsLinks": { "links": { - "claims": "Claims", "payments": "Payments", "wallets": "Wallets" } diff --git a/src/assets/i18n/services/ru.json b/src/assets/i18n/services/ru.json index 8b35549b..2e3dfd6c 100644 --- a/src/assets/i18n/services/ru.json +++ b/src/assets/i18n/services/ru.json @@ -10,7 +10,6 @@ }, "sectionsLinks": { "links": { - "claims": "Заявки", "payments": "Платежи", "wallets": "Кошельки" } diff --git a/src/assets/i18n/wallet-section/en.json b/src/assets/i18n/wallet-section/en.json index 2476b784..06ea7890 100644 --- a/src/assets/i18n/wallet-section/en.json +++ b/src/assets/i18n/wallet-section/en.json @@ -1,6 +1,5 @@ { "depositDetails": { - "amount": "Amount", "error": "Error", "errors": { "failed": "Deposit operation failed" @@ -87,6 +86,7 @@ }, "mainInfo": { "createdAt": "Created at", + "fetchWalletAccountError": "Balance loading error", "name": "Name" }, "wallet": "Wallet", @@ -158,7 +158,6 @@ }, "withdrawals": { "details": { - "amount": "Payout amount", "error": "Error", "errors": { "failed": "An error occurred when withdrawing funds" diff --git a/src/assets/i18n/wallet-section/ru.json b/src/assets/i18n/wallet-section/ru.json index 74e0a5ad..e4e031e6 100644 --- a/src/assets/i18n/wallet-section/ru.json +++ b/src/assets/i18n/wallet-section/ru.json @@ -1,6 +1,5 @@ { "depositDetails": { - "amount": "Сумма зачисления", "error": "Ошибка", "errors": { "failed": "Ошибка при пополнении" @@ -87,6 +86,7 @@ }, "mainInfo": { "createdAt": "Дата и время создания", + "fetchWalletAccountError": "Ошибка загрузки баланса", "name": "Название" }, "wallet": "Кошелек", @@ -158,7 +158,6 @@ }, "withdrawals": { "details": { - "amount": "Сумма списания", "error": "Ошибка", "errors": { "failed": "Произошла ошибка при выводе средств" diff --git a/src/environments/index.ts b/src/environments/index.ts index 52be614b..7f829b57 100644 --- a/src/environments/index.ts +++ b/src/environments/index.ts @@ -3,5 +3,7 @@ import { InjectionToken } from '@angular/core'; import { environment } from '../environments/environment'; export type Env = typeof environment; -export const ENV = new InjectionToken('Env'); + export { environment }; + +export const ENV = new InjectionToken('Env');