From 214327031c2aa2a9b608c0748f2c700b4ea9a3ed Mon Sep 17 00:00:00 2001 From: Andreas Knuth Date: Mon, 20 May 2024 17:52:05 -0500 Subject: [PATCH] Bug Fixes --- bizmatch-server/src/app.module.ts | 4 ++-- bizmatch-server/src/file/file.service.ts | 4 ++-- .../src/subscriptions/subscriptions.controller.ts | 12 ------------ bizmatch-server/src/user/user.controller.ts | 15 +++++++++++++++ .../details-user/details-user.component.html | 8 ++++---- .../subscription/account/account.component.html | 6 ++++-- .../subscription/account/account.component.ts | 2 +- .../src/app/services/subscriptions.service.ts | 12 ++++++------ 8 files changed, 34 insertions(+), 29 deletions(-) delete mode 100644 bizmatch-server/src/subscriptions/subscriptions.controller.ts diff --git a/bizmatch-server/src/app.module.ts b/bizmatch-server/src/app.module.ts index e2d1dd2..07dd928 100644 --- a/bizmatch-server/src/app.module.ts +++ b/bizmatch-server/src/app.module.ts @@ -14,7 +14,7 @@ import { ListingsModule } from './listings/listings.module.js'; import { MailModule } from './mail/mail.module.js'; import { RequestDurationMiddleware } from './request-duration/request-duration.middleware.js'; import { SelectOptionsModule } from './select-options/select-options.module.js'; -import { SubscriptionsController } from './subscriptions/subscriptions.controller.js'; + import { UserModule } from './user/user.module.js'; const __filename = fileURLToPath(import.meta.url); @@ -47,7 +47,7 @@ const __dirname = path.dirname(__filename); SelectOptionsModule, ImageModule, ], - controllers: [AppController, SubscriptionsController], + controllers: [AppController], providers: [AppService, FileService], }) export class AppModule { diff --git a/bizmatch-server/src/file/file.service.ts b/bizmatch-server/src/file/file.service.ts index 3024122..92a429e 100644 --- a/bizmatch-server/src/file/file.service.ts +++ b/bizmatch-server/src/file/file.service.ts @@ -6,7 +6,7 @@ import path, { join } from 'path'; import sharp from 'sharp'; import { fileURLToPath } from 'url'; import { Logger } from 'winston'; -import { ImageProperty } from '../models/main.model.js'; +import { ImageProperty, Subscription } from '../models/main.model.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -25,7 +25,7 @@ export class FileService { const rawData = readFileSync(filePath, 'utf8'); this.subscriptions = JSON.parse(rawData); } - getSubscriptions() { + getSubscriptions(): Subscription[] { return this.subscriptions; } async storeProfilePicture(file: Express.Multer.File, userId: string) { diff --git a/bizmatch-server/src/subscriptions/subscriptions.controller.ts b/bizmatch-server/src/subscriptions/subscriptions.controller.ts deleted file mode 100644 index 122feb7..0000000 --- a/bizmatch-server/src/subscriptions/subscriptions.controller.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Controller, Get } from '@nestjs/common'; -import { FileService } from '../file/file.service.js'; - -@Controller('subscriptions') -export class SubscriptionsController { - constructor(private readonly fileService: FileService){} - @Get() - findAll(): any { - return this.fileService.getSubscriptions(); - } - -} diff --git a/bizmatch-server/src/user/user.controller.ts b/bizmatch-server/src/user/user.controller.ts index 4ed20ee..6b5bf11 100644 --- a/bizmatch-server/src/user/user.controller.ts +++ b/bizmatch-server/src/user/user.controller.ts @@ -2,12 +2,15 @@ import { Body, Controller, Get, Inject, Param, Post, Query } from '@nestjs/commo import { WINSTON_MODULE_PROVIDER } from 'nest-winston'; import { User } from 'src/models/db.model.js'; import { Logger } from 'winston'; +import { FileService } from '../file/file.service.js'; +import { Subscription } from '../models/main.model.js'; import { UserService } from './user.service.js'; @Controller('user') export class UserController { constructor( private userService: UserService, + private fileService: FileService, @Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger, ) {} @@ -47,4 +50,16 @@ export class UserController { this.logger.info(`Found ${result.length} entries`); return result; } + + @Get('subscriptions/:id') + async findSubscriptionsById(@Param('id') id: string): Promise { + const subscriptions = this.fileService.getSubscriptions(); + const user = await this.userService.getUserById(id); + subscriptions.forEach(s => { + s.userId = user.id; + s.start = user.created; + s.modified = user.created; + }); + return subscriptions; + } } diff --git a/bizmatch/src/app/pages/details/details-user/details-user.component.html b/bizmatch/src/app/pages/details/details-user/details-user.component.html index 6877e4c..bd83515 100644 --- a/bizmatch/src/app/pages/details/details-user/details-user.component.html +++ b/bizmatch/src/app/pages/details/details-user/details-user.component.html @@ -20,12 +20,12 @@
For Sale -
12
+
{{ businessListings.length + commercialPropListings.length }}
-
+
@@ -86,7 +86,7 @@
Licensed In
@for (license of user.licensedIn; track license) { -
{{ license.state }} {{ license.registerNo }}
+ }
diff --git a/bizmatch/src/app/pages/subscription/account/account.component.html b/bizmatch/src/app/pages/subscription/account/account.component.html index 32d1d2f..3f3ccf6 100644 --- a/bizmatch/src/app/pages/subscription/account/account.component.html +++ b/bizmatch/src/app/pages/subscription/account/account.component.html @@ -66,12 +66,13 @@
@@ -94,12 +95,13 @@
diff --git a/bizmatch/src/app/pages/subscription/account/account.component.ts b/bizmatch/src/app/pages/subscription/account/account.component.ts index 4f75556..e1b2f09 100644 --- a/bizmatch/src/app/pages/subscription/account/account.component.ts +++ b/bizmatch/src/app/pages/subscription/account/account.component.ts @@ -79,7 +79,7 @@ export class AccountComponent { } } - this.userSubscriptions = await lastValueFrom(this.subscriptionService.getAllSubscriptions()); + this.userSubscriptions = await lastValueFrom(this.subscriptionService.getAllSubscriptions(this.user.id)); this.profileUrl = this.user.hasProfile ? `${this.env.imageBaseUrl}/pictures/profile/${this.user.id}.avif?_ts=${new Date().getTime()}` : `/assets/images/placeholder.png`; this.companyLogoUrl = this.user.hasCompanyLogo ? `${this.env.imageBaseUrl}/pictures/logo/${this.user.id}.avif?_ts=${new Date().getTime()}` : `/assets/images/placeholder.png`; } diff --git a/bizmatch/src/app/services/subscriptions.service.ts b/bizmatch/src/app/services/subscriptions.service.ts index 25fcca9..b1f6ced 100644 --- a/bizmatch/src/app/services/subscriptions.service.ts +++ b/bizmatch/src/app/services/subscriptions.service.ts @@ -1,17 +1,17 @@ +import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { environment } from '../../environments/environment'; -import { HttpClient } from '@angular/common/http'; import { Subscription } from '../../../../bizmatch-server/src/models/main.model'; +import { environment } from '../../environments/environment'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class SubscriptionsService { private apiBaseUrl = environment.apiBaseUrl; - constructor(private http: HttpClient) { } + constructor(private http: HttpClient) {} - getAllSubscriptions():Observable{ - return this.http.get(`${this.apiBaseUrl}/bizmatch/subscriptions`); + getAllSubscriptions(id: string): Observable { + return this.http.get(`${this.apiBaseUrl}/bizmatch/user/subscriptions/${id}`); } }