Bugfixes
This commit is contained in:
@@ -3,21 +3,80 @@ import { ConsoleFormattedStream, INFO, createLogger as _createLogger, stdSeriali
|
||||
import { BusinessListing, CommercialPropertyListing } from '../../../../bizmatch-server/src/models/db.model';
|
||||
import { ListingCriteria } from '../../../../bizmatch-server/src/models/main.model';
|
||||
|
||||
export function createGenericObject<T>(): T {
|
||||
// Ein leeres Objekt vom Typ T erstellen
|
||||
const ergebnis: Partial<T> = {};
|
||||
|
||||
// Für ein reales Interface funktioniert diese direkte Iteration nicht,
|
||||
// da Interfaces zur Compile-Zeit entfernt werden. Stattdessen könnten Sie
|
||||
// ein Dummy-Objekt oder spezifische Typtransformationen verwenden.
|
||||
// Hier nur als Pseudocode dargestellt, um die Idee zu vermitteln:
|
||||
for (const key in ergebnis) {
|
||||
ergebnis[key] = null; // oder undefined, je nach Bedarf
|
||||
}
|
||||
|
||||
return ergebnis as T;
|
||||
export function createDefaultCommercialPropertyListing(): CommercialPropertyListing {
|
||||
return {
|
||||
id: undefined,
|
||||
userId: '',
|
||||
type: null,
|
||||
title: '',
|
||||
description: '',
|
||||
city: '',
|
||||
state: '',
|
||||
price: null,
|
||||
favoritesForUser: [],
|
||||
hideImage: false,
|
||||
draft: false,
|
||||
zipCode: null,
|
||||
county: '',
|
||||
email: '',
|
||||
website: '',
|
||||
phoneNumber: '',
|
||||
imageOrder: [],
|
||||
imagePath: '',
|
||||
created: null,
|
||||
updated: null,
|
||||
visits: null,
|
||||
lastVisit: null,
|
||||
listingsCategory: 'commercialProperty',
|
||||
};
|
||||
}
|
||||
export function createDefaultBusinessListing(): BusinessListing {
|
||||
return {
|
||||
id: undefined,
|
||||
userId: '',
|
||||
type: null,
|
||||
title: '',
|
||||
description: '',
|
||||
city: '',
|
||||
state: '',
|
||||
price: null,
|
||||
favoritesForUser: [],
|
||||
draft: false,
|
||||
realEstateIncluded: false,
|
||||
leasedLocation: false,
|
||||
franchiseResale: false,
|
||||
salesRevenue: null,
|
||||
cashFlow: null,
|
||||
supportAndTraining: '',
|
||||
employees: null,
|
||||
established: null,
|
||||
internalListingNumber: null,
|
||||
reasonForSale: '',
|
||||
brokerLicencing: '',
|
||||
internals: '',
|
||||
created: null,
|
||||
updated: null,
|
||||
visits: null,
|
||||
lastVisit: null,
|
||||
listingsCategory: 'business',
|
||||
};
|
||||
}
|
||||
export function createDefaultListingCriteria(): ListingCriteria {
|
||||
return {
|
||||
start: 0,
|
||||
length: 0,
|
||||
page: 0,
|
||||
pageCount: 0,
|
||||
type: 0,
|
||||
state: '',
|
||||
minPrice: 0,
|
||||
maxPrice: 0,
|
||||
realEstateChecked: false,
|
||||
title: '',
|
||||
category: 'broker',
|
||||
name: '',
|
||||
};
|
||||
}
|
||||
|
||||
export function createLogger(name: string, level: number = INFO, options: any = {}) {
|
||||
return _createLogger({
|
||||
name,
|
||||
@@ -33,20 +92,11 @@ export const getSessionStorageHandler = function (path, value, previous, applyDa
|
||||
};
|
||||
|
||||
export function getCriteriaStateObject() {
|
||||
const initialState = createGenericObject<ListingCriteria>();
|
||||
const initialState = createDefaultListingCriteria();
|
||||
const storedState = sessionStorage.getItem('criteria');
|
||||
return storedState ? JSON.parse(storedState) : initialState;
|
||||
}
|
||||
|
||||
export function getListingType(listing: BusinessListing | CommercialPropertyListing): 'business' | 'commercialProperty' {
|
||||
return listing?.type < 100 ? 'business' : 'commercialProperty';
|
||||
}
|
||||
export function isBusinessListing(listing: BusinessListing | CommercialPropertyListing): listing is BusinessListing {
|
||||
return listing?.type < 100;
|
||||
}
|
||||
export function isCommercialPropertyListing(listing: BusinessListing | CommercialPropertyListing): listing is CommercialPropertyListing {
|
||||
return listing?.type >= 100;
|
||||
}
|
||||
export function routeListingWithState(router: Router, value: string, data: any) {
|
||||
if (value === 'business') {
|
||||
router.navigate(['createBusinessListing'], { state: { data } });
|
||||
@@ -54,6 +104,7 @@ export function routeListingWithState(router: Router, value: string, data: any)
|
||||
router.navigate(['createCommercialPropertyListing'], { state: { data } });
|
||||
}
|
||||
}
|
||||
|
||||
export function resetCriteria(criteria: ListingCriteria) {
|
||||
criteria.type = null;
|
||||
criteria.state = null;
|
||||
|
||||
Reference in New Issue
Block a user