Browse Source

Task/improve type safety in pricing page component (#6806)

* fix(client): resolve type errors

* feat(client): enforce immutability

* fix(client): remove unused variables

* fix(client): enforce encapsulation

* feat(client): replace constructor based DI with inject
pull/6797/merge
Kenrick Tandrian 2 weeks ago
committed by GitHub
parent
commit
1daa672f27
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 63
      apps/client/src/app/pages/pricing/pricing-page.component.ts
  2. 1
      libs/ui/src/lib/i18n.ts

63
apps/client/src/app/pages/pricing/pricing-page.component.ts

@ -13,6 +13,7 @@ import {
Component, Component,
CUSTOM_ELEMENTS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA,
DestroyRef, DestroyRef,
inject,
OnInit OnInit
} from '@angular/core'; } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
@ -48,35 +49,28 @@ import { catchError } from 'rxjs/operators';
templateUrl: './pricing-page.html' templateUrl: './pricing-page.html'
}) })
export class GfPricingPageComponent implements OnInit { export class GfPricingPageComponent implements OnInit {
public baseCurrency: string; protected baseCurrency: string;
public coupon: number; protected coupon: number | undefined;
public couponId: string; protected durationExtension: StringValue | undefined;
public durationExtension: StringValue; protected hasPermissionToCreateUser: boolean;
public hasPermissionToCreateUser: boolean; protected hasPermissionToUpdateUserSettings: boolean;
public hasPermissionToUpdateUserSettings: boolean;
protected readonly importAndExportTooltipBasic = translate(
public importAndExportTooltipBasic = translate(
'DATA_IMPORT_AND_EXPORT_TOOLTIP_BASIC' 'DATA_IMPORT_AND_EXPORT_TOOLTIP_BASIC'
); );
public importAndExportTooltipOSS = translate( protected readonly importAndExportTooltipOSS = translate(
'DATA_IMPORT_AND_EXPORT_TOOLTIP_OSS' 'DATA_IMPORT_AND_EXPORT_TOOLTIP_OSS'
); );
public importAndExportTooltipPremium = translate( protected label: string | undefined;
'DATA_IMPORT_AND_EXPORT_TOOLTIP_PREMIUM' protected price: number | undefined;
);
public isLoggedIn: boolean;
public label: string;
public price: number;
public priceId: string;
public professionalDataProviderTooltipPremium = translate( protected readonly professionalDataProviderTooltipPremium = translate(
'PROFESSIONAL_DATA_PROVIDER_TOOLTIP_PREMIUM' 'PROFESSIONAL_DATA_PROVIDER_TOOLTIP_PREMIUM'
); );
public referralBrokers = [ protected readonly referralBrokers = [
'Alpian', 'Alpian',
'DEGIRO', 'DEGIRO',
'finpension', 'finpension',
@ -87,19 +81,22 @@ export class GfPricingPageComponent implements OnInit {
'Swissquote', 'Swissquote',
'VIAC', 'VIAC',
'Zak' 'Zak'
]; ] as const;
public routerLinkFeatures = publicRoutes.features.routerLink; protected readonly routerLinkFeatures = publicRoutes.features.routerLink;
public routerLinkRegister = publicRoutes.register.routerLink; protected readonly routerLinkRegister = publicRoutes.register.routerLink;
public user: User; protected user: User;
public constructor( private couponId: string | undefined;
private changeDetectorRef: ChangeDetectorRef, private priceId: string;
private dataService: DataService,
private destroyRef: DestroyRef, private readonly changeDetectorRef = inject(ChangeDetectorRef);
private notificationService: NotificationService, private readonly dataService = inject(DataService);
private userService: UserService private readonly destroyRef = inject(DestroyRef);
) { private readonly notificationService = inject(NotificationService);
private readonly userService = inject(UserService);
public constructor() {
addIcons({ addIcons({
checkmarkCircleOutline, checkmarkCircleOutline,
checkmarkOutline, checkmarkOutline,
@ -147,7 +144,7 @@ export class GfPricingPageComponent implements OnInit {
}); });
} }
public onCheckout() { protected onCheckout() {
this.dataService this.dataService
.createStripeCheckoutSession({ .createStripeCheckoutSession({
couponId: this.couponId, couponId: this.couponId,

1
libs/ui/src/lib/i18n.ts

@ -11,7 +11,6 @@ const locales = {
CLOSE: $localize`Close`, CLOSE: $localize`Close`,
DATA_IMPORT_AND_EXPORT_TOOLTIP_BASIC: $localize`Switch to Ghostfolio Premium or Ghostfolio Open Source easily`, DATA_IMPORT_AND_EXPORT_TOOLTIP_BASIC: $localize`Switch to Ghostfolio Premium or Ghostfolio Open Source easily`,
DATA_IMPORT_AND_EXPORT_TOOLTIP_OSS: $localize`Switch to Ghostfolio Premium easily`, DATA_IMPORT_AND_EXPORT_TOOLTIP_OSS: $localize`Switch to Ghostfolio Premium easily`,
DATA_IMPORT_AND_EXPORT_TOOLTIP_PREMIUM: $localize`Switch to Ghostfolio Open Source or Ghostfolio Basic easily`,
DATA_SOURCE: $localize`Data Source`, DATA_SOURCE: $localize`Data Source`,
EMERGENCY_FUND: $localize`Emergency Fund`, EMERGENCY_FUND: $localize`Emergency Fund`,
EXCLUDE_FROM_ANALYSIS: $localize`Exclude from Analysis`, EXCLUDE_FROM_ANALYSIS: $localize`Exclude from Analysis`,

Loading…
Cancel
Save