diff --git a/bizmatch-server/src/drizzle/schema.ts b/bizmatch-server/src/drizzle/schema.ts index 8d6b02b..3c4546e 100644 --- a/bizmatch-server/src/drizzle/schema.ts +++ b/bizmatch-server/src/drizzle/schema.ts @@ -33,6 +33,7 @@ export const users = pgTable( subscriptionId: text('subscriptionId'), subscriptionPlan: subscriptionTypeEnum('subscriptionPlan'), location: jsonb('location'), + showInDirectory: boolean('showInDirectory').default(true), // city: varchar('city', { length: 255 }), // state: char('state', { length: 2 }), // latitude: doublePrecision('latitude'), diff --git a/bizmatch-server/src/interceptors/logging.interceptor.ts b/bizmatch-server/src/interceptors/logging.interceptor.ts index c0be9b0..3b6f1f7 100644 --- a/bizmatch-server/src/interceptors/logging.interceptor.ts +++ b/bizmatch-server/src/interceptors/logging.interceptor.ts @@ -15,7 +15,7 @@ export class LoggingInterceptor implements NestInterceptor { const ip = this.cls.get('ip') || 'unknown'; const countryCode = this.cls.get('countryCode') || 'unknown'; - const username = this.cls.get('username') || 'unknown'; + const username = this.cls.get('email') || 'unknown'; const method = request.method; const url = request.originalUrl; diff --git a/bizmatch-server/src/interceptors/user.interceptor.ts b/bizmatch-server/src/interceptors/user.interceptor.ts index 45b058a..7658548 100644 --- a/bizmatch-server/src/interceptors/user.interceptor.ts +++ b/bizmatch-server/src/interceptors/user.interceptor.ts @@ -13,12 +13,12 @@ export class UserInterceptor implements NestInterceptor { const request = context.switchToHttp().getRequest(); // Überprüfe, ob der Benutzer authentifiziert ist - if (request.user && request.user.username) { + if (request.user && request.user.email) { try { - this.cls.set('username', request.user.username); - this.logger.log(`CLS context gesetzt: Username=${request.user.username}`); + this.cls.set('email', request.user.email); + this.logger.log(`CLS context gesetzt: EMail=${request.user.email}`); } catch (error) { - this.logger.error('Fehler beim Setzen der Username im CLS-Kontext', error); + this.logger.error('Fehler beim Setzen der EMail im CLS-Kontext', error); } } else { this.logger.log('Kein authentifizierter Benutzer gefunden'); diff --git a/bizmatch-server/src/models/db.model.ts b/bizmatch-server/src/models/db.model.ts index c94c525..9f20712 100644 --- a/bizmatch-server/src/models/db.model.ts +++ b/bizmatch-server/src/models/db.model.ts @@ -186,6 +186,7 @@ export const UserSchema = z updated: z.date().optional().nullable(), subscriptionId: z.string().optional().nullable(), subscriptionPlan: SubscriptionTypeEnum.optional().nullable(), + showInDirectory: z.boolean(), }) .superRefine((data, ctx) => { if (data.customerType === 'professional') { @@ -233,7 +234,7 @@ export const UserSchema = z ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Company location is required for professional customers', - path: ['companyLocation'], + path: ['location'], }); } diff --git a/bizmatch-server/src/user/user.service.ts b/bizmatch-server/src/user/user.service.ts index 011e20b..b41ec48 100644 --- a/bizmatch-server/src/user/user.service.ts +++ b/bizmatch-server/src/user/user.service.ts @@ -52,6 +52,10 @@ export class UserService { if (criteria.state) { whereConditions.push(sql`EXISTS (SELECT 1 FROM jsonb_array_elements(${schema.users.areasServed}) AS area WHERE area->>'state' = ${criteria.state})`); } + + //never show user which denied + whereConditions.push(eq(schema.users.showInDirectory, true)) + return whereConditions; } async searchUserListings(criteria: UserListingCriteria): Promise<{ results: User[]; totalCount: number }> { @@ -59,7 +63,7 @@ export class UserService { const length = criteria.length ? criteria.length : 12; const query = this.conn.select().from(schema.users); const whereConditions = this.getWhereConditions(criteria); - + if (whereConditions.length > 0) { const whereClause = and(...whereConditions); query.where(whereClause); diff --git a/bizmatch/src/app/app.component.html b/bizmatch/src/app/app.component.html index d877810..f6a844b 100644 --- a/bizmatch/src/app/app.component.html +++ b/bizmatch/src/app/app.component.html @@ -1,9 +1,9 @@ -
+
@if (actualRoute !=='home' && actualRoute !=='login' && actualRoute!=='emailVerification' && actualRoute!=='email-authorized'){
} -
+
diff --git a/bizmatch/src/app/components/header/header.component.html b/bizmatch/src/app/components/header/header.component.html index 7943e2b..5eae35a 100644 --- a/bizmatch/src/app/components/header/header.component.html +++ b/bizmatch/src/app/components/header/header.component.html @@ -111,6 +111,7 @@ >Businesses + @if ((numberOfCommercial$ | async) > 0) {
  • Properties
  • + } + @if ((numberOfBroker$ | async) > 0) {
  • Professionals
  • + }
    } @else { @@ -151,6 +155,7 @@ >Businesses + @if ((numberOfCommercial$ | async) > 0) {
  • Properties
  • + } + @if ((numberOfBroker$ | async) > 0) {
  • Professionals
  • + }
    } @@ -200,6 +208,7 @@ >Businesses + @if ((numberOfCommercial$ | async) > 0) {
  • Properties
  • + } + @if ((numberOfBroker$ | async) > 0) {
  • Professionals
  • + } diff --git a/bizmatch/src/app/components/header/header.component.ts b/bizmatch/src/app/components/header/header.component.ts index 98cd16e..3ac2764 100644 --- a/bizmatch/src/app/components/header/header.component.ts +++ b/bizmatch/src/app/components/header/header.component.ts @@ -12,6 +12,7 @@ import { BusinessListingCriteria, CommercialPropertyListingCriteria, emailToDirN import { environment } from '../../../environments/environment'; import { AuthService } from '../../services/auth.service'; import { CriteriaChangeService } from '../../services/criteria-change.service'; +import { ListingsService } from '../../services/listings.service'; import { SearchService } from '../../services/search.service'; import { SelectOptionsService } from '../../services/select-options.service'; import { SharedService } from '../../services/shared.service'; @@ -46,6 +47,8 @@ export class HeaderComponent { baseRoute: string; sortDropdownVisible: boolean; sortByOptions: KeyValueAsSortBy[] = []; + numberOfBroker$: Observable; + numberOfCommercial$: Observable; constructor( private router: Router, private userService: UserService, @@ -56,6 +59,7 @@ export class HeaderComponent { private criteriaChangeService: CriteriaChangeService, public selectOptions: SelectOptionsService, private authService: AuthService, + private listingService: ListingsService, ) {} @HostListener('document:click', ['$event']) handleGlobalClick(event: Event) { @@ -71,7 +75,8 @@ export class HeaderComponent { this.user = await this.userService.getByMail(this.keycloakUser?.email); this.profileUrl = this.user.hasProfile ? `${this.env.imageBaseUrl}/pictures/profile/${emailToDirName(this.user.email)}.avif?_ts=${new Date().getTime()}` : `/assets/images/placeholder.png`; } - + this.numberOfBroker$ = this.userService.getNumberOfBroker(createEmptyUserListingCriteria()); + this.numberOfCommercial$ = this.listingService.getNumberOfListings(createEmptyCommercialPropertyListingCriteria(), 'commercialProperty'); setTimeout(() => { initFlowbite(); }, 10); diff --git a/bizmatch/src/app/pages/home/home.component.html b/bizmatch/src/app/pages/home/home.component.html index e0bb896..7be7b32 100644 --- a/bizmatch/src/app/pages/home/home.component.html +++ b/bizmatch/src/app/pages/home/home.component.html @@ -56,6 +56,7 @@ >Businesses + @if ((numberOfCommercial$ | async) > 0) {
  • Properties
  • + } + @if ((numberOfBroker$ | async) > 0) {
  • Professionals
  • + } } @if(aiSearch){ diff --git a/bizmatch/src/app/pages/home/home.component.ts b/bizmatch/src/app/pages/home/home.component.ts index 3887cd8..d365174 100644 --- a/bizmatch/src/app/pages/home/home.component.ts +++ b/bizmatch/src/app/pages/home/home.component.ts @@ -52,7 +52,8 @@ export class HomeComponent { cityOrState = undefined; private criteriaChangeSubscription: Subscription; numberOfResults$: Observable; - + numberOfBroker$: Observable; + numberOfCommercial$: Observable; aiSearch = false; aiSearchText = ''; aiSearchFailed = false; @@ -84,7 +85,8 @@ export class HomeComponent { setTimeout(() => { initFlowbite(); }, 0); - + this.numberOfBroker$ = this.userService.getNumberOfBroker(createEmptyUserListingCriteria()); + this.numberOfCommercial$ = this.listingService.getNumberOfListings(createEmptyCommercialPropertyListingCriteria(), 'commercialProperty'); const token = await this.authService.getToken(); sessionStorage.removeItem('businessListings'); sessionStorage.removeItem('commercialPropertyListings'); @@ -114,14 +116,7 @@ export class HomeComponent { private setupCriteriaChangeListener() { this.criteriaChangeSubscription = this.criteriaChangeService.criteriaChange$.pipe(untilDestroyed(this), debounceTime(400)).subscribe(() => this.setTotalNumberOfResults()); } - // login() { - // this.keycloakService.login({ - // redirectUri: `${window.location.origin}/login${this.router.routerState.snapshot.url}`, - // }); - // } - // register() { - // this.keycloakService.register({ redirectUri: `${window.location.origin}/account` }); - // } + toggleMenu() { this.isMenuOpen = !this.isMenuOpen; } diff --git a/bizmatch/src/app/pages/subscription/account/account.component.html b/bizmatch/src/app/pages/subscription/account/account.component.html index 98d0028..7afd761 100644 --- a/bizmatch/src/app/pages/subscription/account/account.component.html +++ b/bizmatch/src/app/pages/subscription/account/account.component.html @@ -220,6 +220,16 @@ } +
    + +
    +