import { BusinessListing, CommercialPropertyListing, User } from './db.model'; export interface StatesResult { state: string; count: number; } export interface KeyValue { name: string; value: string; } export interface KeyValueRatio { label: string; value: number; } export interface KeyValueStyle { name: string; value: string; oldValue?: string; icon: string; textColorClass: string; } export type SelectOption = { value: T; label: string; }; export type ImageType = { name: 'propertyPicture' | 'companyLogo' | 'profile'; upload: string; delete: string; }; export type ListingCategory = { name: 'business' | 'commercialProperty'; }; export type ListingType = BusinessListing | CommercialPropertyListing; export type ResponseBusinessListingArray = { results: BusinessListing[]; totalCount: number; }; export type ResponseBusinessListing = { data: BusinessListing; }; export type ResponseCommercialPropertyListingArray = { results: CommercialPropertyListing[]; totalCount: number; }; export type ResponseCommercialPropertyListing = { data: CommercialPropertyListing; }; export type ResponseUsersArray = { results: User[]; totalCount: number; }; export interface ListCriteria { start: number; length: number; page: number; types: string[]; city: string; prompt: string; criteriaType: 'business' | 'commercialProperty' | 'broker'; } export interface BusinessListingCriteria extends ListCriteria { state: string; county: string; minPrice: number; maxPrice: number; minRevenue: number; maxRevenue: number; minCashFlow: number; maxCashFlow: number; minNumberEmployees: number; maxNumberEmployees: number; establishedSince: number; establishedUntil: number; realEstateChecked: boolean; leasedLocation: boolean; franchiseResale: boolean; title: string; brokerName: string; criteriaType: 'business'; } export interface CommercialPropertyListingCriteria extends ListCriteria { state: string; county: string; minPrice: number; maxPrice: number; title: string; criteriaType: 'commercialProperty'; } export interface UserListingCriteria extends ListCriteria { firstname: string; lastname: string; companyName: string; counties: string[]; states: string[]; criteriaType: 'broker'; } export interface KeycloakUser { id: string; createdTimestamp?: number; username?: string; enabled?: boolean; totp?: boolean; emailVerified?: boolean; firstName: string; lastName: string; email: string; disableableCredentialTypes?: any[]; requiredActions?: any[]; notBefore?: number; access?: Access; } export interface JwtUser { userId: string; username: string; firstname: string; lastname: string; roles: string[]; } export interface Access { manageGroupMembership: boolean; view: boolean; mapRoles: boolean; impersonate: boolean; manage: boolean; } export interface Subscription { id: string; userId: string; level: string; start: Date; modified: Date; end: Date; status: string; invoices: Array; } export interface Invoice { id: string; date: Date; price: number; } export interface JwtToken { exp: number; iat: number; auth_time: number; jti: string; iss: string; aud: string; sub: string; typ: string; azp: string; nonce: string; session_state: string; acr: string; realm_access: Realmaccess; resource_access: Resourceaccess; scope: string; sid: string; email_verified: boolean; name: string; preferred_username: string; given_name: string; family_name: string; email: string; user_id: string; } export interface JwtPayload { sub: string; preferred_username: string; realm_access?: { roles?: string[]; }; [key: string]: any; // für andere optionale Felder im JWT-Payload } interface Resourceaccess { account: Realmaccess; } interface Realmaccess { roles: string[]; } export interface PageEvent { first: number; rows: number; page: number; pageCount: number; } export interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } export interface MailInfo { sender: Sender; email: string; url: string; listing?: BusinessListing; } export interface Sender { name?: string; email?: string; phoneNumber?: string; state?: string; comments?: string; } export interface ImageProperty { id: string; code: string; name: string; } export interface ErrorResponse { fields?: FieldError[]; general?: string[]; } export interface FieldError { fieldname: string; message: string; } export interface UploadParams { type: 'uploadPropertyPicture' | 'uploadCompanyLogo' | 'uploadProfile'; imagePath: string; serialId?: number; } export interface GeoResult { id: number; city: string; state: string; state_code: string; } export interface CountyResult { id: number; name: string; state: string; state_code: string; } export function isEmpty(value: any): boolean { // Check for undefined or null if (value === undefined || value === null) { return true; } // Check for empty string or string with only whitespace if (typeof value === 'string') { return value.trim().length === 0; } // Check for number and NaN if (typeof value === 'number') { return isNaN(value); } // If it's not a string or number, it's not considered empty by this function return false; } export function emailToDirName(email: string): string { if (email === undefined || email === null) { return null; } // Entferne ungültige Zeichen und ersetze sie durch Unterstriche const sanitizedEmail = email.replace(/[^a-zA-Z0-9_-]/g, '_'); // Entferne führende und nachfolgende Unterstriche const trimmedEmail = sanitizedEmail.replace(/^_+|_+$/g, ''); // Ersetze mehrfache aufeinanderfolgende Unterstriche durch einen einzelnen Unterstrich const normalizedEmail = trimmedEmail.replace(/_+/g, '_'); return normalizedEmail; } export const LISTINGS_PER_PAGE = 12;