parent
0004c5dabe
commit
5f56812125
@ -23,10 +23,10 @@ import {
|
|||||||
import {
|
import {
|
||||||
InfoItem,
|
InfoItem,
|
||||||
Statistics,
|
Statistics,
|
||||||
Subscription
|
SubscriptionOffer
|
||||||
} from '@ghostfolio/common/interfaces';
|
} from '@ghostfolio/common/interfaces';
|
||||||
import { permissions } from '@ghostfolio/common/permissions';
|
import { permissions } from '@ghostfolio/common/permissions';
|
||||||
import { SubscriptionOffer } from '@ghostfolio/common/types';
|
import { SubscriptionOfferKey } from '@ghostfolio/common/types';
|
||||||
|
|
||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
import { JwtService } from '@nestjs/jwt';
|
import { JwtService } from '@nestjs/jwt';
|
||||||
@ -101,7 +101,7 @@ export class InfoService {
|
|||||||
isUserSignupEnabled,
|
isUserSignupEnabled,
|
||||||
platforms,
|
platforms,
|
||||||
statistics,
|
statistics,
|
||||||
subscriptions
|
subscriptionOffers
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
this.benchmarkService.getBenchmarkAssetProfiles(),
|
this.benchmarkService.getBenchmarkAssetProfiles(),
|
||||||
this.getDemoAuthToken(),
|
this.getDemoAuthToken(),
|
||||||
@ -110,7 +110,7 @@ export class InfoService {
|
|||||||
orderBy: { name: 'asc' }
|
orderBy: { name: 'asc' }
|
||||||
}),
|
}),
|
||||||
this.getStatistics(),
|
this.getStatistics(),
|
||||||
this.getSubscriptions()
|
this.getSubscriptionOffers()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (isUserSignupEnabled) {
|
if (isUserSignupEnabled) {
|
||||||
@ -125,7 +125,7 @@ export class InfoService {
|
|||||||
isReadOnlyMode,
|
isReadOnlyMode,
|
||||||
platforms,
|
platforms,
|
||||||
statistics,
|
statistics,
|
||||||
subscriptions,
|
subscriptionOffers,
|
||||||
baseCurrency: DEFAULT_CURRENCY,
|
baseCurrency: DEFAULT_CURRENCY,
|
||||||
currencies: this.exchangeRateDataService.getCurrencies()
|
currencies: this.exchangeRateDataService.getCurrencies()
|
||||||
};
|
};
|
||||||
@ -314,8 +314,8 @@ export class InfoService {
|
|||||||
return statistics;
|
return statistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getSubscriptions(): Promise<{
|
private async getSubscriptionOffers(): Promise<{
|
||||||
[offer in SubscriptionOffer]: Subscription;
|
[offer in SubscriptionOfferKey]: SubscriptionOffer;
|
||||||
}> {
|
}> {
|
||||||
if (!this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
|
if (!this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service';
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service';
|
||||||
import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service';
|
import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service';
|
||||||
import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config';
|
import { PropertyService } from '@ghostfolio/api/services/property/property.service';
|
||||||
|
import {
|
||||||
|
DEFAULT_LANGUAGE_CODE,
|
||||||
|
PROPERTY_STRIPE_CONFIG
|
||||||
|
} from '@ghostfolio/common/config';
|
||||||
import { parseDate } from '@ghostfolio/common/helper';
|
import { parseDate } from '@ghostfolio/common/helper';
|
||||||
import { SubscriptionOffer, UserWithSettings } from '@ghostfolio/common/types';
|
import { SubscriptionOffer } from '@ghostfolio/common/interfaces';
|
||||||
|
import {
|
||||||
|
SubscriptionOfferKey,
|
||||||
|
UserWithSettings
|
||||||
|
} from '@ghostfolio/common/types';
|
||||||
import { SubscriptionType } from '@ghostfolio/common/types/subscription-type.type';
|
import { SubscriptionType } from '@ghostfolio/common/types/subscription-type.type';
|
||||||
|
|
||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
@ -17,7 +25,8 @@ export class SubscriptionService {
|
|||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
private readonly configurationService: ConfigurationService,
|
private readonly configurationService: ConfigurationService,
|
||||||
private readonly prismaService: PrismaService
|
private readonly prismaService: PrismaService,
|
||||||
|
private readonly propertyService: PropertyService
|
||||||
) {
|
) {
|
||||||
this.stripe = new Stripe(
|
this.stripe = new Stripe(
|
||||||
this.configurationService.get('STRIPE_SECRET_KEY'),
|
this.configurationService.get('STRIPE_SECRET_KEY'),
|
||||||
@ -36,6 +45,18 @@ export class SubscriptionService {
|
|||||||
priceId: string;
|
priceId: string;
|
||||||
user: UserWithSettings;
|
user: UserWithSettings;
|
||||||
}) {
|
}) {
|
||||||
|
const subscriptionOffers: {
|
||||||
|
[offer in SubscriptionOfferKey]: SubscriptionOffer;
|
||||||
|
} =
|
||||||
|
((await this.propertyService.getByKey(PROPERTY_STRIPE_CONFIG)) as any) ??
|
||||||
|
{};
|
||||||
|
|
||||||
|
const subscriptionOffer = Object.values(subscriptionOffers).find(
|
||||||
|
(subscriptionOffer) => {
|
||||||
|
return subscriptionOffer.priceId === priceId;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const checkoutSessionCreateParams: Stripe.Checkout.SessionCreateParams = {
|
const checkoutSessionCreateParams: Stripe.Checkout.SessionCreateParams = {
|
||||||
cancel_url: `${this.configurationService.get('ROOT_URL')}/${
|
cancel_url: `${this.configurationService.get('ROOT_URL')}/${
|
||||||
user.Settings?.settings?.language ?? DEFAULT_LANGUAGE_CODE
|
user.Settings?.settings?.language ?? DEFAULT_LANGUAGE_CODE
|
||||||
@ -47,6 +68,13 @@ export class SubscriptionService {
|
|||||||
quantity: 1
|
quantity: 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
locale:
|
||||||
|
(user.Settings?.settings
|
||||||
|
?.language as Stripe.Checkout.SessionCreateParams.Locale) ??
|
||||||
|
DEFAULT_LANGUAGE_CODE,
|
||||||
|
metadata: subscriptionOffer
|
||||||
|
? { subscriptionOffer: JSON.stringify(subscriptionOffer) }
|
||||||
|
: {},
|
||||||
mode: 'payment',
|
mode: 'payment',
|
||||||
payment_method_types: ['card'],
|
payment_method_types: ['card'],
|
||||||
success_url: `${this.configurationService.get(
|
success_url: `${this.configurationService.get(
|
||||||
@ -73,17 +101,25 @@ export class SubscriptionService {
|
|||||||
|
|
||||||
public async createSubscription({
|
public async createSubscription({
|
||||||
duration = '1 year',
|
duration = '1 year',
|
||||||
|
durationExtension,
|
||||||
price,
|
price,
|
||||||
userId
|
userId
|
||||||
}: {
|
}: {
|
||||||
duration?: StringValue;
|
duration?: StringValue;
|
||||||
|
durationExtension?: StringValue;
|
||||||
price: number;
|
price: number;
|
||||||
userId: string;
|
userId: string;
|
||||||
}) {
|
}) {
|
||||||
|
let expiresAt = addMilliseconds(new Date(), ms(duration));
|
||||||
|
|
||||||
|
if (durationExtension) {
|
||||||
|
expiresAt = addMilliseconds(expiresAt, ms(durationExtension));
|
||||||
|
}
|
||||||
|
|
||||||
await this.prismaService.subscription.create({
|
await this.prismaService.subscription.create({
|
||||||
data: {
|
data: {
|
||||||
|
expiresAt,
|
||||||
price,
|
price,
|
||||||
expiresAt: addMilliseconds(new Date(), ms(duration)),
|
|
||||||
User: {
|
User: {
|
||||||
connect: {
|
connect: {
|
||||||
id: userId
|
id: userId
|
||||||
@ -95,10 +131,21 @@ export class SubscriptionService {
|
|||||||
|
|
||||||
public async createSubscriptionViaStripe(aCheckoutSessionId: string) {
|
public async createSubscriptionViaStripe(aCheckoutSessionId: string) {
|
||||||
try {
|
try {
|
||||||
|
let durationExtension: StringValue;
|
||||||
|
|
||||||
const session =
|
const session =
|
||||||
await this.stripe.checkout.sessions.retrieve(aCheckoutSessionId);
|
await this.stripe.checkout.sessions.retrieve(aCheckoutSessionId);
|
||||||
|
|
||||||
|
const subscriptionOffer: SubscriptionOffer = JSON.parse(
|
||||||
|
session.metadata.subscriptionOffer ?? '{}'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (subscriptionOffer) {
|
||||||
|
durationExtension = subscriptionOffer.durationExtension;
|
||||||
|
}
|
||||||
|
|
||||||
await this.createSubscription({
|
await this.createSubscription({
|
||||||
|
durationExtension,
|
||||||
price: session.amount_total / 100,
|
price: session.amount_total / 100,
|
||||||
userId: session.client_reference_id
|
userId: session.client_reference_id
|
||||||
});
|
});
|
||||||
@ -121,7 +168,7 @@ export class SubscriptionService {
|
|||||||
return new Date(a.expiresAt) > new Date(b.expiresAt) ? a : b;
|
return new Date(a.expiresAt) > new Date(b.expiresAt) ? a : b;
|
||||||
});
|
});
|
||||||
|
|
||||||
let offer: SubscriptionOffer = price ? 'renewal' : 'default';
|
let offer: SubscriptionOfferKey = price ? 'renewal' : 'default';
|
||||||
|
|
||||||
if (isBefore(createdAt, parseDate('2023-01-01'))) {
|
if (isBefore(createdAt, parseDate('2023-01-01'))) {
|
||||||
offer = 'renewal-early-bird-2023';
|
offer = 'renewal-early-bird-2023';
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
[deviceType]="deviceType"
|
[deviceType]="deviceType"
|
||||||
[hasPermissionToChangeDateRange]="hasPermissionToChangeDateRange"
|
[hasPermissionToChangeDateRange]="hasPermissionToChangeDateRange"
|
||||||
[hasPermissionToChangeFilters]="hasPermissionToChangeFilters"
|
[hasPermissionToChangeFilters]="hasPermissionToChangeFilters"
|
||||||
|
[hasPromotion]="hasPromotion"
|
||||||
[hasTabs]="hasTabs"
|
[hasTabs]="hasTabs"
|
||||||
[info]="info"
|
[info]="info"
|
||||||
[pageTitle]="pageTitle"
|
[pageTitle]="pageTitle"
|
||||||
|
@ -57,6 +57,7 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
public hasPermissionToAccessFearAndGreedIndex: boolean;
|
public hasPermissionToAccessFearAndGreedIndex: boolean;
|
||||||
public hasPermissionToChangeDateRange: boolean;
|
public hasPermissionToChangeDateRange: boolean;
|
||||||
public hasPermissionToChangeFilters: boolean;
|
public hasPermissionToChangeFilters: boolean;
|
||||||
|
public hasPromotion = false;
|
||||||
public hasTabs = false;
|
public hasTabs = false;
|
||||||
public info: InfoItem;
|
public info: InfoItem;
|
||||||
public pageTitle: string;
|
public pageTitle: string;
|
||||||
@ -136,6 +137,10 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
permissions.enableFearAndGreedIndex
|
permissions.enableFearAndGreedIndex
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.hasPromotion =
|
||||||
|
!!this.info?.subscriptionOffers?.default?.coupon ||
|
||||||
|
!!this.info?.subscriptionOffers?.default?.durationExtension;
|
||||||
|
|
||||||
this.impersonationStorageService
|
this.impersonationStorageService
|
||||||
.onChangeHasImpersonation()
|
.onChangeHasImpersonation()
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
@ -231,6 +236,14 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
this.hasInfoMessage =
|
this.hasInfoMessage =
|
||||||
this.canCreateAccount || !!this.user?.systemMessage;
|
this.canCreateAccount || !!this.user?.systemMessage;
|
||||||
|
|
||||||
|
this.hasPromotion =
|
||||||
|
!!this.info?.subscriptionOffers?.[
|
||||||
|
this.user?.subscription?.offer ?? 'default'
|
||||||
|
]?.coupon ||
|
||||||
|
!!this.info?.subscriptionOffers?.[
|
||||||
|
this.user?.subscription?.offer ?? 'default'
|
||||||
|
]?.durationExtension;
|
||||||
|
|
||||||
this.initializeTheme(this.user?.settings.colorScheme);
|
this.initializeTheme(this.user?.settings.colorScheme);
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
this.changeDetectorRef.markForCheck();
|
||||||
|
@ -88,15 +88,20 @@
|
|||||||
<li class="list-inline-item">
|
<li class="list-inline-item">
|
||||||
<a
|
<a
|
||||||
class="d-none d-sm-block"
|
class="d-none d-sm-block"
|
||||||
i18n
|
|
||||||
mat-flat-button
|
mat-flat-button
|
||||||
[ngClass]="{
|
[ngClass]="{
|
||||||
'font-weight-bold': currentRoute === routePricing,
|
'font-weight-bold': currentRoute === routePricing,
|
||||||
'text-decoration-underline': currentRoute === routePricing
|
'text-decoration-underline': currentRoute === routePricing
|
||||||
}"
|
}"
|
||||||
[routerLink]="routerLinkPricing"
|
[routerLink]="routerLinkPricing"
|
||||||
>Pricing</a
|
|
||||||
>
|
>
|
||||||
|
<span class="align-items-center d-flex">
|
||||||
|
<span i18n>Pricing</span>
|
||||||
|
@if (currentRoute !== routePricing && hasPromotion) {
|
||||||
|
<span class="badge badge-warning ml-1">%</span>
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
<li class="list-inline-item">
|
<li class="list-inline-item">
|
||||||
@ -290,12 +295,17 @@
|
|||||||
) {
|
) {
|
||||||
<a
|
<a
|
||||||
class="d-flex d-sm-none"
|
class="d-flex d-sm-none"
|
||||||
i18n
|
|
||||||
mat-menu-item
|
mat-menu-item
|
||||||
[ngClass]="{ 'font-weight-bold': currentRoute === routePricing }"
|
[ngClass]="{ 'font-weight-bold': currentRoute === routePricing }"
|
||||||
[routerLink]="routerLinkPricing"
|
[routerLink]="routerLinkPricing"
|
||||||
>Pricing</a
|
|
||||||
>
|
>
|
||||||
|
<span class="align-items-center d-flex">
|
||||||
|
<span i18n>Pricing</span>
|
||||||
|
@if (currentRoute !== routePricing && hasPromotion) {
|
||||||
|
<span class="badge badge-warning ml-1">%</span>
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
}
|
}
|
||||||
<a
|
<a
|
||||||
class="d-flex d-sm-none"
|
class="d-flex d-sm-none"
|
||||||
@ -358,15 +368,20 @@
|
|||||||
<li class="list-inline-item">
|
<li class="list-inline-item">
|
||||||
<a
|
<a
|
||||||
class="d-sm-block"
|
class="d-sm-block"
|
||||||
i18n
|
|
||||||
mat-flat-button
|
mat-flat-button
|
||||||
[ngClass]="{
|
[ngClass]="{
|
||||||
'font-weight-bold': currentRoute === routePricing,
|
'font-weight-bold': currentRoute === routePricing,
|
||||||
'text-decoration-underline': currentRoute === routePricing
|
'text-decoration-underline': currentRoute === routePricing
|
||||||
}"
|
}"
|
||||||
[routerLink]="routerLinkPricing"
|
[routerLink]="routerLinkPricing"
|
||||||
>Pricing</a
|
|
||||||
>
|
>
|
||||||
|
<span class="align-items-center d-flex">
|
||||||
|
<span i18n>Pricing</span>
|
||||||
|
@if (currentRoute !== routePricing && hasPromotion) {
|
||||||
|
<span class="badge badge-warning ml-1">%</span>
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
@if (hasPermissionToAccessFearAndGreedIndex) {
|
@if (hasPermissionToAccessFearAndGreedIndex) {
|
||||||
|
@ -58,6 +58,7 @@ export class HeaderComponent implements OnChanges {
|
|||||||
@Input() deviceType: string;
|
@Input() deviceType: string;
|
||||||
@Input() hasPermissionToChangeDateRange: boolean;
|
@Input() hasPermissionToChangeDateRange: boolean;
|
||||||
@Input() hasPermissionToChangeFilters: boolean;
|
@Input() hasPermissionToChangeFilters: boolean;
|
||||||
|
@Input() hasPromotion: boolean;
|
||||||
@Input() hasTabs: boolean;
|
@Input() hasTabs: boolean;
|
||||||
@Input() info: InfoItem;
|
@Input() info: InfoItem;
|
||||||
@Input() pageTitle: string;
|
@Input() pageTitle: string;
|
||||||
|
@ -16,6 +16,7 @@ import {
|
|||||||
MatSnackBarRef,
|
MatSnackBarRef,
|
||||||
TextOnlySnackBar
|
TextOnlySnackBar
|
||||||
} from '@angular/material/snack-bar';
|
} from '@angular/material/snack-bar';
|
||||||
|
import { StringValue } from 'ms';
|
||||||
import { StripeService } from 'ngx-stripe';
|
import { StripeService } from 'ngx-stripe';
|
||||||
import { EMPTY, Subject } from 'rxjs';
|
import { EMPTY, Subject } from 'rxjs';
|
||||||
import { catchError, switchMap, takeUntil } from 'rxjs/operators';
|
import { catchError, switchMap, takeUntil } from 'rxjs/operators';
|
||||||
@ -31,6 +32,7 @@ export class UserAccountMembershipComponent implements OnDestroy {
|
|||||||
public coupon: number;
|
public coupon: number;
|
||||||
public couponId: string;
|
public couponId: string;
|
||||||
public defaultDateFormat: string;
|
public defaultDateFormat: string;
|
||||||
|
public durationExtension: StringValue;
|
||||||
public hasPermissionForSubscription: boolean;
|
public hasPermissionForSubscription: boolean;
|
||||||
public hasPermissionToUpdateUserSettings: boolean;
|
public hasPermissionToUpdateUserSettings: boolean;
|
||||||
public price: number;
|
public price: number;
|
||||||
@ -51,7 +53,7 @@ export class UserAccountMembershipComponent implements OnDestroy {
|
|||||||
private stripeService: StripeService,
|
private stripeService: StripeService,
|
||||||
private userService: UserService
|
private userService: UserService
|
||||||
) {
|
) {
|
||||||
const { baseCurrency, globalPermissions, subscriptions } =
|
const { baseCurrency, globalPermissions, subscriptionOffers } =
|
||||||
this.dataService.fetchInfo();
|
this.dataService.fetchInfo();
|
||||||
|
|
||||||
this.baseCurrency = baseCurrency;
|
this.baseCurrency = baseCurrency;
|
||||||
@ -76,11 +78,18 @@ export class UserAccountMembershipComponent implements OnDestroy {
|
|||||||
permissions.updateUserSettings
|
permissions.updateUserSettings
|
||||||
);
|
);
|
||||||
|
|
||||||
this.coupon = subscriptions?.[this.user.subscription.offer]?.coupon;
|
this.coupon =
|
||||||
|
subscriptionOffers?.[this.user.subscription.offer]?.coupon;
|
||||||
this.couponId =
|
this.couponId =
|
||||||
subscriptions?.[this.user.subscription.offer]?.couponId;
|
subscriptionOffers?.[this.user.subscription.offer]?.couponId;
|
||||||
this.price = subscriptions?.[this.user.subscription.offer]?.price;
|
this.durationExtension =
|
||||||
this.priceId = subscriptions?.[this.user.subscription.offer]?.priceId;
|
subscriptionOffers?.[
|
||||||
|
this.user.subscription.offer
|
||||||
|
]?.durationExtension;
|
||||||
|
this.price =
|
||||||
|
subscriptionOffers?.[this.user.subscription.offer]?.price;
|
||||||
|
this.priceId =
|
||||||
|
subscriptionOffers?.[this.user.subscription.offer]?.priceId;
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
this.changeDetectorRef.markForCheck();
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,16 @@
|
|||||||
<span i18n>per year</span>
|
<span i18n>per year</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@if (durationExtension) {
|
||||||
|
<div class="mt-1 text-center">
|
||||||
|
<div
|
||||||
|
class="badge badge-pill badge-warning font-weight-normal px-2 py-1"
|
||||||
|
>
|
||||||
|
<strong>Limited Offer!</strong> Get
|
||||||
|
{{ durationExtension }} extra
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
<div class="align-items-center d-flex justify-content-center mt-4">
|
<div class="align-items-center d-flex justify-content-center mt-4">
|
||||||
@if (!user?.subscription?.expiresAt) {
|
@if (!user?.subscription?.expiresAt) {
|
||||||
|
@ -6,6 +6,7 @@ import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
|||||||
import { translate } from '@ghostfolio/ui/i18n';
|
import { translate } from '@ghostfolio/ui/i18n';
|
||||||
|
|
||||||
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
|
import { StringValue } from 'ms';
|
||||||
import { StripeService } from 'ngx-stripe';
|
import { StripeService } from 'ngx-stripe';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { catchError, switchMap, takeUntil } from 'rxjs/operators';
|
import { catchError, switchMap, takeUntil } from 'rxjs/operators';
|
||||||
@ -20,6 +21,7 @@ export class PricingPageComponent implements OnDestroy, OnInit {
|
|||||||
public baseCurrency: string;
|
public baseCurrency: string;
|
||||||
public coupon: number;
|
public coupon: number;
|
||||||
public couponId: string;
|
public couponId: string;
|
||||||
|
public durationExtension: StringValue;
|
||||||
public hasPermissionToUpdateUserSettings: boolean;
|
public hasPermissionToUpdateUserSettings: boolean;
|
||||||
public importAndExportTooltipBasic = translate(
|
public importAndExportTooltipBasic = translate(
|
||||||
'DATA_IMPORT_AND_EXPORT_TOOLTIP_BASIC'
|
'DATA_IMPORT_AND_EXPORT_TOOLTIP_BASIC'
|
||||||
@ -51,11 +53,12 @@ export class PricingPageComponent implements OnDestroy, OnInit {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
const { baseCurrency, subscriptions } = this.dataService.fetchInfo();
|
const { baseCurrency, subscriptionOffers } = this.dataService.fetchInfo();
|
||||||
this.baseCurrency = baseCurrency;
|
this.baseCurrency = baseCurrency;
|
||||||
|
|
||||||
this.coupon = subscriptions?.default?.coupon;
|
this.coupon = subscriptionOffers?.default?.coupon;
|
||||||
this.price = subscriptions?.default?.price;
|
this.durationExtension = subscriptionOffers?.default?.durationExtension;
|
||||||
|
this.price = subscriptionOffers?.default?.price;
|
||||||
|
|
||||||
this.userService.stateChanged
|
this.userService.stateChanged
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
@ -68,11 +71,18 @@ export class PricingPageComponent implements OnDestroy, OnInit {
|
|||||||
permissions.updateUserSettings
|
permissions.updateUserSettings
|
||||||
);
|
);
|
||||||
|
|
||||||
this.coupon = subscriptions?.[this.user?.subscription?.offer]?.coupon;
|
this.coupon =
|
||||||
|
subscriptionOffers?.[this.user?.subscription?.offer]?.coupon;
|
||||||
this.couponId =
|
this.couponId =
|
||||||
subscriptions?.[this.user.subscription.offer]?.couponId;
|
subscriptionOffers?.[this.user.subscription.offer]?.couponId;
|
||||||
this.price = subscriptions?.[this.user?.subscription?.offer]?.price;
|
this.durationExtension =
|
||||||
this.priceId = subscriptions?.[this.user.subscription.offer]?.priceId;
|
subscriptionOffers?.[
|
||||||
|
this.user?.subscription?.offer
|
||||||
|
]?.durationExtension;
|
||||||
|
this.price =
|
||||||
|
subscriptionOffers?.[this.user?.subscription?.offer]?.price;
|
||||||
|
this.priceId =
|
||||||
|
subscriptionOffers?.[this.user.subscription.offer]?.priceId;
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
this.changeDetectorRef.markForCheck();
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,11 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@if (durationExtension) {
|
||||||
|
<div class="d-none d-lg-block hidden mt-3">
|
||||||
|
<div class="badge p-3 w-100"> </div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</div>
|
</div>
|
||||||
@ -159,6 +164,11 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@if (durationExtension) {
|
||||||
|
<div class="d-none d-lg-block hidden mt-3">
|
||||||
|
<div class="badge p-3 w-100"> </div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</div>
|
</div>
|
||||||
@ -289,6 +299,14 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@if (durationExtension) {
|
||||||
|
<div class="mt-3">
|
||||||
|
<div class="badge badge-warning font-weight-normal p-3 w-100">
|
||||||
|
<strong>Limited Offer!</strong> Get
|
||||||
|
{{ durationExtension }} extra
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</div>
|
</div>
|
||||||
|
@ -35,9 +35,9 @@ export class GfProductPageComponent implements OnInit {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
const { subscriptions } = this.dataService.fetchInfo();
|
const { subscriptionOffers } = this.dataService.fetchInfo();
|
||||||
|
|
||||||
this.price = subscriptions?.default?.price;
|
this.price = subscriptionOffers?.default?.price;
|
||||||
|
|
||||||
this.product1 = {
|
this.product1 = {
|
||||||
founded: 2021,
|
founded: 2021,
|
||||||
|
@ -46,7 +46,7 @@ import type { PortfolioPerformanceResponse } from './responses/portfolio-perform
|
|||||||
import type { PublicPortfolioResponse } from './responses/public-portfolio-response.interface';
|
import type { PublicPortfolioResponse } from './responses/public-portfolio-response.interface';
|
||||||
import type { ScraperConfiguration } from './scraper-configuration.interface';
|
import type { ScraperConfiguration } from './scraper-configuration.interface';
|
||||||
import type { Statistics } from './statistics.interface';
|
import type { Statistics } from './statistics.interface';
|
||||||
import type { Subscription } from './subscription.interface';
|
import type { SubscriptionOffer } from './subscription-offer.interface';
|
||||||
import type { SymbolMetrics } from './symbol-metrics.interface';
|
import type { SymbolMetrics } from './symbol-metrics.interface';
|
||||||
import type { SystemMessage } from './system-message.interface';
|
import type { SystemMessage } from './system-message.interface';
|
||||||
import type { TabConfiguration } from './tab-configuration.interface';
|
import type { TabConfiguration } from './tab-configuration.interface';
|
||||||
@ -102,8 +102,8 @@ export {
|
|||||||
ResponseError,
|
ResponseError,
|
||||||
ScraperConfiguration,
|
ScraperConfiguration,
|
||||||
Statistics,
|
Statistics,
|
||||||
|
SubscriptionOffer,
|
||||||
SystemMessage,
|
SystemMessage,
|
||||||
Subscription,
|
|
||||||
SymbolMetrics,
|
SymbolMetrics,
|
||||||
TabConfiguration,
|
TabConfiguration,
|
||||||
ToggleOption,
|
ToggleOption,
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { SubscriptionOffer } from '@ghostfolio/common/types';
|
import { SubscriptionOfferKey } from '@ghostfolio/common/types';
|
||||||
|
|
||||||
import { Platform, SymbolProfile } from '@prisma/client';
|
import { Platform, SymbolProfile } from '@prisma/client';
|
||||||
|
|
||||||
import { Statistics } from './statistics.interface';
|
import { Statistics } from './statistics.interface';
|
||||||
import { Subscription } from './subscription.interface';
|
import { SubscriptionOffer } from './subscription-offer.interface';
|
||||||
|
|
||||||
export interface InfoItem {
|
export interface InfoItem {
|
||||||
baseCurrency: string;
|
baseCurrency: string;
|
||||||
@ -18,5 +18,5 @@ export interface InfoItem {
|
|||||||
platforms: Platform[];
|
platforms: Platform[];
|
||||||
statistics: Statistics;
|
statistics: Statistics;
|
||||||
stripePublicKey?: string;
|
stripePublicKey?: string;
|
||||||
subscriptions: { [offer in SubscriptionOffer]: Subscription };
|
subscriptionOffers: { [offer in SubscriptionOfferKey]: SubscriptionOffer };
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
import { StringValue } from 'ms';
|
||||||
|
|
||||||
|
export interface SubscriptionOffer {
|
||||||
|
coupon?: number;
|
||||||
|
couponId?: string;
|
||||||
|
durationExtension?: StringValue;
|
||||||
|
price: number;
|
||||||
|
priceId: string;
|
||||||
|
}
|
@ -1,6 +0,0 @@
|
|||||||
export interface Subscription {
|
|
||||||
coupon?: number;
|
|
||||||
couponId?: string;
|
|
||||||
price: number;
|
|
||||||
priceId: string;
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
import { SubscriptionOffer } from '@ghostfolio/common/types';
|
import { SubscriptionOfferKey } from '@ghostfolio/common/types';
|
||||||
import { SubscriptionType } from '@ghostfolio/common/types/subscription-type.type';
|
import { SubscriptionType } from '@ghostfolio/common/types/subscription-type.type';
|
||||||
|
|
||||||
import { Account, Tag } from '@prisma/client';
|
import { Account, Tag } from '@prisma/client';
|
||||||
@ -20,7 +20,7 @@ export interface User {
|
|||||||
systemMessage?: SystemMessage;
|
systemMessage?: SystemMessage;
|
||||||
subscription: {
|
subscription: {
|
||||||
expiresAt?: Date;
|
expiresAt?: Date;
|
||||||
offer: SubscriptionOffer;
|
offer: SubscriptionOfferKey;
|
||||||
type: SubscriptionType;
|
type: SubscriptionType;
|
||||||
};
|
};
|
||||||
tags: (Tag & { isUsed: boolean })[];
|
tags: (Tag & { isUsed: boolean })[];
|
||||||
|
@ -15,7 +15,7 @@ import type { MarketState } from './market-state.type';
|
|||||||
import type { Market } from './market.type';
|
import type { Market } from './market.type';
|
||||||
import type { OrderWithAccount } from './order-with-account.type';
|
import type { OrderWithAccount } from './order-with-account.type';
|
||||||
import type { RequestWithUser } from './request-with-user.type';
|
import type { RequestWithUser } from './request-with-user.type';
|
||||||
import type { SubscriptionOffer } from './subscription-offer.type';
|
import type { SubscriptionOfferKey } from './subscription-offer-key.type';
|
||||||
import type { UserWithSettings } from './user-with-settings.type';
|
import type { UserWithSettings } from './user-with-settings.type';
|
||||||
import type { ViewMode } from './view-mode.type';
|
import type { ViewMode } from './view-mode.type';
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ export type {
|
|||||||
MarketState,
|
MarketState,
|
||||||
OrderWithAccount,
|
OrderWithAccount,
|
||||||
RequestWithUser,
|
RequestWithUser,
|
||||||
SubscriptionOffer,
|
SubscriptionOfferKey,
|
||||||
UserWithSettings,
|
UserWithSettings,
|
||||||
ViewMode
|
ViewMode
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export type SubscriptionOffer =
|
export type SubscriptionOfferKey =
|
||||||
| 'default'
|
| 'default'
|
||||||
| 'renewal'
|
| 'renewal'
|
||||||
| 'renewal-early-bird-2023'
|
| 'renewal-early-bird-2023'
|
@ -1,5 +1,5 @@
|
|||||||
import { UserSettings } from '@ghostfolio/common/interfaces';
|
import { UserSettings } from '@ghostfolio/common/interfaces';
|
||||||
import { SubscriptionOffer } from '@ghostfolio/common/types';
|
import { SubscriptionOfferKey } from '@ghostfolio/common/types';
|
||||||
import { SubscriptionType } from '@ghostfolio/common/types/subscription-type.type';
|
import { SubscriptionType } from '@ghostfolio/common/types/subscription-type.type';
|
||||||
|
|
||||||
import { Access, Account, Settings, User } from '@prisma/client';
|
import { Access, Account, Settings, User } from '@prisma/client';
|
||||||
@ -13,7 +13,7 @@ export type UserWithSettings = User & {
|
|||||||
Settings: Settings & { settings: UserSettings };
|
Settings: Settings & { settings: UserSettings };
|
||||||
subscription?: {
|
subscription?: {
|
||||||
expiresAt?: Date;
|
expiresAt?: Date;
|
||||||
offer: SubscriptionOffer;
|
offer: SubscriptionOfferKey;
|
||||||
type: SubscriptionType;
|
type: SubscriptionType;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user