diff --git a/package-lock.json b/package-lock.json index ec7ee2f9b..a870c9138 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "@angular/router": "^20.1.0", "@ngneat/input-mask": "^6.1.0", "@tailwindcss/postcss": "^4.1.11", - "@vality/domain-proto": "^2.0.1-f831d3a.0", + "@vality/domain-proto": "^2.0.1-7a97267.0", "@vality/fistful-proto": "^2.0.1-7c61ac5.0", "@vality/machinegun-proto": "^1.0.1-cc2c27c.0", "@vality/magista-proto": "^2.0.2-f3b4b14.0", @@ -5955,9 +5955,9 @@ } }, "node_modules/@vality/domain-proto": { - "version": "2.0.1-f831d3a.0", - "resolved": "https://registry.npmjs.org/@vality/domain-proto/-/domain-proto-2.0.1-f831d3a.0.tgz", - "integrity": "sha512-pmgYCVo/rr/J5ACotPBg+i1ZcoQ4gtbl/ssLWi4/GGuYbzBuJHi/dm5d6z6k05e0VvEUTp0ucJN5Lk0q0P9Q8g==", + "version": "2.0.1-7a97267.0", + "resolved": "https://registry.npmjs.org/@vality/domain-proto/-/domain-proto-2.0.1-7a97267.0.tgz", + "integrity": "sha512-77vfl9TEjn2ZTSWLNAQNsgDSWhr6oWr5gLze98HPMUGgCC2Sg886e0VWe7KXZcluZ+mgy7G6cSChvE7D925v8g==", "license": "Apache-2.0" }, "node_modules/@vality/fistful-proto": { diff --git a/package.json b/package.json index baafe5ef2..49a421ecd 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@angular/router": "^20.1.0", "@ngneat/input-mask": "^6.1.0", "@tailwindcss/postcss": "^4.1.11", - "@vality/domain-proto": "^2.0.1-f831d3a.0", + "@vality/domain-proto": "^2.0.1-7a97267.0", "@vality/fistful-proto": "^2.0.1-7c61ac5.0", "@vality/machinegun-proto": "^1.0.1-cc2c27c.0", "@vality/magista-proto": "^2.0.2-f3b4b14.0", diff --git a/src/api/services.ts b/src/api/services.ts index 7d410cfc5..98efb1250 100644 --- a/src/api/services.ts +++ b/src/api/services.ts @@ -12,7 +12,7 @@ import { metadata$ as scroogeMetadata$ } from '@vality/scrooge-proto'; import { DomainMetadataFormExtensionsService } from '~/components/thrift-api-crud'; import { DomainMetadataViewExtensionsService } from '~/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions'; -import { Services as WachterServices } from '~/services'; +import { Service } from '~/services'; import { ThriftService, createThriftServices } from '~/utils'; export interface MetadataThriftService extends ThriftService { @@ -34,7 +34,7 @@ export const services = [ // Domain { ...domainData, - name: 'DMT', + name: Service.DMT, loader: () => import('@vality/domain-proto/domain_config_v2').then((m) => m.Repository), namespace: 'domain_config_v2', service: 'Repository', @@ -42,7 +42,7 @@ export const services = [ }, { ...domainData, - name: 'DMTClient', + name: Service.DMTClient, loader: () => import('@vality/domain-proto/domain_config_v2').then((m) => m.RepositoryClient), namespace: 'domain_config_v2', @@ -51,7 +51,7 @@ export const services = [ }, { ...domainData, - name: 'DMTAuthor', + name: Service.DMTAuthor, loader: () => import('@vality/domain-proto/domain_config_v2').then((m) => m.AuthorManagement), namespace: 'domain_config_v2', @@ -60,7 +60,7 @@ export const services = [ }, { ...domainData, - name: 'Invoicing', + name: Service.Invoicing, loader: () => import('@vality/domain-proto/payment_processing').then((m) => m.Invoicing), namespace: 'payment_processing', service: 'Invoicing', @@ -68,7 +68,7 @@ export const services = [ }, { ...domainData, - name: 'PartyManagement', + name: Service.PartyManagement, loader: () => import('@vality/domain-proto/payment_processing').then((m) => m.PartyManagement), namespace: 'payment_processing', @@ -77,7 +77,7 @@ export const services = [ }, { ...domainData, - name: 'WebhookManager', + name: Service.WebhookManager, loader: () => import('@vality/domain-proto/webhooker').then((m) => m.WebhookManager), namespace: 'webhooker', service: 'WebhookManager', @@ -85,15 +85,24 @@ export const services = [ }, { ...domainData, - name: 'Accounter', + name: Service.Accounter, loader: () => import('@vality/domain-proto/accounter').then((m) => m.Accounter), namespace: 'accounter', service: 'Accounter', public: 'Accounter', }, + { + ...domainData, + name: Service.InvoiceTemplating, + loader: () => + import('@vality/domain-proto/api_extensions').then((m) => m.InvoiceTemplating), + namespace: 'api_extensions', + service: 'InvoiceTemplating', + public: 'InvoiceTemplating', + }, // Repairer { - name: 'RepairManagement', + name: Service.RepairManagement, loader: () => import('@vality/repairer-proto/repairer').then((m) => m.RepairManagement), metadata$: repairerMetadata$, namespace: 'repairer', @@ -102,7 +111,7 @@ export const services = [ }, // Scrooge { - name: 'Scrooge', + name: Service.Scrooge, loader: () => import('@vality/scrooge-proto/account_balance').then((m) => m.AccountService), metadata$: scroogeMetadata$, namespace: 'account_balance', @@ -111,7 +120,7 @@ export const services = [ }, // Magista { - name: 'MerchantStatistics', + name: Service.MerchantStatistics, loader: () => import('@vality/magista-proto/magista').then((m) => m.MerchantStatisticsService), metadata$: magistaMetadata$, @@ -121,7 +130,7 @@ export const services = [ }, // Machinegun { - name: 'Automaton', + name: Service.Automaton, loader: () => import('@vality/machinegun-proto/state_processing').then((m) => m.Automaton), metadata$: machinegunMetadata$, namespace: 'state_processing', @@ -130,7 +139,7 @@ export const services = [ }, // Fistful { - name: 'DepositManagement', + name: Service.DepositManagement, loader: () => import('@vality/fistful-proto/deposit').then((m) => m.Management), metadata$: fistfulMetadata$, namespace: 'deposit', @@ -138,7 +147,7 @@ export const services = [ public: 'DepositManagement', }, { - name: 'FistfulStatistics', + name: Service.FistfulStatistics, loader: () => import('@vality/fistful-proto/fistful_stat').then((m) => m.FistfulStatistics), metadata$: fistfulMetadata$, namespace: 'fistful_stat', @@ -146,7 +155,7 @@ export const services = [ public: 'FistfulStatistics', }, { - name: 'WithdrawalManagement', + name: Service.WithdrawalManagement, loader: () => import('@vality/fistful-proto/withdrawal').then((m) => m.Management), metadata$: fistfulMetadata$, namespace: 'withdrawal', @@ -154,7 +163,7 @@ export const services = [ public: 'WithdrawalManagement', }, { - name: 'SourceManagement', + name: Service.SourceManagement, loader: () => import('@vality/fistful-proto/source').then((m) => m.Management), metadata$: fistfulMetadata$, namespace: 'source', @@ -162,7 +171,7 @@ export const services = [ public: 'SourceManagement', }, { - name: WachterServices.WalletsWebhookManager, + name: Service.WalletsWebhookManager, loader: () => import('@vality/fistful-proto/webhooker').then((m) => m.WebhookManager), metadata$: fistfulMetadata$, namespace: 'webhooker', @@ -191,4 +200,5 @@ export const { WebhookManager: ThriftShopWebhooksManagementService, WalletsWebhookManager: ThriftWalletWebhooksManagementService, Accounter: ThriftAccountManagementService, + InvoiceTemplating: ThriftInvoiceTemplatingService, } = injectableServices; diff --git a/src/app/app-routes.ts b/src/app/app-routes.ts index 5cfc1be66..0dd160bdb 100644 --- a/src/app/app-routes.ts +++ b/src/app/app-routes.ts @@ -1,20 +1,20 @@ import { z } from 'zod'; -import { Route, Services } from '~/services'; +import { Route, Service } from '~/services'; type SectionPageRoutes = Record>; export const APP_ROUTES = { domain: { root: new Route('domain', { - services: [Services.DMT], + services: [Service.DMT], loadComponent: () => import('./domain-config').then((m) => m.DomainConfigComponent), queryParams: z.object({ type: z.string() }), }), }, parties: { root: new Route('parties', { - services: [Services.DMT], + services: [Service.DMT], loadComponent: () => import('./parties').then((m) => m.PartiesComponent), queryParams: z.object({ type: z.string() }), }), diff --git a/src/app/app.component.ts b/src/app/app.component.ts index eb80c99a6..84e0589d1 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -26,7 +26,7 @@ import { ThriftRepositoryService } from '~/api/services'; import { SidenavInfoModule, SidenavInfoService } from '~/components/sidenav-info'; import { getLimitedDomainObjectDetails } from '~/components/thrift-api-crud'; import { DomainObjectCardComponent } from '~/components/thrift-api-crud/domain'; -import { KeycloakUserService, Services } from '~/services'; +import { KeycloakUserService, Service } from '~/services'; import { LOGGING } from '~/utils'; import { APP_ROUTES } from './app-routes'; @@ -40,7 +40,7 @@ import { ROUTING_CONFIG as TERMS_ROUTING_CONFIG } from './terms/routing-config'; import { ROUTING_CONFIG as WALLETS_ROUTING_CONFIG } from './wallets/routing-config'; import { ROUTING_CONFIG as WITHDRAWALS_ROUTING_CONFIG } from './withdrawals/routing-config'; -function isHidden(services: Services[]): BaseLink['isHidden'] { +function isHidden(services: Service[]): BaseLink['isHidden'] { const keycloakUserService = inject(KeycloakUserService); return !keycloakUserService.hasServiceRole(...services); } diff --git a/src/app/deposits/deposit/routing-config.ts b/src/app/deposits/deposit/routing-config.ts index 4f3207ab4..d4b513cd0 100644 --- a/src/app/deposits/deposit/routing-config.ts +++ b/src/app/deposits/deposit/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.FistfulStatistics], + services: [Service.FistfulStatistics], }; diff --git a/src/app/deposits/routing-config.ts b/src/app/deposits/routing-config.ts index 4f3207ab4..d4b513cd0 100644 --- a/src/app/deposits/routing-config.ts +++ b/src/app/deposits/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.FistfulStatistics], + services: [Service.FistfulStatistics], }; diff --git a/src/app/machines/routing-config.ts b/src/app/machines/routing-config.ts index 6aa0a8552..ea975fef2 100644 --- a/src/app/machines/routing-config.ts +++ b/src/app/machines/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.RepairManagement], + services: [Service.RepairManagement], }; diff --git a/src/app/parties/party/routing-config.ts b/src/app/parties/party/routing-config.ts index 919ab96d5..fa8001e6f 100644 --- a/src/app/parties/party/routing-config.ts +++ b/src/app/parties/party/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.DMT], + services: [Service.DMT], }; diff --git a/src/app/parties/party/routing-rules/party-delegate-rulesets/routing-config.ts b/src/app/parties/party/routing-rules/party-delegate-rulesets/routing-config.ts index 919ab96d5..fa8001e6f 100644 --- a/src/app/parties/party/routing-rules/party-delegate-rulesets/routing-config.ts +++ b/src/app/parties/party/routing-rules/party-delegate-rulesets/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.DMT], + services: [Service.DMT], }; diff --git a/src/app/parties/party/routing-rules/party-routing-ruleset/routing-config.ts b/src/app/parties/party/routing-rules/party-routing-ruleset/routing-config.ts index 919ab96d5..fa8001e6f 100644 --- a/src/app/parties/party/routing-rules/party-routing-ruleset/routing-config.ts +++ b/src/app/parties/party/routing-rules/party-routing-ruleset/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.DMT], + services: [Service.DMT], }; diff --git a/src/app/parties/party/routing-rules/routing-ruleset/routing-config.ts b/src/app/parties/party/routing-rules/routing-ruleset/routing-config.ts index 919ab96d5..fa8001e6f 100644 --- a/src/app/parties/party/routing-rules/routing-ruleset/routing-config.ts +++ b/src/app/parties/party/routing-rules/routing-ruleset/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.DMT], + services: [Service.DMT], }; diff --git a/src/app/parties/party/shops/routing-config.ts b/src/app/parties/party/shops/routing-config.ts index 919ab96d5..fa8001e6f 100644 --- a/src/app/parties/party/shops/routing-config.ts +++ b/src/app/parties/party/shops/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.DMT], + services: [Service.DMT], }; diff --git a/src/app/parties/party/wallet-webhooks/routing-config.ts b/src/app/parties/party/wallet-webhooks/routing-config.ts index b2852f4d0..0ef5d2367 100644 --- a/src/app/parties/party/wallet-webhooks/routing-config.ts +++ b/src/app/parties/party/wallet-webhooks/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.WalletsWebhookManager], + services: [Service.WalletsWebhookManager], }; diff --git a/src/app/parties/party/webhooks/routing-config.ts b/src/app/parties/party/webhooks/routing-config.ts index 08cdf470b..40458dccf 100644 --- a/src/app/parties/party/webhooks/routing-config.ts +++ b/src/app/parties/party/webhooks/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.WebhookManager], + services: [Service.WebhookManager], }; diff --git a/src/app/payments/payment/routing-config.ts b/src/app/payments/payment/routing-config.ts index 81f470cbb..ef9973dcb 100644 --- a/src/app/payments/payment/routing-config.ts +++ b/src/app/payments/payment/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.MerchantStatistics], + services: [Service.MerchantStatistics], }; diff --git a/src/app/payments/payments.component.html b/src/app/payments/payments.component.html index 4867c7b2f..7802d9850 100644 --- a/src/app/payments/payments.component.html +++ b/src/app/payments/payments.component.html @@ -43,16 +43,28 @@ (selectedChange)="selected$.next($event)" (update)="reload($event ?? {})" > - - + + @if ((selected$ | async)?.length) { + + } @else { + + } diff --git a/src/app/payments/payments.component.ts b/src/app/payments/payments.component.ts index 6265ee3eb..d8ac337fc 100644 --- a/src/app/payments/payments.component.ts +++ b/src/app/payments/payments.component.ts @@ -8,6 +8,7 @@ import { CommonModule } from '@angular/common'; import { Component, DestroyRef, OnInit, inject } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormsModule, NonNullableFormBuilder, ReactiveFormsModule } from '@angular/forms'; +import { MatBadgeModule } from '@angular/material/badge'; import { MatButtonModule } from '@angular/material/button'; import { StatPayment } from '@vality/magista-proto/magista'; @@ -33,6 +34,7 @@ import { } from '@vality/matez'; import { ThriftFormExtension, ThriftFormModule, isTypeWithAliases } from '@vality/ng-thrift'; +import { CreateInvoiceTemplateDialogComponent } from '~/components/create-invoice-template-dialog'; import { FailMachinesDialogComponent, Type } from '~/components/fail-machines-dialog'; import { MerchantFieldModule } from '~/components/merchant-field/merchant-field.module'; import { PageLayoutModule } from '~/components/page-layout'; @@ -71,6 +73,7 @@ interface Filters { FormsModule, MagistaThriftFormComponent, PaymentsTableComponent, + MatBadgeModule, ], }) export class PaymentsComponent implements OnInit { @@ -222,4 +225,8 @@ export class PaymentsComponent implements OnInit { } }); } + + createInvoiceTemplate() { + this.dialogService.open(CreateInvoiceTemplateDialogComponent); + } } diff --git a/src/app/payments/routing-config.ts b/src/app/payments/routing-config.ts index 81f470cbb..ef9973dcb 100644 --- a/src/app/payments/routing-config.ts +++ b/src/app/payments/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.MerchantStatistics], + services: [Service.MerchantStatistics], }; diff --git a/src/app/shops/shops-routing-config.ts b/src/app/shops/shops-routing-config.ts index a87171a1e..799f63ef6 100644 --- a/src/app/shops/shops-routing-config.ts +++ b/src/app/shops/shops-routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const SHOPS_ROUTING_CONFIG: RoutingConfig = { - services: [Services.DMT], + services: [Service.DMT], }; diff --git a/src/app/sources/routing-config.ts b/src/app/sources/routing-config.ts index 4f3207ab4..d4b513cd0 100644 --- a/src/app/sources/routing-config.ts +++ b/src/app/sources/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.FistfulStatistics], + services: [Service.FistfulStatistics], }; diff --git a/src/app/terminals/routing-config.ts b/src/app/terminals/routing-config.ts index 919ab96d5..fa8001e6f 100644 --- a/src/app/terminals/routing-config.ts +++ b/src/app/terminals/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.DMT], + services: [Service.DMT], }; diff --git a/src/app/terms/routing-config.ts b/src/app/terms/routing-config.ts index b929e8b80..fa8001e6f 100644 --- a/src/app/terms/routing-config.ts +++ b/src/app/terms/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.Dominator], + services: [Service.DMT], }; diff --git a/src/app/wallets/routing-config.ts b/src/app/wallets/routing-config.ts index 4f3207ab4..d4b513cd0 100644 --- a/src/app/wallets/routing-config.ts +++ b/src/app/wallets/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.FistfulStatistics], + services: [Service.FistfulStatistics], }; diff --git a/src/app/withdrawals/routing-config.ts b/src/app/withdrawals/routing-config.ts index 4f3207ab4..d4b513cd0 100644 --- a/src/app/withdrawals/routing-config.ts +++ b/src/app/withdrawals/routing-config.ts @@ -1,5 +1,5 @@ -import { RoutingConfig, Services } from '~/services'; +import { RoutingConfig, Service } from '~/services'; export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.FistfulStatistics], + services: [Service.FistfulStatistics], }; diff --git a/src/components/create-invoice-template-dialog/create-invoice-template-dialog.component.html b/src/components/create-invoice-template-dialog/create-invoice-template-dialog.component.html new file mode 100644 index 000000000..2c325becb --- /dev/null +++ b/src/components/create-invoice-template-dialog/create-invoice-template-dialog.component.html @@ -0,0 +1,36 @@ +@let template = template$ | async; + + + @if (template) { +
+ + + + + + +
+ +
+ + Link + + + +
+ } @else { + + } + + @if (template) { + + } @else { + + } + +
diff --git a/src/components/create-invoice-template-dialog/create-invoice-template-dialog.component.ts b/src/components/create-invoice-template-dialog/create-invoice-template-dialog.component.ts new file mode 100644 index 000000000..ea4cf57ac --- /dev/null +++ b/src/components/create-invoice-template-dialog/create-invoice-template-dialog.component.ts @@ -0,0 +1,129 @@ +import { + Subject, + catchError, + combineLatest, + debounceTime, + map, + of, + shareReplay, + switchMap, + tap, +} from 'rxjs'; + +import { Clipboard } from '@angular/cdk/clipboard'; +import { CommonModule } from '@angular/common'; +import { Component, DestroyRef, inject, signal } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { FormBuilder, FormControl, ReactiveFormsModule } from '@angular/forms'; +import { MatButtonModule } from '@angular/material/button'; +import { MatDividerModule } from '@angular/material/divider'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatIconModule } from '@angular/material/icon'; +import { MatInputModule } from '@angular/material/input'; + +import { InvoiceTemplateCreateParams } from '@vality/domain-proto/api_extensions'; +import { + DialogModule, + DialogSuperclass, + InputFieldModule, + NotifyLogService, + getValueChanges, + progressTo, +} from '@vality/matez'; + +import { ThriftInvoiceTemplatingService } from '~/api/services'; +import { ConfigService } from '~/services'; + +import { DomainThriftFormComponent } from '../thrift-api-crud'; + +@Component({ + templateUrl: './create-invoice-template-dialog.component.html', + imports: [ + CommonModule, + DialogModule, + DomainThriftFormComponent, + ReactiveFormsModule, + MatButtonModule, + MatFormFieldModule, + MatInputModule, + MatIconModule, + InputFieldModule, + MatDividerModule, + ], +}) +export class CreateInvoiceTemplateDialogComponent extends DialogSuperclass { + private invoiceTemplatingService = inject(ThriftInvoiceTemplatingService); + private log = inject(NotifyLogService); + private dr = inject(DestroyRef); + private createTemplate$ = new Subject(); + private configService = inject(ConfigService); + private clipboard = inject(Clipboard); + private fb = inject(FormBuilder); + + linkForm = this.fb.group({ + name: null, + description: null, + email: null, + redirectUrl: null, + cancelUrl: null, + locale: null, + }); + template$ = this.createTemplate$.pipe( + switchMap(() => + this.invoiceTemplatingService.Create(this.control.value).pipe( + progressTo(this.progress), + tap(() => { + this.log.success('Invoice template created successfully'); + }), + catchError((err) => { + this.log.error('Failed to create invoice template', err); + return of(null); + }), + ), + ), + takeUntilDestroyed(this.dr), + shareReplay(1), + ); + control = new FormControl( + { context: { type: '', data: '' } } as InvoiceTemplateCreateParams, + { nonNullable: true }, + ); + progress = signal(0); + link$ = combineLatest([ + this.template$, + this.configService.config.value$, + getValueChanges(this.linkForm).pipe(debounceTime(1000)), + ]).pipe( + map(([template, config, linkValues]) => { + const url = new URL( + `http${(config.checkout.https ?? true) ? 's' : ''}://${config.checkout.hostname}${config.checkout.path ?? '/v1/checkout'}`, + ); + url.searchParams.set('invoiceTemplateID', template.invoice_template.id); + url.searchParams.set( + 'invoiceTemplateAccessToken', + template.invoice_template_access_token.payload, + ); + const nonEmptyLinkValues = Object.entries(linkValues).filter(([, v]) => !!v); + for (const [key, value] of nonEmptyLinkValues) { + url.searchParams.set(key, value as string); + } + return url.toString(); + }), + shareReplay({ refCount: true, bufferSize: 1 }), + ); + + create() { + this.createTemplate$.next(null); + } + + confirm() { + this.closeWithSuccess(); + } + + copyLink() { + this.link$.pipe(takeUntilDestroyed(this.dr)).subscribe((link) => { + this.clipboard.copy(link); + this.log.success('Link copied to clipboard'); + }); + } +} diff --git a/src/components/create-invoice-template-dialog/index.ts b/src/components/create-invoice-template-dialog/index.ts new file mode 100644 index 000000000..bbe98fe34 --- /dev/null +++ b/src/components/create-invoice-template-dialog/index.ts @@ -0,0 +1 @@ +export * from './create-invoice-template-dialog.component'; diff --git a/src/components/thrift-api-crud/domain/services/domain-metadata-form-extensions/domain-metadata-form-extensions.service.ts b/src/components/thrift-api-crud/domain/services/domain-metadata-form-extensions/domain-metadata-form-extensions.service.ts index 46ee806b6..b599c5178 100644 --- a/src/components/thrift-api-crud/domain/services/domain-metadata-form-extensions/domain-metadata-form-extensions.service.ts +++ b/src/components/thrift-api-crud/domain/services/domain-metadata-form-extensions/domain-metadata-form-extensions.service.ts @@ -97,6 +97,10 @@ export class DomainMetadataFormExtensionsService { generate: () => of('authorization_failed:unknown'), }), }, + { + determinant: (data) => of(isTypeWithAliases(data, 'InvoiceContext', 'domain')), + extension: () => of({ hidden: true }), + }, ]), shareReplay({ refCount: true, bufferSize: 1 }), ); diff --git a/src/services/app-auth-guard/services.ts b/src/services/app-auth-guard/services.ts index 7ea9502e0..bcf85c6c0 100644 --- a/src/services/app-auth-guard/services.ts +++ b/src/services/app-auth-guard/services.ts @@ -1,11 +1,24 @@ -export enum Services { +export enum Service { DMT = 'DMT', - FistfulStatistics = 'FistfulStatistics', - MerchantStatistics = 'MerchantStatistics', - ClaimManagement = 'ClaimManagement', + DMTClient = 'DMTClient', + DMTAuthor = 'DMTAuthor', Invoicing = 'Invoicing', - RepairManagement = 'RepairManagement', - Dominator = 'Dominator', + PartyManagement = 'PartyManagement', WebhookManager = 'WebhookManager', + Accounter = 'Accounter', + InvoiceTemplating = 'InvoiceTemplating', + + RepairManagement = 'RepairManagement', + + Scrooge = 'Scrooge', + + MerchantStatistics = 'MerchantStatistics', + + Automaton = 'Automaton', + + DepositManagement = 'DepositManagement', + FistfulStatistics = 'FistfulStatistics', + WithdrawalManagement = 'WithdrawalManagement', + SourceManagement = 'SourceManagement', WalletsWebhookManager = 'WalletsWebhookManager', } diff --git a/src/services/app-auth-guard/types/routing-config.ts b/src/services/app-auth-guard/types/routing-config.ts index ffa19c2ba..f609967d1 100644 --- a/src/services/app-auth-guard/types/routing-config.ts +++ b/src/services/app-auth-guard/types/routing-config.ts @@ -1,5 +1,5 @@ -import { Services } from '../services'; +import { Service } from '../services'; export interface RoutingConfig { - services?: Services[]; + services?: Service[]; } diff --git a/src/services/config/types/app-config.ts b/src/services/config/types/app-config.ts index 73c6e1882..11380887b 100644 --- a/src/services/config/types/app-config.ts +++ b/src/services/config/types/app-config.ts @@ -1,6 +1,6 @@ interface Endpoint { hostname: string; - path: string; + path?: string; port?: string; https?: boolean; } @@ -9,4 +9,5 @@ export interface AppConfig { api: { wachter: Endpoint; }; + checkout: Endpoint; } diff --git a/src/services/navigate/models/route.ts b/src/services/navigate/models/route.ts index 6c87089e9..58a363428 100644 --- a/src/services/navigate/models/route.ts +++ b/src/services/navigate/models/route.ts @@ -3,7 +3,7 @@ import { ZodObject, ZodRawShape } from 'zod'; import { Route as NgRoute } from '@angular/router'; -import { RoutingConfig, Services, canActivateAuthRole } from '../../app-auth-guard'; +import { RoutingConfig, Service, canActivateAuthRole } from '../../app-auth-guard'; export class Route< const TPath extends string = string, @@ -12,7 +12,7 @@ export class Route< constructor( public readonly path: TPath, public readonly config: { - services?: Services[]; + services?: Service[]; queryParams?: TQpSchema; } & NgRoute = {}, ) {}