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

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

@ -11,7 +11,6 @@ const locales = {
CLOSE: $localize`Close`,
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_PREMIUM: $localize`Switch to Ghostfolio Open Source or Ghostfolio Basic easily`,
DATA_SOURCE: $localize`Data Source`,
EMERGENCY_FUND: $localize`Emergency Fund`,
EXCLUDE_FROM_ANALYSIS: $localize`Exclude from Analysis`,

Loading…
Cancel
Save