Feature: #84, BugFix #93, Init Free Plan, Selection type of Listing

This commit is contained in:
2024-08-27 20:01:56 +02:00
parent c1b72bbc12
commit 8721be4a90
14 changed files with 306 additions and 67 deletions

View File

@@ -28,13 +28,19 @@ export class PricingComponent {
async ngOnInit() {
const token = await this.keycloakService.getToken();
this.keycloakUser = map2User(token);
if (this.id) {
this.checkout({ priceId: atob(this.id), email: this.keycloakUser.email, name: `${this.keycloakUser.firstName} ${this.keycloakUser.lastName}` });
}
if (this.keycloakUser && !this.id) {
this.user = await this.userService.getByMail(this.keycloakUser.email);
if (this.user.subscriptionId) {
if (this.keycloakUser) {
if (this.id === 'free') {
this.user = await this.userService.getByMail(this.keycloakUser.email);
this.user.subscriptionPlan = 'free';
await this.userService.save(this.user);
this.router.navigate([`/account`]);
} else if (this.id) {
this.checkout({ priceId: atob(this.id), email: this.keycloakUser.email, name: `${this.keycloakUser.firstName} ${this.keycloakUser.lastName}` });
} else if (!this.id) {
this.user = await this.userService.getByMail(this.keycloakUser.email);
if (this.user.subscriptionId) {
this.router.navigate([`/account`]);
}
}
}
}
@@ -55,7 +61,7 @@ export class PricingComponent {
redirectUri: `${window.location.origin}/pricing/${btoa(priceId)}`,
});
} else {
this.keycloakService.register({ redirectUri: `${window.location.origin}/account` });
this.keycloakService.register({ redirectUri: `${window.location.origin}/pricing/free` });
}
}
}