BugFix: #90,#86 + Restrictions on seller
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
<div class="container mx-auto px-4 py-16">
|
||||
<h1 class="text-4xl font-bold text-center mb-12">Choose the Right Plan for Your Business</h1>
|
||||
|
||||
<div class="grid md:grid-cols-3 gap-8">
|
||||
<div
|
||||
[ngClass]="{
|
||||
'grid gap-8 mx-auto': true,
|
||||
'md:grid-cols-3 max-w-7xl': !user || !user.subscriptionPlan,
|
||||
'md:grid-cols-2 max-w-4xl': user && user.subscriptionPlan
|
||||
}"
|
||||
>
|
||||
@if(!user || !user.subscriptionPlan) {
|
||||
<!-- Free Plan -->
|
||||
<div class="bg-white rounded-lg shadow-lg overflow-hidden flex flex-col h-full">
|
||||
<div class="px-6 py-8 bg-gray-50 text-center border-b">
|
||||
@@ -30,6 +37,7 @@
|
||||
<button (click)="register()" class="w-full bg-blue-500 text-white rounded-full px-4 py-2 font-semibold hover:bg-blue-600 transition duration-300">Sign Up Now</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Professional Plan -->
|
||||
<div class="bg-white rounded-lg shadow-lg overflow-hidden flex flex-col h-full">
|
||||
@@ -72,7 +80,6 @@
|
||||
</ul>
|
||||
</div>
|
||||
<div class="px-6 py-4 mt-auto">
|
||||
<!-- <button routerLink="/payment" class="w-full bg-blue-500 text-white rounded-full px-4 py-2 font-semibold hover:bg-blue-600 transition duration-300">Get Started</button> -->
|
||||
<button (click)="register('price_1PpSkpDjmFBOcNBs9UDPgBos')" class="w-full bg-blue-500 text-white rounded-full px-4 py-2 font-semibold hover:bg-blue-600 transition duration-300">Get Started</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -122,7 +129,6 @@
|
||||
</ul>
|
||||
</div>
|
||||
<div class="px-6 py-4 mt-auto">
|
||||
<!-- <button routerLink="/payment" class="w-full bg-blue-500 text-white rounded-full px-4 py-2 font-semibold hover:bg-blue-600 transition duration-300">Start Listing Now</button> -->
|
||||
<button (click)="register('price_1PpSmRDjmFBOcNBsaaSp2nk9')" class="w-full bg-blue-500 text-white rounded-full px-4 py-2 font-semibold hover:bg-blue-600 transition duration-300">Start Listing Now</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { KeycloakService } from 'keycloak-angular';
|
||||
import { StripeService } from 'ngx-stripe';
|
||||
import { switchMap } from 'rxjs';
|
||||
import { User } from '../../../../../bizmatch-server/src/models/db.model';
|
||||
import { Checkout, KeycloakUser } from '../../../../../bizmatch-server/src/models/main.model';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { UserService } from '../../services/user.service';
|
||||
@@ -21,6 +22,7 @@ export class PricingComponent {
|
||||
private apiBaseUrl = environment.apiBaseUrl;
|
||||
private id: string | undefined = this.activatedRoute.snapshot.params['id'] as string | undefined;
|
||||
keycloakUser: KeycloakUser;
|
||||
user: User;
|
||||
constructor(public keycloakService: KeycloakService, private http: HttpClient, private stripeService: StripeService, private activatedRoute: ActivatedRoute, private userService: UserService, private router: Router) {}
|
||||
|
||||
async ngOnInit() {
|
||||
@@ -29,14 +31,20 @@ export class PricingComponent {
|
||||
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) {
|
||||
this.router.navigate([`/account`]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async register(priceId?: string) {
|
||||
if (this.keycloakUser) {
|
||||
if (!priceId) {
|
||||
const user = await this.userService.getByMail(this.keycloakUser.email);
|
||||
user.subscriptionPlan = 'free';
|
||||
await this.userService.save(user);
|
||||
this.user = await this.userService.getByMail(this.keycloakUser.email);
|
||||
this.user.subscriptionPlan = 'free';
|
||||
await this.userService.save(this.user);
|
||||
this.router.navigate([`/account`]);
|
||||
} else {
|
||||
this.checkout({ priceId: priceId, email: this.keycloakUser.email, name: `${this.keycloakUser.firstName} ${this.keycloakUser.lastName}` });
|
||||
|
||||
Reference in New Issue
Block a user