diff --git a/bizmatch-server/src/listings/unknown-listings.controller.ts b/bizmatch-server/src/listings/unknown-listings.controller.ts index c152808..6f4fd89 100644 --- a/bizmatch-server/src/listings/unknown-listings.controller.ts +++ b/bizmatch-server/src/listings/unknown-listings.controller.ts @@ -1,18 +1,26 @@ -import { Controller, Inject } from '@nestjs/common'; +import { Controller, Get, Inject, Param, Request, UseGuards } from '@nestjs/common'; import { WINSTON_MODULE_PROVIDER } from 'nest-winston'; import { Logger } from 'winston'; +import { OptionalJwtAuthGuard } from '../jwt-auth/optional-jwt-auth.guard.js'; +import { BusinessListingService } from './business-listing.service.js'; +import { CommercialPropertyService } from './commercial-property.service.js'; @Controller('listings/undefined') export class UnknownListingsController { - constructor(@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) {} + constructor( + @Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger, + private readonly businessListingsService: BusinessListingService, + private readonly propertyListingsService: CommercialPropertyService, + ) {} - // @Get(':id') - // async findById(@Param('id') id: string): Promise { - // const result = await this.listingsService.findById(id, businesses); - // if (result) { - // return result; - // } else { - // return await this.listingsService.findById(id, commercials); - // } - // } + @UseGuards(OptionalJwtAuthGuard) + @Get(':id') + async findById(@Request() req, @Param('id') id: string): Promise { + const result = await this.businessListingsService.findBusinessesById(id, req.user); + if (result) { + return result; + } else { + return await this.propertyListingsService.findCommercialPropertiesById(id, req.user); + } + } } diff --git a/bizmatch/src/app/components/validated-price/validated-price.component.html b/bizmatch/src/app/components/validated-price/validated-price.component.html index abf84cf..c0cdc61 100644 --- a/bizmatch/src/app/components/validated-price/validated-price.component.html +++ b/bizmatch/src/app/components/validated-price/validated-price.component.html @@ -21,5 +21,6 @@ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" [options]="{ prefix: '$', thousands: ',', decimal: '.', precision: 0, align: 'left' }" currencyMask + autocomplete="off" /> diff --git a/bizmatch/src/app/guards/listing-category.guard.ts b/bizmatch/src/app/guards/listing-category.guard.ts index 10e2a48..d0c99fc 100644 --- a/bizmatch/src/app/guards/listing-category.guard.ts +++ b/bizmatch/src/app/guards/listing-category.guard.ts @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router'; import { Observable, of } from 'rxjs'; -import { catchError, map } from 'rxjs/operators'; +import { catchError, tap } from 'rxjs/operators'; import { environment } from '../../environments/environment'; @Injectable({ @@ -17,14 +17,14 @@ export class ListingCategoryGuard implements CanActivate { const url = `${this.apiBaseUrl}/bizmatch/listings/undefined/${id}`; return this.http.get(url).pipe( - map(response => { + tap(response => { const category = response.listingsCategory; if (category === 'business') { - return this.router.createUrlTree([`/details-business-listing/${id}`]); + this.router.navigate(['details-business-listing', id]); } else if (category === 'commercialProperty') { - return this.router.createUrlTree([`/details-commercial-property-listing/${id}`]); + this.router.navigate(['details-commercial-property-listing', id]); } else { - return this.router.createUrlTree(['/not-found']); + this.router.navigate(['not-found']); } }), catchError(() => { diff --git a/bizmatch/src/app/pages/details/details-business-listing/details-business-listing.component.ts b/bizmatch/src/app/pages/details/details-business-listing/details-business-listing.component.ts index 699d1e2..2688010 100644 --- a/bizmatch/src/app/pages/details/details-business-listing/details-business-listing.component.ts +++ b/bizmatch/src/app/pages/details/details-business-listing/details-business-listing.component.ts @@ -16,7 +16,7 @@ import { MailService } from '../../../services/mail.service'; import { SelectOptionsService } from '../../../services/select-options.service'; import { UserService } from '../../../services/user.service'; import { SharedModule } from '../../../shared/shared/shared.module'; -import { map2User } from '../../../utils/utils'; +import { createMailInfo, map2User } from '../../../utils/utils'; @Component({ selector: 'app-details-business-listing', standalone: true, @@ -81,7 +81,7 @@ export class DetailsBusinessListingComponent { this.keycloakUser = map2User(token); if (this.keycloakUser) { this.user = await this.userService.getByMail(this.keycloakUser.email); - this.mailinfo.sender = { name: `${this.user.firstname} ${this.user.lastname}`, email: this.user.email, phoneNumber: this.user.phoneNumber, state: this.user.companyLocation.state }; + this.mailinfo = createMailInfo(this.user); } this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, 'business')); this.listingUser = await this.userService.getByMail(this.listing.email); @@ -99,6 +99,7 @@ export class DetailsBusinessListingComponent { this.mailinfo.listing = this.listing; await this.mailService.mail(this.mailinfo); this.messageService.addMessage({ severity: 'success', text: 'Your message has been sent to the creator of the listing', duration: 3000 }); + this.mailinfo = createMailInfo(this.user); } catch (error) { this.messageService.addMessage({ severity: 'danger', diff --git a/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.ts b/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.ts index 389dcb8..8c1c4cf 100644 --- a/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.ts +++ b/bizmatch/src/app/pages/details/details-commercial-property-listing/details-commercial-property-listing.component.ts @@ -18,7 +18,7 @@ import { MailService } from '../../../services/mail.service'; import { SelectOptionsService } from '../../../services/select-options.service'; import { UserService } from '../../../services/user.service'; import { SharedModule } from '../../../shared/shared/shared.module'; -import { map2User } from '../../../utils/utils'; +import { createMailInfo, map2User } from '../../../utils/utils'; @Component({ selector: 'app-details-commercial-property-listing', @@ -86,7 +86,7 @@ export class DetailsCommercialPropertyListingComponent { this.keycloakUser = map2User(token); if (this.keycloakUser) { this.user = await this.userService.getByMail(this.keycloakUser.email); - this.mailinfo.sender = { name: `${this.user.firstname} ${this.user.lastname}`, email: this.user.email, phoneNumber: this.user.phoneNumber, state: this.user.companyLocation.state }; + this.mailinfo = createMailInfo(this.user); } this.listing = (await lastValueFrom(this.listingsService.getListingById(this.id, 'commercialProperty'))) as CommercialPropertyListing; this.listingUser = await this.userService.getByMail(this.listing.email); @@ -123,6 +123,7 @@ export class DetailsCommercialPropertyListingComponent { this.mailinfo.listing = this.listing; await this.mailService.mail(this.mailinfo); this.messageService.addMessage({ severity: 'success', text: 'Your message has been sent to the creator of the listing', duration: 3000 }); + this.mailinfo = createMailInfo(this.user); } catch (error) { this.messageService.addMessage({ severity: 'danger', diff --git a/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.html b/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.html index 349fd58..8736609 100644 --- a/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.html +++ b/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.html @@ -129,15 +129,15 @@
- +
- +
- +
diff --git a/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts b/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts index 7ea1547..a191b60 100644 --- a/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts +++ b/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts @@ -159,4 +159,13 @@ export class EditBusinessListingComponent { } target[keys[keys.length - 1]] = value; } + onCheckboxChange(checkbox: string) { + // Deaktivieren Sie alle Checkboxes + this.listing.realEstateIncluded = false; + this.listing.leasedLocation = false; + this.listing.franchiseResale = false; + + // Aktivieren Sie nur die aktuell ausgewählte Checkbox + this.listing[checkbox] = true; + } } diff --git a/bizmatch/src/app/pages/subscription/email-us/email-us.component.ts b/bizmatch/src/app/pages/subscription/email-us/email-us.component.ts index 3902862..51241fe 100644 --- a/bizmatch/src/app/pages/subscription/email-us/email-us.component.ts +++ b/bizmatch/src/app/pages/subscription/email-us/email-us.component.ts @@ -11,7 +11,7 @@ import { ValidationMessagesService } from '../../../components/validation-messag import { MailService } from '../../../services/mail.service'; import { UserService } from '../../../services/user.service'; import { SharedModule } from '../../../shared/shared/shared.module'; -import { map2User } from '../../../utils/utils'; +import { createMailInfo, map2User } from '../../../utils/utils'; @Component({ selector: 'app-email-us', standalone: true, @@ -39,7 +39,7 @@ export class EmailUsComponent { this.keycloakUser = map2User(token); if (this.keycloakUser) { this.user = await this.userService.getByMail(this.keycloakUser.email); - this.mailinfo.sender = { name: `${this.user.firstname} ${this.user.lastname}`, email: this.user.email, phoneNumber: this.user.phoneNumber, state: this.user.companyLocation.state }; + this.mailinfo = createMailInfo(this.user); } } ngOnDestroy() { @@ -50,6 +50,7 @@ export class EmailUsComponent { this.mailinfo.email = 'support@bizmatch.net'; await this.mailService.mail(this.mailinfo); this.messageService.addMessage({ severity: 'success', text: 'Your request has been forwarded to the support team of bizmatch.', duration: 3000 }); + this.mailinfo = createMailInfo(this.user); } catch (error) { this.messageService.addMessage({ severity: 'danger', diff --git a/bizmatch/src/app/utils/utils.ts b/bizmatch/src/app/utils/utils.ts index cf3263a..6ff1a22 100644 --- a/bizmatch/src/app/utils/utils.ts +++ b/bizmatch/src/app/utils/utils.ts @@ -1,7 +1,7 @@ import { Router } from '@angular/router'; import { ConsoleFormattedStream, INFO, createLogger as _createLogger, stdSerializers } from 'browser-bunyan'; import { jwtDecode } from 'jwt-decode'; -import { BusinessListingCriteria, CommercialPropertyListingCriteria, JwtToken, KeycloakUser, UserListingCriteria } from '../../../../bizmatch-server/src/models/main.model'; +import { BusinessListingCriteria, CommercialPropertyListingCriteria, JwtToken, KeycloakUser, MailInfo, UserListingCriteria } from '../../../../bizmatch-server/src/models/main.model'; // export function createDefaultUser(email: string, firstname: string, lastname: string): User { // return { @@ -154,6 +154,14 @@ export function createEmptyUserListingCriteria(): UserListingCriteria { radius: null, }; } +export function createMailInfo(user: User): MailInfo { + return { + sender: { name: `${user.firstname} ${user.lastname}`, email: user.email, phoneNumber: user.phoneNumber, state: user.companyLocation.state, comments: null }, + email: null, + url: environment.mailinfoUrl, + listing: null, + }; +} export function createLogger(name: string, level: number = INFO, options: any = {}) { return _createLogger({ name, @@ -244,6 +252,8 @@ export function getDialogWidth(dimensions): string { import { initFlowbite } from 'flowbite'; import onChange from 'on-change'; import { Subject, concatMap, delay, of } from 'rxjs'; +import { User } from '../../../../bizmatch-server/src/models/db.model'; +import { environment } from '../../environments/environment'; const flowbiteQueue = new Subject<() => void>(); @@ -387,17 +397,7 @@ export function getCriteriaProxy(path: string, component: any): BusinessListingC } } export function createEnhancedProxy(obj: BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria, component: any) { - // const component = this; - const sessionStorageHandler = function (path, value, previous, applyData) { - // let criteriaType = ''; - // if ('/businessListings' === window.location.pathname) { - // criteriaType = 'business'; - // } else if ('/commercialPropertyListings' === window.location.pathname) { - // criteriaType = 'commercialProperty'; - // } else if ('/brokerListings' === window.location.pathname) { - // criteriaType = 'broker'; - // } sessionStorage.setItem(`${obj.criteriaType}`, JSON.stringify(this)); };