Einbau klassische Filter als Overlay ...

This commit is contained in:
2024-07-16 17:09:59 +02:00
parent af982d19d8
commit bdafb03165
32 changed files with 1274 additions and 239 deletions

View File

@@ -2,7 +2,7 @@ import { Router } from '@angular/router';
import { ConsoleFormattedStream, INFO, createLogger as _createLogger, stdSerializers } from 'browser-bunyan';
import { jwtDecode } from 'jwt-decode';
import { BusinessListing, CommercialPropertyListing, User } from '../../../../bizmatch-server/src/models/db.model';
import { JwtToken, KeycloakUser, ListingCriteria } from '../../../../bizmatch-server/src/models/main.model';
import { BusinessListingCriteria, CommercialPropertyListingCriteria, JwtToken, KeycloakUser, UserListingCriteria } from '../../../../bizmatch-server/src/models/main.model';
export function createDefaultUser(email: string, firstname: string, lastname: string): User {
return {
@@ -82,21 +82,69 @@ export function createDefaultBusinessListing(): BusinessListing {
listingsCategory: 'business',
};
}
export function createDefaultListingCriteria(): ListingCriteria {
export function createEmptyBusinessListingCriteria(): BusinessListingCriteria {
return {
start: 0,
length: 12,
length: 0,
page: 0,
pageCount: 0,
type: 0,
state: '',
city: '',
types: [],
prompt: '',
criteriaType: 'business',
county: '',
minPrice: null,
maxPrice: null,
minRevenue: null,
maxRevenue: null,
minCashFlow: null,
maxCashFlow: null,
minNumberEmployees: null,
maxNumberEmployees: null,
establishedSince: null,
establishedUntil: null,
realEstateChecked: false,
leasedLocation: false,
franchiseResale: false,
title: '',
brokerName: '',
};
}
export function createEmptyCommercialPropertyListingCriteria(): CommercialPropertyListingCriteria {
return {
start: 0,
length: 0,
page: 0,
pageCount: 0,
state: '',
city: '',
types: [],
prompt: '',
criteriaType: 'commercialProperty',
county: '',
minPrice: 0,
maxPrice: 0,
realEstateChecked: false,
title: '',
category: 'broker',
name: '',
};
}
export function createEmptyUserListingCriteria(): UserListingCriteria {
return {
start: 0,
length: 0,
page: 0,
pageCount: 0,
city: '',
types: [],
prompt: '',
criteriaType: 'user',
firstname: '',
lastname: '',
companyName: '',
counties: [],
states: [],
};
}
export function createLogger(name: string, level: number = INFO, options: any = {}) {
@@ -120,8 +168,15 @@ export const getSessionStorageHandler = function (path, value, previous, applyDa
sessionStorage.setItem('criteria', JSON.stringify(this));
};
export function getCriteriaStateObject() {
const initialState = createDefaultListingCriteria();
export function getCriteriaStateObject(criteriaType: 'business' | 'commercialProperty' | 'user') {
let initialState;
if (criteriaType === 'business') {
initialState = createEmptyBusinessListingCriteria();
} else if (criteriaType === 'commercialProperty') {
initialState = createEmptyCommercialPropertyListingCriteria();
} else {
initialState = createEmptyUserListingCriteria();
}
const storedState = sessionStorage.getItem('criteria');
return storedState ? JSON.parse(storedState) : initialState;
}
@@ -134,17 +189,6 @@ export function routeListingWithState(router: Router, value: string, data: any)
}
}
export function resetCriteria(criteria: ListingCriteria) {
criteria.type = null;
criteria.state = null;
criteria.minPrice = null;
criteria.maxPrice = null;
criteria.start = 0;
criteria.length = 12;
criteria.realEstateChecked = null;
criteria.title = null;
criteria.name = null;
}
export function map2User(jwt: string): KeycloakUser {
if (jwt) {
const token = jwtDecode<JwtToken>(jwt);