diff --git a/bizmatch-client/.editorconfig b/bizmatch-client/.editorconfig new file mode 100644 index 0000000..f166060 --- /dev/null +++ b/bizmatch-client/.editorconfig @@ -0,0 +1,17 @@ +# Editor configuration, see https://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.ts] +quote_type = single +ij_typescript_use_double_quotes = false + +[*.md] +max_line_length = off +trim_trailing_whitespace = false diff --git a/bizmatch-client/.gitignore b/bizmatch-client/.gitignore new file mode 100644 index 0000000..cc7b141 --- /dev/null +++ b/bizmatch-client/.gitignore @@ -0,0 +1,42 @@ +# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files. + +# Compiled output +/dist +/tmp +/out-tsc +/bazel-out + +# Node +/node_modules +npm-debug.log +yarn-error.log + +# IDEs and editors +.idea/ +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# Visual Studio Code +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +.history/* + +# Miscellaneous +/.angular/cache +.sass-cache/ +/connect.lock +/coverage +/libpeerconnection.log +testem.log +/typings + +# System files +.DS_Store +Thumbs.db diff --git a/bizmatch-client/.prettierrc.json b/bizmatch-client/.prettierrc.json new file mode 100644 index 0000000..154e81e --- /dev/null +++ b/bizmatch-client/.prettierrc.json @@ -0,0 +1,18 @@ +{ + "arrowParens": "avoid", + "embeddedLanguageFormatting": "auto", + "htmlWhitespaceSensitivity": "css", + "insertPragma": false, + "jsxBracketSameLine": false, + "jsxSingleQuote": false, + "printWidth": 250, + "proseWrap": "always", + "quoteProps": "as-needed", + "requirePragma": false, + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "all", + "useTabs": false, + "vueIndentScriptAndStyle": false +} \ No newline at end of file diff --git a/bizmatch-client/.vscode/extensions.json b/bizmatch-client/.vscode/extensions.json new file mode 100644 index 0000000..77b3745 --- /dev/null +++ b/bizmatch-client/.vscode/extensions.json @@ -0,0 +1,4 @@ +{ + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 + "recommendations": ["angular.ng-template"] +} diff --git a/bizmatch-client/.vscode/launch.json b/bizmatch-client/.vscode/launch.json new file mode 100644 index 0000000..925af83 --- /dev/null +++ b/bizmatch-client/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "ng serve", + "type": "chrome", + "request": "launch", + "preLaunchTask": "npm: start", + "url": "http://localhost:4200/" + }, + { + "name": "ng test", + "type": "chrome", + "request": "launch", + "preLaunchTask": "npm: test", + "url": "http://localhost:9876/debug.html" + } + ] +} diff --git a/bizmatch-client/.vscode/settings.json b/bizmatch-client/.vscode/settings.json new file mode 100644 index 0000000..0fd6e04 --- /dev/null +++ b/bizmatch-client/.vscode/settings.json @@ -0,0 +1,28 @@ +{ + "editor.suggestSelection": "first", + "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue", + "explorer.confirmDelete": false, + "typescript.updateImportsOnFileMove.enabled": "always", + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[html]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[json]": { + "editor.defaultFormatter": "vscode.json-language-features" + }, + "[scss]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit" + }, + "prettier.printWidth": 240, + "git.autofetch": false, + "git.autorefresh": true +} diff --git a/bizmatch-client/.vscode/tasks.json b/bizmatch-client/.vscode/tasks.json new file mode 100644 index 0000000..a298b5b --- /dev/null +++ b/bizmatch-client/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "start", + "isBackground": true, + "problemMatcher": { + "owner": "typescript", + "pattern": "$tsc", + "background": { + "activeOnStart": true, + "beginsPattern": { + "regexp": "(.*?)" + }, + "endsPattern": { + "regexp": "bundle generation complete" + } + } + } + }, + { + "type": "npm", + "script": "test", + "isBackground": true, + "problemMatcher": { + "owner": "typescript", + "pattern": "$tsc", + "background": { + "activeOnStart": true, + "beginsPattern": { + "regexp": "(.*?)" + }, + "endsPattern": { + "regexp": "bundle generation complete" + } + } + } + } + ] +} diff --git a/bizmatch-client/README.md b/bizmatch-client/README.md new file mode 100644 index 0000000..d786c01 --- /dev/null +++ b/bizmatch-client/README.md @@ -0,0 +1,59 @@ +# BizmatchClient + +This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.6. + +## Development server + +To start a local development server, run: + +```bash +ng serve +``` + +Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files. + +## Code scaffolding + +Angular CLI includes powerful code scaffolding tools. To generate a new component, run: + +```bash +ng generate component component-name +``` + +For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run: + +```bash +ng generate --help +``` + +## Building + +To build the project run: + +```bash +ng build +``` + +This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed. + +## Running unit tests + +To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command: + +```bash +ng test +``` + +## Running end-to-end tests + +For end-to-end (e2e) testing, run: + +```bash +ng e2e +``` + +Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs. + +## Additional Resources + +For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page. diff --git a/bizmatch-client/angular.json b/bizmatch-client/angular.json new file mode 100644 index 0000000..868341e --- /dev/null +++ b/bizmatch-client/angular.json @@ -0,0 +1,133 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "bizmatch-client": { + "projectType": "application", + "schematics": { + "@schematics/angular:component": { + "style": "scss", + "skipTests": true + }, + "@schematics/angular:class": { + "skipTests": true + }, + "@schematics/angular:directive": { + "skipTests": true + }, + "@schematics/angular:guard": { + "skipTests": true + }, + "@schematics/angular:interceptor": { + "skipTests": true + }, + "@schematics/angular:pipe": { + "skipTests": true + }, + "@schematics/angular:resolver": { + "skipTests": true + }, + "@schematics/angular:service": { + "skipTests": true + } + }, + "root": "", + "sourceRoot": "src", + "prefix": "app", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:application", + "options": { + "outputPath": "dist/bizmatch-client", + "index": "src/index.html", + "browser": "src/main.ts", + "polyfills": [ + "zone.js" + ], + "tsConfig": "tsconfig.app.json", + "inlineStyleLanguage": "scss", + "assets": [ + { + "glob": "**/*", + "input": "public" + }, + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.scss", + "node_modules/quill/dist/quill.snow.css" + ], + "scripts": [], + "server": "src/main.server.ts", + "prerender": false, + "ssr": false + }, + "configurations": { + "production": { + "budgets": [ + { + "type": "initial", + "maximumWarning": "500kB", + "maximumError": "1MB" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "4kB", + "maximumError": "8kB" + } + ], + "outputHashing": "all" + }, + "development": { + "optimization": false, + "extractLicenses": false, + "sourceMap": true + } + }, + "defaultConfiguration": "production" + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "configurations": { + "production": { + "buildTarget": "bizmatch-client:build:production" + }, + "development": { + "buildTarget": "bizmatch-client:build:development" + } + }, + "defaultConfiguration": "development", + "options": { + "proxyConfig": "proxy.conf.json" + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n" + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "polyfills": [ + "zone.js", + "zone.js/testing" + ], + "tsConfig": "tsconfig.spec.json", + "inlineStyleLanguage": "scss", + "assets": [ + { + "glob": "**/*", + "input": "public" + } + ], + "styles": [ + "src/styles.scss" + ], + "scripts": [] + } + } + } + } + } +} \ No newline at end of file diff --git a/bizmatch-client/package.json b/bizmatch-client/package.json new file mode 100644 index 0000000..3de7c2a --- /dev/null +++ b/bizmatch-client/package.json @@ -0,0 +1,66 @@ +{ + "name": "bizmatch-client", + "version": "0.0.0", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build", + "watch": "ng build --watch --configuration development", + "test": "ng test", + "serve:ssr:bizmatch-client": "node dist/bizmatch-client/server/server.mjs" + }, + "private": true, + "dependencies": { + "@angular/animations": "^19.2.5", + "@angular/common": "^19.2.0", + "@angular/compiler": "^19.2.0", + "@angular/core": "^19.2.0", + "@angular/fire": "^19.0.0", + "@angular/forms": "^19.2.0", + "@angular/platform-browser": "^19.2.0", + "@angular/platform-browser-dynamic": "^19.2.0", + "@angular/platform-server": "^19.2.0", + "@angular/router": "^19.2.0", + "@angular/ssr": "^19.2.6", + "@fortawesome/angular-fontawesome": "^1.0.0", + "@fortawesome/fontawesome-free": "^6.7.2", + "@fortawesome/fontawesome-svg-core": "^6.7.2", + "@fortawesome/free-brands-svg-icons": "^6.7.2", + "@fortawesome/free-solid-svg-icons": "^6.7.2", + "@ng-select/ng-select": "^14.2.6", + "@ngneat/until-destroy": "^10.0.0", + "browser-bunyan": "^1.8.0", + "dayjs": "^1.11.13", + "express": "^4.18.2", + "flowbite": "^3.1.2", + "jwt-decode": "^4.0.0", + "ngx-currency": "^19.0.0", + "ngx-image-cropper": "^9.1.5", + "ngx-mask": "^19.0.6", + "ngx-quill": "^27.0.1", + "ngx-sharebuttons": "^17.0.0", + "on-change": "^5.0.1", + "rxjs": "~7.8.0", + "tslib": "^2.3.0", + "urlcat": "^3.1.0", + "zone.js": "~0.15.0" + }, + "devDependencies": { + "@angular-devkit/build-angular": "^19.2.6", + "@angular/cli": "^19.2.6", + "@angular/compiler-cli": "^19.2.0", + "@types/express": "^4.17.17", + "@types/jasmine": "~5.1.0", + "@types/node": "^18.18.0", + "autoprefixer": "^10.4.21", + "jasmine-core": "~5.6.0", + "karma": "~6.4.0", + "karma-chrome-launcher": "~3.2.0", + "karma-coverage": "~2.2.0", + "karma-jasmine": "~5.1.0", + "karma-jasmine-html-reporter": "~2.1.0", + "postcss": "^8.5.3", + "tailwindcss": "^3.4.17", + "typescript": "~5.7.2" + } +} diff --git a/bizmatch-client/proxy.conf.json b/bizmatch-client/proxy.conf.json new file mode 100644 index 0000000..4fc2167 --- /dev/null +++ b/bizmatch-client/proxy.conf.json @@ -0,0 +1,28 @@ +{ + "/bizmatch": { + "target": "http://localhost:3000", + "secure": false, + "changeOrigin": true, + "logLevel": "debug" + }, + "/pictures": { + "target": "http://localhost:8080", + "secure": false + }, + "/ipify": { + "target": "https://api.ipify.org", + "secure": true, + "changeOrigin": true, + "pathRewrite": { + "^/ipify": "" + } + }, + "/ipinfo": { + "target": "https://ipinfo.io", + "secure": true, + "changeOrigin": true, + "pathRewrite": { + "^/ipinfo": "" + } + } +} \ No newline at end of file diff --git a/bizmatch-client/src/app/app.component.html b/bizmatch-client/src/app/app.component.html new file mode 100644 index 0000000..d85669b --- /dev/null +++ b/bizmatch-client/src/app/app.component.html @@ -0,0 +1,43 @@ + +
+ @if (actualRoute !=='home' && actualRoute !=='login' && + actualRoute!=='emailVerification' && actualRoute!=='email-authorized'){ +
+ } +
+ +
+ +
+ +@if (loadingService.isLoading$ | async) { +
+
+ @let loadingText = (loadingService.loadingText$ | async); @if(loadingText){ +
{{ loadingText }}
+ } +
+ +
+
+
+} + + + + diff --git a/bizmatch-client/src/app/app.component.scss b/bizmatch-client/src/app/app.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/bizmatch-client/src/app/app.component.ts b/bizmatch-client/src/app/app.component.ts new file mode 100644 index 0000000..d6547a4 --- /dev/null +++ b/bizmatch-client/src/app/app.component.ts @@ -0,0 +1,51 @@ +import { CommonModule } from '@angular/common'; +import { Component, HostListener } from '@angular/core'; +import { ActivatedRoute, NavigationEnd, Router, RouterOutlet } from '@angular/router'; +import { filter } from 'rxjs'; +import build from '../build'; +import { ConfirmationComponent } from './components/confirmation.component'; +import { EMailComponent } from './components/email/email.component'; +import { FooterComponent } from './components/footer/footer.component'; +import { HeaderComponent } from './components/header/header.component'; +import { MessageContainerComponent } from './components/message/message-container.component'; +import { SearchModalComponent } from './components/search-modal/search-modal.component'; +import { ConfirmationService } from './services/confirmation.service'; +import { LoadingService } from './services/loading.service'; +import { UserService } from './services/user.service'; + +@Component({ + selector: 'app-root', + imports: [CommonModule, RouterOutlet, HeaderComponent, FooterComponent, MessageContainerComponent, SearchModalComponent, ConfirmationComponent, EMailComponent], + templateUrl: './app.component.html', + styleUrl: './app.component.scss', +}) +export class AppComponent { + build = build; + title = 'bizmatch'; + actualRoute = ''; + + public constructor(public loadingService: LoadingService, private router: Router, private activatedRoute: ActivatedRoute, private userService: UserService, private confirmationService: ConfirmationService) { + this.router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe(() => { + let currentRoute = this.activatedRoute.root; + while (currentRoute.children[0] !== undefined) { + currentRoute = currentRoute.children[0]; + } + this.actualRoute = currentRoute.snapshot.url[0].path; + }); + } + ngOnInit() {} + + @HostListener('window:keydown', ['$event']) + handleKeyboardEvent(event: KeyboardEvent) { + if (event.shiftKey && event.ctrlKey && event.key === 'V') { + this.showVersionDialog(); + } + } + + showVersionDialog() { + this.confirmationService.showConfirmation({ + message: `App Version: ${this.build.timestamp}`, + buttons: 'none', + }); + } +} diff --git a/bizmatch-client/src/app/app.config.server.ts b/bizmatch-client/src/app/app.config.server.ts new file mode 100644 index 0000000..3514d3a --- /dev/null +++ b/bizmatch-client/src/app/app.config.server.ts @@ -0,0 +1,11 @@ +import { mergeApplicationConfig, ApplicationConfig } from '@angular/core'; +import { provideServerRendering } from '@angular/platform-server'; +import { appConfig } from './app.config'; + +const serverConfig: ApplicationConfig = { + providers: [ + provideServerRendering(), + ] +}; + +export const config = mergeApplicationConfig(appConfig, serverConfig); diff --git a/bizmatch-client/src/app/app.config.ts b/bizmatch-client/src/app/app.config.ts new file mode 100644 index 0000000..dc77c4c --- /dev/null +++ b/bizmatch-client/src/app/app.config.ts @@ -0,0 +1,48 @@ +import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; +import { APP_INITIALIZER, ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; +import { initializeApp, provideFirebaseApp } from '@angular/fire/app'; +import { provideClientHydration, withEventReplay } from '@angular/platform-browser'; +import { provideRouter, withEnabledBlockingInitialNavigation, withInMemoryScrolling } from '@angular/router'; +import { environment } from '../environments/environment'; +import { routes } from './app.routes'; +import { LoadingInterceptor } from './interceptors/loading.interceptor'; +import { TimeoutInterceptor } from './interceptors/timeout.interceptor'; +import { SelectOptionsService } from './services/select-options.service'; + +export const appConfig: ApplicationConfig = { + providers: [ + provideHttpClient(withInterceptorsFromDi()), + { + provide: APP_INITIALIZER, + useFactory: initServices, + multi: true, + deps: [SelectOptionsService], + }, + { + provide: HTTP_INTERCEPTORS, + useClass: LoadingInterceptor, + multi: true, + }, + { + provide: HTTP_INTERCEPTORS, + useClass: TimeoutInterceptor, + multi: true, + }, + provideZoneChangeDetection({ eventCoalescing: true }), + provideRouter( + routes, + withEnabledBlockingInitialNavigation(), + withInMemoryScrolling({ + scrollPositionRestoration: 'enabled', + anchorScrolling: 'enabled', + }), + ), + provideClientHydration(withEventReplay()), + provideFirebaseApp(() => initializeApp(environment.firebaseConfig)), + ], +}; +function initServices(selectOptions: SelectOptionsService) { + return async () => { + await selectOptions.init(); + }; +} diff --git a/bizmatch-client/src/app/app.routes.ts b/bizmatch-client/src/app/app.routes.ts new file mode 100644 index 0000000..f52d8a8 --- /dev/null +++ b/bizmatch-client/src/app/app.routes.ts @@ -0,0 +1,93 @@ +import { Routes } from '@angular/router'; +import { AuthGuard } from './guards/auth.guard'; +import { AccountComponent } from './pages/account/account.component'; +import { BusinessListingsComponent } from './pages/business-listings/business-listings.component'; +import { DetailsBusinessListingComponent } from './pages/details-business-listing/details-business-listing.component'; +import { EditBusinessListingComponent } from './pages/edit-business-listing/edit-business-listing.component'; +import { EmailAuthorizedComponent } from './pages/email-authorized/email-authorized.component'; +import { EmailUsComponent } from './pages/email-us/email-us.component'; +import { EmailVerificationComponent } from './pages/email-verification/email-verification.component'; +import { FavoritesComponent } from './pages/favorites/favorites.component'; +import { HomeComponent } from './pages/home/home.component'; +import { LoginRegisterComponent } from './pages/login-register/login-register.component'; +import { LogoutComponent } from './pages/logout/logout.component'; +import { MyListingComponent } from './pages/my-listing/my-listing.component'; +import { NotFoundComponent } from './pages/not-found/not-found.component'; +import { UserListComponent } from './pages/user-list/user-list.component'; + +export const routes: Routes = [ + { + path: 'businessListings', + component: BusinessListingsComponent, + }, + { + path: 'home', + component: HomeComponent, + }, + { + path: 'details-business-listing/:id', + component: DetailsBusinessListingComponent, + }, + { + path: 'createBusinessListing', + component: EditBusinessListingComponent, + canActivate: [AuthGuard], + }, + { + path: 'login/:page', + component: LoginRegisterComponent, + }, + { + path: 'login', + component: LoginRegisterComponent, + }, + { + path: 'notfound', + component: NotFoundComponent, + }, + { + path: 'account', + component: AccountComponent, + canActivate: [AuthGuard], + }, + { + path: 'editBusinessListing/:id', + component: EditBusinessListingComponent, + canActivate: [AuthGuard], + }, + + { + path: 'myListings', + component: MyListingComponent, + canActivate: [AuthGuard], + }, + { + path: 'myFavorites', + component: FavoritesComponent, + canActivate: [AuthGuard], + }, + { + path: 'emailUs', + component: EmailUsComponent, + // canActivate: [AuthGuard], + }, + { + path: 'logout', + component: LogoutComponent, + canActivate: [AuthGuard], + }, + { + path: 'emailVerification', + component: EmailVerificationComponent, + }, + { + path: 'email-authorized', + component: EmailAuthorizedComponent, + }, + { + path: 'admin/users', + component: UserListComponent, + canActivate: [AuthGuard], + }, + { path: '**', redirectTo: 'home' }, +]; diff --git a/bizmatch-client/src/app/components/base-input/base-input.component.ts b/bizmatch-client/src/app/components/base-input/base-input.component.ts new file mode 100644 index 0000000..ea6bb21 --- /dev/null +++ b/bizmatch-client/src/app/components/base-input/base-input.component.ts @@ -0,0 +1,56 @@ +import { Component, Input } from '@angular/core'; +import { ControlValueAccessor } from '@angular/forms'; + +import { Subscription } from 'rxjs'; +import { ValidationMessagesService } from '../validation-messages.service'; + +@Component({ + selector: 'app-base-input', + template: ``, + imports: [], +}) +export abstract class BaseInputComponent implements ControlValueAccessor { + @Input() value: any = ''; + validationMessage: string = ''; + onChange: any = () => {}; + onTouched: any = () => {}; + subscription: Subscription | null = null; + @Input() label: string = ''; + // @Input() id: string = ''; + @Input() name: string = ''; + isTooltipVisible = false; + constructor(protected validationMessagesService: ValidationMessagesService) {} + ngOnInit() { + this.subscription = this.validationMessagesService.messages$.subscribe(() => { + this.updateValidationMessage(); + }); + } + + ngOnDestroy() { + if (this.subscription) { + this.subscription.unsubscribe(); + } + } + writeValue(value: any): void { + if (value !== undefined) { + this.value = value; + } + } + + registerOnChange(fn: any): void { + this.onChange = fn; + } + + registerOnTouched(fn: any): void { + this.onTouched = fn; + } + updateValidationMessage(): void { + this.validationMessage = this.validationMessagesService.getMessage(this.name); + } + setDisabledState?(isDisabled: boolean): void {} + toggleTooltip(event: Event) { + event.preventDefault(); + event.stopPropagation(); + this.isTooltipVisible = !this.isTooltipVisible; + } +} diff --git a/bizmatch-client/src/app/components/confirmation.component.ts b/bizmatch-client/src/app/components/confirmation.component.ts new file mode 100644 index 0000000..5f0a807 --- /dev/null +++ b/bizmatch-client/src/app/components/confirmation.component.ts @@ -0,0 +1,54 @@ +import { AsyncPipe, NgIf } from '@angular/common'; +import { Component } from '@angular/core'; +import { ConfirmationService } from '../services/confirmation.service'; + +@Component({ + selector: 'app-confirmation', + imports: [AsyncPipe, NgIf], + template: ` +
+
+
+ +
+ + @let confirmation = (confirmationService.confirmation$ | async); +

+ {{ confirmation?.message }} +

+ @if(confirmation?.buttons==='both'){ + + + } +
+
+
+
+ `, +}) +export class ConfirmationComponent { + constructor(public confirmationService: ConfirmationService) {} +} diff --git a/bizmatch-client/src/app/components/email/email.component.html b/bizmatch-client/src/app/components/email/email.component.html new file mode 100644 index 0000000..a68bcbb --- /dev/null +++ b/bizmatch-client/src/app/components/email/email.component.html @@ -0,0 +1,43 @@ + +
+
+ +
+ +
+

Email listing to a friend

+ +
+ +
+
+
+ +
+
+ +
+
+ +
+ + +
+
+
+
+
diff --git a/bizmatch-client/src/app/components/email/email.component.ts b/bizmatch-client/src/app/components/email/email.component.ts new file mode 100644 index 0000000..e2aa94f --- /dev/null +++ b/bizmatch-client/src/app/components/email/email.component.ts @@ -0,0 +1,40 @@ +import { CommonModule } from '@angular/common'; +import { Component } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; +import { ShareByEMail } from '../../../../../bizmatch-server/src/models/db.model'; +import { MailService } from '../../services/mail.service'; +import { ValidatedInputComponent } from '../validated-input/validated-input.component'; +import { ValidationMessagesService } from '../validation-messages.service'; +import { EMailService } from './email.service'; + +@UntilDestroy() +@Component({ + selector: 'app-email', + standalone: true, + imports: [CommonModule, FormsModule, ValidatedInputComponent], + templateUrl: './email.component.html', + template: ``, +}) +export class EMailComponent { + shareByEMail: ShareByEMail = {}; + constructor(public eMailService: EMailService, private mailService: MailService, private validationMessagesService: ValidationMessagesService) {} + ngOnInit() { + this.eMailService.shareByEMail$.pipe(untilDestroyed(this)).subscribe(val => { + this.shareByEMail = val; + }); + } + async sendMail() { + try { + const result = await this.mailService.mailToFriend(this.shareByEMail); + this.eMailService.accept(this.shareByEMail); + } catch (error) { + if (error.error && Array.isArray(error.error?.message)) { + this.validationMessagesService.updateMessages(error.error.message); + } + } + } + ngOnDestroy() { + this.validationMessagesService.clearMessages(); // Löschen Sie alle bestehenden Validierungsnachrichten + } +} diff --git a/bizmatch-client/src/app/components/email/email.service.ts b/bizmatch-client/src/app/components/email/email.service.ts new file mode 100644 index 0000000..4804283 --- /dev/null +++ b/bizmatch-client/src/app/components/email/email.service.ts @@ -0,0 +1,33 @@ +import { Injectable } from '@angular/core'; +import { Observable, Subject } from 'rxjs'; +import { ShareByEMail } from '../../../../../bizmatch-server/src/models/db.model'; + +@Injectable({ + providedIn: 'root', +}) +export class EMailService { + private modalVisibleSubject = new Subject(); + private shareByEMailSubject = new Subject(); + private resolvePromise!: (value: boolean | ShareByEMail) => void; + + modalVisible$: Observable = this.modalVisibleSubject.asObservable(); + shareByEMail$: Observable = this.shareByEMailSubject.asObservable(); + + showShareByEMail(shareByEMail: ShareByEMail): Promise { + this.shareByEMailSubject.next(shareByEMail); + this.modalVisibleSubject.next(true); + return new Promise(resolve => { + this.resolvePromise = resolve; + }); + } + + accept(value: ShareByEMail): void { + this.modalVisibleSubject.next(false); + this.resolvePromise(value); + } + + reject(): void { + this.modalVisibleSubject.next(false); + this.resolvePromise(false); + } +} diff --git a/bizmatch-client/src/app/components/footer/footer.component.html b/bizmatch-client/src/app/components/footer/footer.component.html new file mode 100644 index 0000000..88ceeac --- /dev/null +++ b/bizmatch-client/src/app/components/footer/footer.component.html @@ -0,0 +1,1049 @@ + + + +
+
+
+
+

BizMatch

+

Your trusted partner in business brokerage.

+

TREC License #0516 788

+
+ +
+

Quick Links

+ +
+ +
+

Contact Us

+

1001 Blucher Street

+

Corpus Christi, TX 78401

+

United States

+

1-800-840-6025

+

info@bizmatch.net

+
+
+ +
+

© 2025 BizMatch. All rights reserved.

+
+
+
+
+
+ + Privacy Statement +
+ +
+
+
+
+

+ Privacy Policy
+ We are committed to protecting your privacy. We have established this statement as a testament to our commitment to your privacy. +

+

This Privacy Policy relates to the use of any personal information you provide to us through this websites.

+

+ By accepting the Privacy Policy during registration or the sending of an enquiry, you expressly consent to our collection, storage, use and disclosure of your personal information as described in this Privacy + Policy. +

+

+ We may update our Privacy Policy from time to time. Our Privacy Policy was last updated in Febuary 2018 and is effective upon acceptance for new users. By continuing to use our websites or otherwise + continuing to deal with us, you accept this Privacy Policy. +

+

+ Collection of personal information
+ Anyone can browse our websites without revealing any personally identifiable information. +

+

However, should you wish to contact a business for sale, a franchise opportunity or an intermediary, we will require you to provide some personal information.

+

Should you wish to advertise your services, your business (es) or your franchise opportunity, we will require you to provide some personal information.

+

By providing personal information, you are consenting to the transfer and storage of that information on our servers located in the United States.

+

We may collect and store the following personal information:

+

+ Your name, email address, physical address, telephone numbers, and (depending on the service used), your business information, financial information, such as credit / payment card details;
+ transactional information based on your activities on the site; information that you disclose in a forum on any of our websites, feedback, correspondence through our websites, and correspondence sent to + us;
+ other information from your interaction with our websites, services, content and advertising, including computer and connection information, statistics on page views, traffic to and from the sites, ad data, + IP address and standard web log information;
+ supplemental information from third parties (for example, if you incur a debt, we will generally conduct a credit check by obtaining additional information about you from a credit bureau, as permitted by law; + or if the information you provide cannot be verified,
+ we may ask you to send us additional information, or to answer additional questions online to help verify your information). +

+

+ How we use your information
+ The primary reason we collect your personal information is to improve the services we deliver to you through our website. By registering or sending an enquiry through our website, you agree that we may use + your personal information to:
+ provide the services and customer support you request;
+ connect you with relevant parties:
+ If you are a buyer we will pass some or all of your details on to the seller / intermediary along with any message you have typed. This allows the seller to contact you in order to pursue a possible sale of a + business;
+ If you are a seller / intermediary, we will disclose your details where you have given us permission to do so;
+ resolve disputes, collect fees, and troubleshoot problems;
+ prevent potentially prohibited or illegal activities, and enforce our Terms and Conditions;
+ customize, measure and improve our services, conduct internal market research, provide content and advertising;
+ tell you about other Biz-Match products and services, target marketing, send you service updates, and promotional offers based on your communication preferences. +

+

+ Our disclosure of your information
+ We may disclose personal information to respond to legal requirements, enforce our policies, respond to claims that a listing or other content infringes the rights of others, or protect anyone’s rights, + property, or safety. +

+

+ We may also share your personal information with
+ When you select to register an account as a business buyer, you provide your personal details and we will pass this on to a seller of a business or franchise when you request more information. +

+

+ When you select to register an account as a business broker or seller on the site, we provide a public platform on which to establish your business profile. This profile consists of pertinent facts about your + business along with your personal information; namely, the contact information you provide to facilitate contact between you and other users’ of the site. Direct email addresses and telephone numbers will not + be publicly displayed unless you specifically include it on your profile. +

+

+ The information a user includes within the forums provided on the site is publicly available to other users’ of the site. Please be aware that any personal information you elect to provide in a public forum + may be used to send you unsolicited messages; we are not responsible for the personal information a user elects to disclose within their public profile, or in the private communications that users’ engage in + on the site. +

+

+ We post testimonials on the site obtained from users’. These testimonials may include the name, city, state or region and business of the user. We obtain permission from our users’ prior to posting their + testimonials on the site. We are not responsible for any personal information a user selects to include within their testimonial. +

+

+ When you elect to email a friend about the site, or a particular business, we request the third party’s email address to send this one time email. We do not share this information with any third parties for + their promotional purposes and only store the information to gauge the effectiveness of our referral program. +

+

We may share your personal information with our service providers where necessary. We employ the services of a payment processor to fulfil payment for services purchased on the site.

+

+ We works with a number of partners or affiliates, where we provide marketing services for these companies. These third party agents collect your personal information to facilitate your service request and the + information submitted here is governed by their privacy policy. +

+

+ Masking Policy
+ In some cases, where the third party agent collects your information, the affiliate portal may appear within a BizMatch.net frame. It is presented as a BizMatch.net page for a streamlined user interface + however the data collected on such pages is governed by the third party agent’s privacy policy. +

+

+ Legal Disclosure
+ In certain circumstances, we may be legally required to disclose information collected on the site to law enforcement, government agencies or other third parties. We reserve the right to disclose information + to our service providers and to law enforcement or government agencies where a formal request such as in response to a court order, subpoena or judicial proceeding is made. Where we believe in good faith that + disclosure of information is necessary to prevent imminent physical or financial harm, or loss, or in protecting against illegal activity on the site, we reserve to disclose information. +

+

+ Should the company undergo the merger, acquisition or sale of some or all of its assets, your personal information may likely be a part of the transferred assets. In such an event, your personal information + on the site, would be governed by this privacy statement; any changes to the privacy practices governing your information as a result of transfer would be relayed to you by means of a prominent notice on the + Site, or by email. +

+

+ Using information from BizMatch.net website
+ In certain cases, (where you are receiving contact details of buyers interested in your business opportunity or a business opportunity you represent), you must comply with data protection laws, and give other + users a chance to remove themselves from your database and a chance to review what information you have collected about them. +

+

+ You agree to use BizMatch.net user information only for: +

+

+ BizMatch.net transaction-related purposes that are not unsolicited commercial messages;
+ using services offered through BizMatch.net, or
+ other purposes that a user expressly chooses. +

+

+ Marketing
+ We do not sell or rent your personal information to third parties for their marketing purposes without your explicit consent. Where you explicitly express your consent at the point of collection to receive + offers from third party partners or affiliates, we will communicate to you on their behalf. We will not pass your information on. +

+

+ You will receive email marketing communications from us throughout the duration of your relationship with our websites. If you do not wish to receive marketing communications from us you may unsubscribe and / + or change your preferences at any time by following instructions included within a communication or emailing Customer Services. +

+

If you have an account with one of our websites you can also log in and click the email preferences link to unsubscribe and / or change your preferences.

+

+ Please note that we reserve the right to send all website users notifications and administrative emails where necessary which are considered a part of the service. Given that these messages aren’t promotional + in nature, you will be unable to opt-out of them. +

+

+ Cookies
+ A cookie is a small text file written to your hard drive that contains information about you. Cookies do not contain any personal information about users. Once you close your browser or log out of the + website, the cookie simply terminates. We use cookies so that we can personalise your experience of our websites. +

+

+ If you set up your browser to reject the cookie, you may still use the website however; doing so may interfere with your use of some aspects of our websites. Some of our business partners use cookies on our + site (for example, advertisers). We have no access to or control over these cookies. +

+

For more information about how BizMatch.net uses cookies please read our Cookie Policy.

+

+ Spam, spyware or spoofing
+ We and our users do not tolerate spam. Make sure to set your email preferences so we can communicate with you, as you prefer. Please add us to your safe senders list. To report spam or spoof emails, please + contact us using the contact information provided in the Contact Us section of this privacy statement. +

+

+ You may not use our communication tools to send spam or otherwise send content that would breach our Terms and Conditions. We automatically scan and may manually filter messages to check for spam, viruses, + phishing attacks and other malicious activity or illegal or prohibited content. We may also store these messages for back up purposes only. +

+

+ If you send an email to an email address that is not registered in our community, we do not permanently store that email or use that email address for any marketing purpose. We do not rent or sell these email + addresses. +

+

+ Account protection
+ Your password is the key to your account. Make sure this is stored safely. Use unique numbers, letters and special characters, and do not disclose your password to anyone. If you do share your password or + your personal information with others, remember that you are responsible for all actions taken in the name of your account. If you lose control of your password, you may lose substantial control over your + personal information and may be subject to legally binding actions taken on your behalf. Therefore, if your password has been compromised for any reason, you should immediately notify us and change your + password. +

+

+ Accessing, reviewing and changing your personal information
+ You can view and amend your personal information at any time by logging in to your account online. You must promptly update your personal information if it changes or is inaccurate. +

+

If at any time you wish to close your account, please contact Customer Services and instruct us to do so. We will process your request as soon as we can.

+

You may also contact us at any time to find out what information we hold about you, what we do with it and ask us to update it for you.

+

+ We do retain personal information from closed accounts to comply with law, prevent fraud, collect any fees owed, resolve disputes, troubleshoot problems, assist with any investigations, enforce our Terms and + Conditions, and take other actions otherwise permitted by law. +

+

+ Security
+ Your information is stored on our servers located in the USA. We treat data as an asset that must be protected and use a variety of tools (encryption, passwords, physical security, etc.) to protect your + personal information against unauthorized access and disclosure. However, no method of security is 100% effective and while we take every measure to protect your personal information, we make no guarantees of + its absolute security. +

+

We employ the use of SSL encryption during the transmission of sensitive data across our websites.

+

+ Third parties
+ Except as otherwise expressly included in this Privacy Policy, this document addresses only the use and disclosure of information we collect from you. If you disclose your information to others, whether they + are buyers or sellers on our websites or other sites throughout the internet, different rules may apply to their use or disclosure of the information you disclose to them. Dynamis does not control the privacy + policies of third parties, and you are subject to the privacy policies of those third parties where applicable. +

+

We encourage you to ask questions before you disclose your personal information to others.

+

+ General
+ We may change this Privacy Policy from time to time as we add new products and applications, as we improve our current offerings, and as technologies and laws change. You can determine when this Privacy + Policy was last revised by referring to the “Last Updated” legend at the top of this page. +

+

+ Any changes will become effective upon our posting of the revised Privacy Policy on our affected websites. We will provide notice to you if these changes are material and, where required by applicable law, we + will obtain your consent. This notice may be provided by email, by posting notice of the changes on our affected websites or by other means, consistent with applicable laws. +

+

+ Contact Us
+ If you have any questions or comments about our privacy policy, and you can’t find the answer to your question on our help pages, please contact us using this form or email support@bizmatch.net, or write + to us at BizMatch, 715 S. Tanahua, Corpus Christi, TX 78401.) +

+
+
+
+
+
+
+
+ + Terms of use +
+ +
+
+
+
+ AGREEMENT BETWEEN USER AND BizMatch

+

The BizMatch Web Site is comprised of various Web pages operated by BizMatch.

+

+ The BizMatch Web Site is offered to you conditioned on your acceptance without modification of the terms, conditions, and notices contained herein. Your use of the BizMatch Web Site constitutes your + agreement to all such terms, conditions, and notices. +

+

+ MODIFICATION OF THESE TERMS OF USE +

+

+ BizMatch reserves the right to change the terms, conditions, and notices under which the BizMatch Web Site is offered, including but not limited to the charges associated with the use of the BizMatch Web + Site. +

+

+ LINKS TO THIRD PARTY SITES +

+

+ The BizMatch Web Site may contain links to other Web Sites ("Linked Sites"). The Linked Sites are not under the control of BizMatch and BizMatch is not responsible for the contents of any Linked Site, + including without limitation any link contained in a Linked Site, or any changes or updates to a Linked Site. BizMatch is not responsible for webcasting or any other form of transmission received from any + Linked Site. BizMatch is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement by BizMatch of the site or any association with its operators. +

+

+ NO UNLAWFUL OR PROHIBITED USE +

+

+ As a condition of your use of the BizMatch Web Site, you warrant to BizMatch that you will not use the BizMatch Web Site for any purpose that is unlawful or prohibited by these terms, conditions, and + notices. You may not use the BizMatch Web Site in any manner which could damage, disable, overburden, or impair the BizMatch Web Site or interfere with any other party’s use and enjoyment of the BizMatch + Web Site. You may not obtain or attempt to obtain any materials or information through any means not intentionally made available or provided for through the BizMatch Web Sites. +

+

+ USE OF COMMUNICATION SERVICES +

+

+ The BizMatch Web Site may contain bulletin board services, chat areas, news groups, forums, communities, personal web pages, calendars, and/or other message or communication facilities designed to enable + you to communicate with the public at large or with a group (collectively, "Communication Services"), you agree to use the Communication Services only to post, send and receive messages and material that + are proper and related to the particular Communication Service. By way of example, and not as a limitation, you agree that when using a Communication Service, you will not: +

+

 

+

+

+ §  Defame, abuse, harass, stalk, threaten or otherwise violate the legal rights (such as rights of privacy and publicity) of others. +

+

 

+

+ §  Publish, post, upload, distribute or disseminate any inappropriate, profane, defamatory, infringing, obscene, indecent or unlawful topic, name, material or information. +

+

+ §  Upload files that contain software or other material protected by intellectual property laws (or by rights of privacy of publicity) unless you own or control the rights thereto or have received all + necessary consents. +

+

+ §  Upload files that contain viruses, corrupted files, or any other similar software or programs that may damage the operation of another’s computer. +

+

+ §  Advertise or offer to sell or buy any goods or services for any business purpose, unless such Communication Service specifically allows such messages. +

+

+ §  Conduct or forward surveys, contests, pyramid schemes or chain letters. +

+

+ §  Download any file posted by another user of a Communication Service that you know, or reasonably should know, cannot be legally distributed in such manner. +

+

+ §  Falsify or delete any author attributions, legal or other proper notices or proprietary designations or labels of the origin or source of software or other material contained in a file that is + uploaded. +

+

+ §  Restrict or inhibit any other user from using and enjoying the Communication Services. +

+

+ §  Violate any code of conduct or other guidelines which may be applicable for any particular Communication Service. +

+

+ §  Harvest or otherwise collect information about others, including e-mail addresses, without their consent. +

+

+ §  Violate any applicable laws or regulations. +

+

+ BizMatch has no obligation to monitor the Communication Services. However, BizMatch reserves the right to review materials posted to a Communication Service and to remove any materials in its sole + discretion. BizMatch reserves the right to terminate your access to any or all of the Communication Services at any time without notice for any reason whatsoever. +

+

+ BizMatch reserves the right at all times to disclose any information as necessary to satisfy any applicable law, regulation, legal process or governmental request, or to edit, refuse to post or to remove + any information or materials, in whole or in part, in BizMatch’s sole discretion. +

+

+ Always use caution when giving out any personally identifying information about yourself or your children in any Communication Service. BizMatch does not control or endorse the content, messages or + information found in any Communication Service and, therefore, BizMatch specifically disclaims any liability with regard to the Communication Services and any actions resulting from your participation in + any Communication Service. Managers and hosts are not authorized BizMatch spokespersons, and their views do not necessarily reflect those of BizMatch. +

+

+ Materials uploaded to a Communication Service may be subject to posted limitations on usage, reproduction and/or dissemination. You are responsible for adhering to such limitations if you download the + materials. +

+

+ MATERIALS PROVIDED TO BizMatch OR POSTED AT ANY BizMatch WEB SITE +

+

+ BizMatch does not claim ownership of the materials you provide to BizMatch (including feedback and suggestions) or post, upload, input or submit to any BizMatch Web Site or its associated services + (collectively "Submissions"). However, by posting, uploading, inputting, providing or submitting your Submission you are granting BizMatch, its affiliated companies and necessary sublicensees permission + to use your Submission in connection with the operation of their Internet businesses including, without limitation, the rights to: copy, distribute, transmit, publicly display, publicly perform, + reproduce, edit, translate and reformat your Submission; and to publish your name in connection with your Submission. +

+

+ No compensation will be paid with respect to the use of your Submission, as provided herein. BizMatch is under no obligation to post or use any Submission you may provide and may remove any Submission at + any time in BizMatch’s sole discretion. +

+

+ By posting, uploading, inputting, providing or submitting your Submission you warrant and represent that you own or otherwise control all of the rights to your Submission as described in this section + including, without limitation, all the rights necessary for you to provide, post, upload, input or submit the Submissions. +

+

+ LIABILITY DISCLAIMER +

+

+ THE INFORMATION, SOFTWARE, PRODUCTS, AND SERVICES INCLUDED IN OR AVAILABLE THROUGH THE BizMatch WEB SITE MAY INCLUDE INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE + INFORMATION HEREIN. BizMatch AND/OR ITS SUPPLIERS MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE BizMatch WEB SITE AT ANY TIME. ADVICE RECEIVED VIA THE BizMatch WEB SITE SHOULD NOT BE RELIED UPON FOR + PERSONAL, MEDICAL, LEGAL OR FINANCIAL DECISIONS AND YOU SHOULD CONSULT AN APPROPRIATE PROFESSIONAL FOR SPECIFIC ADVICE TAILORED TO YOUR SITUATION. +

+

+ BizMatch AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY, RELIABILITY, AVAILABILITY, TIMELINESS, AND ACCURACY OF THE INFORMATION, SOFTWARE, PRODUCTS, SERVICES AND RELATED GRAPHICS + CONTAINED ON THE BizMatch WEB SITE FOR ANY PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, ALL SUCH INFORMATION, SOFTWARE, PRODUCTS, SERVICES AND RELATED GRAPHICS ARE PROVIDED "AS IS" WITHOUT + WARRANTY OR CONDITION OF ANY KIND. BizMatch AND/OR ITS SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS INFORMATION, SOFTWARE, PRODUCTS, SERVICES AND RELATED GRAPHICS, INCLUDING + ALL IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. +

+

+ TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL BizMatch AND/OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL, CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE, DATA OR PROFITS, ARISING OUT OF OR IN ANY WAY CONNECTED WITH THE USE OR PERFORMANCE OF THE BizMatch WEB SITE, WITH THE DELAY OR INABILITY + TO USE THE BizMatch WEB SITE OR RELATED SERVICES, THE PROVISION OF OR FAILURE TO PROVIDE SERVICES, OR FOR ANY INFORMATION, SOFTWARE, PRODUCTS, SERVICES AND RELATED GRAPHICS OBTAINED THROUGH THE BizMatch + WEB SITE, OR OTHERWISE ARISING OUT OF THE USE OF THE BizMatch WEB SITE, WHETHER BASED ON CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY OR OTHERWISE, EVEN IF BizMatch OR ANY OF ITS SUPPLIERS HAS BEEN + ADVISED OF THE POSSIBILITY OF DAMAGES. BECAUSE SOME STATES/JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY + TO YOU. IF YOU ARE DISSATISFIED WITH ANY PORTION OF THE BizMatch WEB SITE, OR WITH ANY OF THESE TERMS OF USE, YOUR SOLE AND EXCLUSIVE REMEDY IS TO DISCONTINUE USING THE BizMatch WEB SITE. +

+

SERVICE CONTACT : info@bizmatch.net

+

+ TERMINATION/ACCESS RESTRICTION +

+

+ BizMatch reserves the right, in its sole discretion, to terminate your access to the BizMatch Web Site and the related services or any portion thereof at any time, without notice. GENERAL To the maximum + extent permitted by law, this agreement is governed by the laws of the State of Washington, U.S.A. and you hereby consent to the exclusive jurisdiction and venue of courts in King County, Washington, + U.S.A. in all disputes arising out of or relating to the use of the BizMatch Web Site. Use of the BizMatch Web Site is unauthorized in any jurisdiction that does not give effect to all provisions of these + terms and conditions, including without limitation this paragraph. You agree that no joint venture, partnership, employment, or agency relationship exists between you and BizMatch as a result of this + agreement or use of the BizMatch Web Site. BizMatch’s performance of this agreement is subject to existing laws and legal process, and nothing contained in this agreement is in derogation of BizMatch’s + right to comply with governmental, court and law enforcement requests or requirements relating to your use of the BizMatch Web Site or information provided to or gathered by BizMatch with respect to such + use. If any part of this agreement is determined to be invalid or unenforceable pursuant to applicable law including, but not limited to, the warranty disclaimers and liability limitations set forth + above, then the invalid or unenforceable provision will be deemed superseded by a valid, enforceable provision that most closely matches the intent of the original provision and the remainder of the + agreement shall continue in effect. Unless otherwise specified herein, this agreement constitutes the entire agreement between the user and BizMatch with respect to the BizMatch Web Site and it supersedes + all prior or contemporaneous communications and proposals, whether electronic, oral or written, between the user and BizMatch with respect to the BizMatch Web Site. A printed version of this agreement and + of any notice given in electronic form shall be admissible in judicial or administrative proceedings based upon or relating to this agreement to the same extent an d subject to the same conditions as + other business documents and records originally generated and maintained in printed form. It is the express wish to the parties that this agreement and all related documents be drawn up in English. +

+

+ COPYRIGHT AND TRADEMARK NOTICES: +

+

All contents of the BizMatch Web Site are: Copyright 2011 by Bizmatch Business Solutions and/or its suppliers. All rights reserved.

+

+ TRADEMARKS +

+

The names of actual companies and products mentioned herein may be the trademarks of their respective owners.

+

+ The example companies, organizations, products, people and events depicted herein are fictitious. No association with any real company, organization, product, person, or event is intended or should be + inferred. +

+

Any rights not expressly granted herein are reserved.

+

+ NOTICES AND PROCEDURE FOR MAKING CLAIMS OF COPYRIGHT INFRINGEMENT +

+

+ Pursuant to Title 17, United States Code, Section 512(c)(2), notifications of claimed copyright infringement under United States copyright law should be sent to Service Provider’s Designated Agent. ALL + INQUIRIES NOT RELEVANT TO THE FOLLOWING PROCEDURE WILL RECEIVE NO RESPONSE. See Notice and Procedure for Making Claims of Copyright Infringement.
+

+

 

+

+ We reserve the right to update or revise these Terms of Use at any time without notice. Please check the Terms of Use periodically for changes. The revised terms will be effective immediately as + soon as they are posted on the WebSite and by continuing to use the Site you agree to be bound by the revised terms

+
+
+
+
+
+ + + diff --git a/bizmatch-client/src/app/components/footer/footer.component.scss b/bizmatch-client/src/app/components/footer/footer.component.scss new file mode 100644 index 0000000..db345dd --- /dev/null +++ b/bizmatch-client/src/app/components/footer/footer.component.scss @@ -0,0 +1,20 @@ +:host { + width: 100%; +} + +@media (max-width: 1023px) { + .order-2 { + order: 2; + } + .order-3 { + order: 3; + } +} +section p { + display: block; + margin-block-start: 1em; + margin-block-end: 1em; + margin-inline-start: 0px; + margin-inline-end: 0px; + unicode-bidi: isolate; +} diff --git a/bizmatch-client/src/app/components/footer/footer.component.ts b/bizmatch-client/src/app/components/footer/footer.component.ts new file mode 100644 index 0000000..a7b9c47 --- /dev/null +++ b/bizmatch-client/src/app/components/footer/footer.component.ts @@ -0,0 +1,21 @@ +import { CommonModule } from '@angular/common'; +import { Component } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { Router, RouterModule } from '@angular/router'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; + +@Component({ + selector: 'app-footer', + standalone: true, + imports: [CommonModule, FormsModule, RouterModule, FontAwesomeModule], + templateUrl: './footer.component.html', + styleUrl: './footer.component.scss', +}) +export class FooterComponent { + privacyVisible = false; + termsVisible = false; + currentYear: number = new Date().getFullYear(); + isHomeRoute = false; + constructor(private router: Router) {} + ngOnInit() {} +} diff --git a/bizmatch-client/src/app/components/header/header.component.html b/bizmatch-client/src/app/components/header/header.component.html new file mode 100644 index 0000000..2b7ebc6 --- /dev/null +++ b/bizmatch-client/src/app/components/header/header.component.html @@ -0,0 +1,124 @@ + diff --git a/bizmatch-client/src/app/components/header/header.component.scss b/bizmatch-client/src/app/components/header/header.component.scss new file mode 100644 index 0000000..27df88c --- /dev/null +++ b/bizmatch-client/src/app/components/header/header.component.scss @@ -0,0 +1,13 @@ +::ng-deep p-menubarsub{ + margin-left: auto; +} +::ng-deep .p-tabmenu .p-tabmenu-nav .p-tabmenuitem .p-menuitem-link{ + border:1px solid #ffffff; +} +::ng-deep .p-tabmenu .p-tabmenu-nav .p-tabmenuitem.p-highlight .p-menuitem-link { + border-bottom: 2px solid #3B82F6 !important; +} +::ng-deep .p-menubar{ + border:unset; + background: unset; +} \ No newline at end of file diff --git a/bizmatch-client/src/app/components/header/header.component.ts b/bizmatch-client/src/app/components/header/header.component.ts new file mode 100644 index 0000000..688763f --- /dev/null +++ b/bizmatch-client/src/app/components/header/header.component.ts @@ -0,0 +1,200 @@ +import { BreakpointObserver } from '@angular/cdk/layout'; +import { CommonModule } from '@angular/common'; +import { Component, HostListener } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { NavigationEnd, Router, RouterModule } from '@angular/router'; +import { faUserGear } from '@fortawesome/free-solid-svg-icons'; +import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; +import { debounceTime, filter, Observable, Subject, Subscription } from 'rxjs'; +import { SortByOptions, User } from '../../../../../bizmatch-server/src/models/db.model'; +import { BusinessListingCriteria, emailToDirName, KeycloakUser, KeyValueAsSortBy } from '../../../../../bizmatch-server/src/models/main.model'; +import { environment } from '../../../environments/environment'; + +import { SharedService } from '../../services/shared.service'; + +import { Collapse, Dropdown } from 'flowbite'; +import { AuthService } from '../../services/auth.service'; +import { CriteriaChangeService } from '../../services/criteria-change.service'; +import { ListingsService } from '../../services/listings.service'; +import { ModalService } from '../../services/modal.service'; +import { SearchService } from '../../services/search.service'; +import { SelectOptionsService } from '../../services/select-options.service'; +import { UserService } from '../../services/user.service'; +import { assignProperties, compareObjects, createEmptyBusinessListingCriteria, getCriteriaProxy, map2User } from '../../utils/utils'; +@UntilDestroy() +@Component({ + selector: 'header', + imports: [CommonModule, RouterModule, FormsModule], + templateUrl: './header.component.html', + styleUrl: './header.component.scss', +}) +export class HeaderComponent { + public buildVersion = environment.buildVersion; + user$: Observable; + keycloakUser: KeycloakUser; + user: User; + activeItem; + faUserGear = faUserGear; + profileUrl: string; + env = environment; + private filterDropdown: Dropdown | null = null; + isMobile: boolean = false; + private destroy$ = new Subject(); + prompt: string; + private subscription: Subscription; + criteria: BusinessListingCriteria; + private routerSubscription: Subscription | undefined; + baseRoute: string; + sortDropdownVisible: boolean; + sortByOptions: KeyValueAsSortBy[] = []; + numberOfBroker$: Observable; + numberOfCommercial$: Observable; + constructor( + private router: Router, + private userService: UserService, + private sharedService: SharedService, + private breakpointObserver: BreakpointObserver, + private modalService: ModalService, + private searchService: SearchService, + private criteriaChangeService: CriteriaChangeService, + public selectOptions: SelectOptionsService, + public authService: AuthService, + private listingService: ListingsService, + ) {} + @HostListener('document:click', ['$event']) + handleGlobalClick(event: Event) { + const target = event.target as HTMLElement; + if (target.id !== 'sortDropdownButton' && target.id !== 'sortDropdownMobileButton') { + this.sortDropdownVisible = false; + } + } + async ngOnInit() { + const token = await this.authService.getToken(); + this.keycloakUser = map2User(token); + if (this.keycloakUser) { + 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.sharedService.currentProfilePhoto.subscribe(photoUrl => { + this.profileUrl = photoUrl; + }); + + this.checkCurrentRoute(this.router.url); + this.setupSortByOptions(); + + this.routerSubscription = this.router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe((event: any) => { + this.checkCurrentRoute(event.urlAfterRedirects); + this.setupSortByOptions(); + }); + this.subscription = this.criteriaChangeService.criteriaChange$.pipe(debounceTime(400)).subscribe(() => { + this.criteria = getCriteriaProxy(this.baseRoute, this); + }); + this.userService.currentUser.pipe(untilDestroyed(this)).subscribe(u => { + this.user = u; + }); + } + private checkCurrentRoute(url: string): void { + this.baseRoute = url.split('/')[1]; // Nimmt den ersten Teil der Route nach dem ersten '/' + const specialRoutes = [, '', '']; + this.criteria = getCriteriaProxy(this.baseRoute, this); + // this.searchService.search(this.criteria); + } + setupSortByOptions() { + this.sortByOptions = []; + if (this.isProfessionalListing()) { + this.sortByOptions = [...this.sortByOptions, ...this.selectOptions.sortByOptions.filter(s => s.type === 'professional')]; + } + if (this.isBusinessListing()) { + this.sortByOptions = [...this.sortByOptions, ...this.selectOptions.sortByOptions.filter(s => s.type === 'business' || s.type === 'listing')]; + } + if (this.isCommercialPropertyListing()) { + this.sortByOptions = [...this.sortByOptions, ...this.selectOptions.sortByOptions.filter(s => s.type === 'commercial' || s.type === 'listing')]; + } + this.sortByOptions = [...this.sortByOptions, ...this.selectOptions.sortByOptions.filter(s => !s.type)]; + } + ngAfterViewInit() {} + + async openModal() { + const modalResult = await this.modalService.showModal(this.criteria); + if (modalResult.accepted) { + this.searchService.search(this.criteria); + } else { + this.criteria = assignProperties(this.criteria, modalResult.criteria); + } + } + navigateWithState(dest: string, state: any) { + this.router.navigate([dest], { state: state }); + } + + isActive(route: string): boolean { + return this.router.url === route; + } + isEmailUsUrl(): boolean { + return ['/emailUs'].includes(this.router.url); + } + isFilterUrl(): boolean { + return ['/businessListings', '/commercialPropertyListings', '/brokerListings'].includes(this.router.url); + } + isBusinessListing(): boolean { + return ['/businessListings'].includes(this.router.url); + } + isCommercialPropertyListing(): boolean { + return ['/commercialPropertyListings'].includes(this.router.url); + } + isProfessionalListing(): boolean { + return ['/brokerListings'].includes(this.router.url); + } + // isSortingUrl(): boolean { + // return ['/businessListings', '/commercialPropertyListings'].includes(this.router.url); + // } + closeDropdown() { + const dropdownButton = document.getElementById('user-menu-button'); + const dropdownMenu = this.user ? document.getElementById('user-login') : document.getElementById('user-unknown'); + + if (dropdownButton && dropdownMenu) { + const dropdown = new Dropdown(dropdownMenu, dropdownButton); + dropdown.hide(); + } + } + closeMobileMenu() { + const targetElement = document.getElementById('navbar-user'); + const triggerElement = document.querySelector('[data-collapse-toggle="navbar-user"]'); + + if (targetElement instanceof HTMLElement && triggerElement instanceof HTMLElement) { + const collapse = new Collapse(targetElement, triggerElement); + collapse.collapse(); + } + } + closeMenusAndSetCriteria(path: string) { + this.closeDropdown(); + this.closeMobileMenu(); + const criteria = getCriteriaProxy(path, this); + criteria.page = 1; + criteria.start = 0; + } + + ngOnDestroy() { + this.destroy$.next(); + this.destroy$.complete(); + } + getNumberOfFiltersSet() { + if (this.criteria?.criteriaType === 'businessListings') { + return compareObjects(createEmptyBusinessListingCriteria(), this.criteria, ['start', 'length', 'page', 'searchType', 'radius', 'sortBy']); + } else { + return 0; + } + } + + sortBy(sortBy: SortByOptions) { + this.criteria.sortBy = sortBy; + this.sortDropdownVisible = false; + this.searchService.search(this.criteria); + } + toggleSortDropdown() { + this.sortDropdownVisible = !this.sortDropdownVisible; + } + get isProfessional() { + return this.user?.customerType === 'professional'; + } +} diff --git a/bizmatch-client/src/app/components/image-crop-and-upload/image-crop-and-upload.component.html b/bizmatch-client/src/app/components/image-crop-and-upload/image-crop-and-upload.component.html new file mode 100644 index 0000000..96f03b7 --- /dev/null +++ b/bizmatch-client/src/app/components/image-crop-and-upload/image-crop-and-upload.component.html @@ -0,0 +1,12 @@ + +
+
+

Crop Image

+ +
+ + +
+
+
+ diff --git a/bizmatch-client/src/app/components/image-crop-and-upload/image-crop-and-upload.component.scss b/bizmatch-client/src/app/components/image-crop-and-upload/image-crop-and-upload.component.scss new file mode 100644 index 0000000..667bdef --- /dev/null +++ b/bizmatch-client/src/app/components/image-crop-and-upload/image-crop-and-upload.component.scss @@ -0,0 +1,6 @@ +::ng-deep image-cropper { + justify-content: center; + & > div { + width: unset !important; + } +} diff --git a/bizmatch-client/src/app/components/image-crop-and-upload/image-crop-and-upload.component.ts b/bizmatch-client/src/app/components/image-crop-and-upload/image-crop-and-upload.component.ts new file mode 100644 index 0000000..f4b6f49 --- /dev/null +++ b/bizmatch-client/src/app/components/image-crop-and-upload/image-crop-and-upload.component.ts @@ -0,0 +1,69 @@ +import { CommonModule } from '@angular/common'; +import { Component, ElementRef, Input, output, ViewChild } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { ImageCroppedEvent, ImageCropperComponent } from 'ngx-image-cropper'; +import { UploadParams } from '../../../../../bizmatch-server/src/models/main.model'; +import { ImageService } from '../../services/image.service'; +import { ListingsService } from '../../services/listings.service'; +export interface UploadReponse { + success: boolean; + type: 'uploadPropertyPicture' | 'uploadCompanyLogo' | 'uploadProfile'; +} +@Component({ + selector: 'app-image-crop-and-upload', + standalone: true, + imports: [CommonModule, FormsModule, RouterModule, FontAwesomeModule, ImageCropperComponent], + templateUrl: './image-crop-and-upload.component.html', + styleUrl: './image-crop-and-upload.component.scss', +}) +export class ImageCropAndUploadComponent { + showModal = false; + imageChangedEvent: any = ''; + croppedImage: Blob | null = null; + @Input() uploadParams: UploadParams; + uploadFinished = output(); + @ViewChild('fileInput', { static: true }) fileInput!: ElementRef; + + constructor(private imageService: ImageService, private listingsService: ListingsService) {} + + ngOnInit() {} + ngOnChanges() { + this.openFileDialog(); + } + openFileDialog() { + if (this.uploadParams) { + this.fileInput.nativeElement.click(); + } + } + + fileChangeEvent(event: any): void { + this.imageChangedEvent = event; + this.showModal = true; + } + + imageCropped(event: ImageCroppedEvent) { + this.croppedImage = event.blob; + } + + closeModal() { + this.imageChangedEvent = null; + this.croppedImage = null; + this.showModal = false; + this.fileInput.nativeElement.value = ''; + this.uploadFinished.emit({ success: false, type: this.uploadParams.type }); + } + + async uploadImage() { + if (this.croppedImage) { + await this.imageService.uploadImage(this.croppedImage, this.uploadParams.type, this.uploadParams.imagePath, this.uploadParams.serialId); + this.closeModal(); + this.uploadFinished.emit({ success: true, type: this.uploadParams.type }); + } + } + + loadImageFailed() { + console.error('Load image failed'); + } +} diff --git a/bizmatch-client/src/app/components/message/message-container.component.ts b/bizmatch-client/src/app/components/message/message-container.component.ts new file mode 100644 index 0000000..88273a3 --- /dev/null +++ b/bizmatch-client/src/app/components/message/message-container.component.ts @@ -0,0 +1,35 @@ +import { CommonModule } from '@angular/common'; +import { Component, OnInit } from '@angular/core'; +import { Message, MessageService } from '../../services/message.service'; +import { MessageComponent } from './message.component'; + +@Component({ + selector: 'app-message-container', + standalone: true, + imports: [CommonModule, MessageComponent], + template: ` +
+ + +
+ `, +}) +export class MessageContainerComponent implements OnInit { + messages: Message[] = []; + + constructor(private messageService: MessageService) {} + + ngOnInit(): void { + this.messageService.messages$.subscribe((messages) => { + this.messages = messages; + }); + } + + removeMessage(message: Message): void { + this.messageService.removeMessage(message); + } +} diff --git a/bizmatch-client/src/app/components/message/message.component.ts b/bizmatch-client/src/app/components/message/message.component.ts new file mode 100644 index 0000000..f4c98ba --- /dev/null +++ b/bizmatch-client/src/app/components/message/message.component.ts @@ -0,0 +1,94 @@ +import { animate, style, transition, trigger } from '@angular/animations'; +import { CommonModule } from '@angular/common'; +import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { Message } from '../../services/message.service'; + +@Component({ + selector: 'app-message', + standalone: true, + imports: [CommonModule], + template: ` +
+
{{ message.text }}
+ +
+ `, + animations: [ + trigger('toastAnimation', [ + transition(':enter', [ + style({ transform: 'translateY(100%)', opacity: 0 }), + animate( + '300ms ease-out', + style({ transform: 'translateY(0)', opacity: 1 }) + ), + ]), + transition(':leave', [ + animate( + '300ms ease-in', + style({ transform: 'translateY(100%)', opacity: 0 }) + ), + ]), + ]), + ], +}) +export class MessageComponent { + @Input() message!: Message; + @Output() close = new EventEmitter(); + + onClose(): void { + this.close.emit(); + } + + getClasses(): string { + return `flex items-center w-full max-w-xs p-4 mb-4 text-gray-500 rounded-lg shadow ${this.getSeverityClasses()}`; + } + + getCloseButtonClasses(): string { + switch (this.message.severity) { + case 'success': + return 'text-green-600 hover:bg-green-200 focus:ring-green-400'; + case 'danger': + return 'text-red-600 hover:bg-red-200 focus:ring-red-400'; + case 'warning': + return 'text-yellow-600 hover:bg-yellow-200 focus:ring-yellow-400'; + default: + return 'text-blue-600 hover:bg-blue-200 focus:ring-blue-400'; + } + } + + private getSeverityClasses(): string { + switch (this.message.severity) { + case 'success': + return 'bg-green-100 text-green-700'; + case 'danger': + return 'bg-red-100 text-red-700'; + case 'warning': + return 'bg-yellow-100 text-yellow-700'; + default: + return 'bg-blue-100 text-blue-700'; + } + } +} diff --git a/bizmatch-client/src/app/components/paginator/paginator.component.html b/bizmatch-client/src/app/components/paginator/paginator.component.html new file mode 100644 index 0000000..1c2a7d6 --- /dev/null +++ b/bizmatch-client/src/app/components/paginator/paginator.component.html @@ -0,0 +1 @@ +

paginator works!

diff --git a/bizmatch-client/src/app/components/paginator/paginator.component.scss b/bizmatch-client/src/app/components/paginator/paginator.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/bizmatch-client/src/app/components/paginator/paginator.component.ts b/bizmatch-client/src/app/components/paginator/paginator.component.ts new file mode 100644 index 0000000..6399a64 --- /dev/null +++ b/bizmatch-client/src/app/components/paginator/paginator.component.ts @@ -0,0 +1,98 @@ +import { CommonModule } from '@angular/common'; +import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; + +@Component({ + selector: 'app-paginator', + standalone: true, + imports: [CommonModule], + template: ` + + `, +}) +export class PaginatorComponent implements OnChanges { + @Input() page = 1; + @Input() pageCount = 1; + @Output() pageChange = new EventEmitter(); + + currentPage = 1; + visiblePages: (number | string)[] = []; + + ngOnChanges(changes: SimpleChanges): void { + if (changes['page'] || changes['pageCount']) { + this.currentPage = this.page; + this.updateVisiblePages(); + } + } + + updateVisiblePages(): void { + const totalPages = this.pageCount; + const current = this.currentPage; + + if (totalPages <= 6) { + this.visiblePages = Array.from({ length: totalPages }, (_, i) => i + 1); + } else { + if (current <= 3) { + this.visiblePages = [1, 2, 3, 4, '...', totalPages]; + } else if (current >= totalPages - 2) { + this.visiblePages = [1, '...', totalPages - 3, totalPages - 2, totalPages - 1, totalPages]; + } else { + this.visiblePages = [1, '...', current - 1, current, current + 1, '...', totalPages]; + } + } + } + + onPageChange(page: number | string): void { + if (typeof page === 'string') { + return; + } + if (page >= 1 && page <= this.pageCount && page !== this.currentPage) { + this.currentPage = page; + this.pageChange.emit(page); + this.updateVisiblePages(); + } + } +} diff --git a/bizmatch-client/src/app/components/search-modal/search-modal.component.html b/bizmatch-client/src/app/components/search-modal/search-modal.component.html new file mode 100644 index 0000000..2a44637 --- /dev/null +++ b/bizmatch-client/src/app/components/search-modal/search-modal.component.html @@ -0,0 +1,394 @@ +
+
+
+
+ @if(criteria.criteriaType==='businessListings'){ +

+ Business Listing Search +

+ } @else if (criteria.criteriaType==='commercialPropertyListings'){ +

+ Property Listing Search +

+ } @else { +

+ Professional Listing Search +

+ } + +
+
+
+ + + +
+
+
+
+ + + +
+ + +
+ +
+ + +
+
+ +
+ +
+ @for (radius of [5, 20, 50, 100, 200, 300, 400, 500]; track + radius) { + + } +
+
+ +
+ +
+ + - + +
+
+
+ +
+ + - + + +
+
+
+ +
+ + - + +
+
+
+ + +
+
+
+
+ +
+ @for(tob of selectOptions.typesOfBusiness; track tob){ +
+ + +
+ } +
+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+ + - + +
+
+
+ +
+ + - + +
+
+
+ + +
+
+
+
+
+ + +
+
+
+
diff --git a/bizmatch-client/src/app/components/search-modal/search-modal.component.scss b/bizmatch-client/src/app/components/search-modal/search-modal.component.scss new file mode 100644 index 0000000..79b09a7 --- /dev/null +++ b/bizmatch-client/src/app/components/search-modal/search-modal.component.scss @@ -0,0 +1,9 @@ +:host ::ng-deep .ng-select.custom .ng-select-container { + --tw-bg-opacity: 1; + background-color: rgb(249 250 251 / var(--tw-bg-opacity)); + height: 46px; + border-radius: 0.5rem; + .ng-value-container .ng-input { + top: 10px; + } +} diff --git a/bizmatch-client/src/app/components/search-modal/search-modal.component.ts b/bizmatch-client/src/app/components/search-modal/search-modal.component.ts new file mode 100644 index 0000000..8ac1833 --- /dev/null +++ b/bizmatch-client/src/app/components/search-modal/search-modal.component.ts @@ -0,0 +1,153 @@ +import { AsyncPipe, CommonModule, NgIf } from '@angular/common'; +import { Component } from '@angular/core'; +import { NgSelectModule } from '@ng-select/ng-select'; +import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; +import { debounceTime, Observable, of, Subject, Subscription } from 'rxjs'; +import { BusinessListingCriteria, CountyResult, GeoResult, KeyValue, KeyValueStyle } from '../../../../../bizmatch-server/src/models/main.model'; + +import { ModalService } from '../../services/modal.service'; + +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { CriteriaChangeService } from '../../services/criteria-change.service'; +import { ListingsService } from '../../services/listings.service'; +import { SelectOptionsService } from '../../services/select-options.service'; +import { UserService } from '../../services/user.service'; +import { resetBusinessListingCriteria } from '../../utils/utils'; +import { ValidatedPriceComponent } from '../validated-price/validated-price.component'; +@UntilDestroy() +@Component({ + selector: 'app-search-modal', + standalone: true, + imports: [CommonModule, FormsModule, RouterModule, FontAwesomeModule, AsyncPipe, NgIf, NgSelectModule, ValidatedPriceComponent], + templateUrl: './search-modal.component.html', + styleUrl: './search-modal.component.scss', +}) +export class SearchModalComponent { + // cities$: Observable; + counties$: Observable; + // cityLoading = false; + countyLoading = false; + // cityInput$ = new Subject(); + countyInput$ = new Subject(); + private criteriaChangeSubscription: Subscription; + public criteria: BusinessListingCriteria; + backupCriteria: BusinessListingCriteria; + numberOfResults$: Observable; + cancelDisable = false; + constructor(public selectOptions: SelectOptionsService, public modalService: ModalService, private criteriaChangeService: CriteriaChangeService, private listingService: ListingsService, private userService: UserService) {} + ngOnInit() { + this.setupCriteriaChangeListener(); + this.modalService.message$.pipe(untilDestroyed(this)).subscribe(msg => { + this.criteria = msg as BusinessListingCriteria; + this.backupCriteria = JSON.parse(JSON.stringify(msg)); + this.setTotalNumberOfResults(); + }); + this.modalService.modalVisible$.pipe(untilDestroyed(this)).subscribe(val => { + if (val) { + this.criteria.page = 1; + this.criteria.start = 0; + } + }); + // this.loadCities(); + // this.loadCounties(); + } + + ngOnChanges() {} + categoryClicked(checked: boolean, value: string) { + if (checked) { + this.criteria.types.push(value); + } else { + const index = this.criteria.types.findIndex(t => t === value); + if (index > -1) { + this.criteria.types.splice(index, 1); + } + } + } + // private loadCounties() { + // this.counties$ = concat( + // of([]), // default items + // this.countyInput$.pipe( + // distinctUntilChanged(), + // tap(() => (this.countyLoading = true)), + // switchMap(term => + // this.geoService.findCountiesStartingWith(term).pipe( + // catchError(() => of([])), // empty list on error + // map(counties => counties.map(county => county.name)), // transform the list of objects to a list of city names + // tap(() => (this.countyLoading = false)), + // ), + // ), + // ), + // ); + // } + setCity(city) { + if (city) { + this.criteria.city = city; + this.criteria.state = city.state; + } else { + this.criteria.city = null; + this.criteria.radius = null; + this.criteria.searchType = 'exact'; + } + } + setState(state: string) { + if (state) { + this.criteria.state = state; + } else { + this.criteria.state = null; + this.setCity(null); + } + } + private setupCriteriaChangeListener() { + this.criteriaChangeSubscription = this.criteriaChangeService.criteriaChange$.pipe(debounceTime(400)).subscribe(() => { + this.setTotalNumberOfResults(); + this.cancelDisable = true; + }); + } + trackByFn(item: GeoResult) { + return item.id; + } + search() { + console.log('Search criteria:', this.criteria); + } + // getCounties() { + // this.geoService.findCountiesStartingWith(''); + // } + closeModal() { + console.log('Closing modal'); + } + isTypeOfBusinessClicked(v: KeyValueStyle) { + return this.criteria.types.find(t => t === v.value); + } + isTypeOfProfessionalClicked(v: KeyValue) { + return this.criteria.types.find(t => t === v.value); + } + setTotalNumberOfResults() { + if (this.criteria) { + console.log(`Getting total number of results for ${this.criteria.criteriaType}`); + if (this.criteria.criteriaType === 'businessListings' || this.criteria.criteriaType === 'commercialPropertyListings') { + this.numberOfResults$ = this.listingService.getNumberOfListings(this.criteria); + } else if (this.criteria.criteriaType === 'brokerListings') { + this.numberOfResults$ = this.userService.getNumberOfBroker(); + } else { + this.numberOfResults$ = of(); + } + } + } + clearFilter() { + resetBusinessListingCriteria(this.criteria); + } + close() { + this.modalService.reject(this.backupCriteria); + } + onCheckboxChange(checkbox: string, value: boolean) { + // Deaktivieren Sie alle Checkboxes + (this.criteria).realEstateChecked = false; + (this.criteria).leasedLocation = false; + (this.criteria).franchiseResale = false; + + // Aktivieren Sie nur die aktuell ausgewählte Checkbox + this.criteria[checkbox] = value; + } +} diff --git a/bizmatch-client/src/app/components/tooltip/tooltip.component.html b/bizmatch-client/src/app/components/tooltip/tooltip.component.html new file mode 100644 index 0000000..273e534 --- /dev/null +++ b/bizmatch-client/src/app/components/tooltip/tooltip.component.html @@ -0,0 +1,3 @@ + diff --git a/bizmatch-client/src/app/components/tooltip/tooltip.component.scss b/bizmatch-client/src/app/components/tooltip/tooltip.component.scss new file mode 100644 index 0000000..1765098 --- /dev/null +++ b/bizmatch-client/src/app/components/tooltip/tooltip.component.scss @@ -0,0 +1,29 @@ +/* Diese Styles kannst du in deine globale styles.css oder in eine eigene tooltip.component.css-Datei packen */ + +.tooltip-arrow { + position: absolute; + width: 8px; + height: 8px; + background: inherit; + transform: rotate(45deg); +} + +.arrow-top { + top: -4px; + left: calc(50% - 4px); +} + +.arrow-right { + right: -4px; + top: calc(50% - 4px); +} + +.arrow-bottom { + bottom: -4px; + left: calc(50% - 4px); +} + +.arrow-left { + left: -4px; + top: calc(50% - 4px); +} diff --git a/bizmatch-client/src/app/components/tooltip/tooltip.component.ts b/bizmatch-client/src/app/components/tooltip/tooltip.component.ts new file mode 100644 index 0000000..eef87d9 --- /dev/null +++ b/bizmatch-client/src/app/components/tooltip/tooltip.component.ts @@ -0,0 +1,167 @@ +import { CommonModule } from '@angular/common'; +import { AfterViewInit, Component, ElementRef, Input, OnChanges, OnDestroy, Renderer2, SimpleChanges } from '@angular/core'; + +@Component({ + selector: 'app-tooltip', + standalone: true, + imports: [CommonModule], + templateUrl: './tooltip.component.html', +}) +export class TooltipComponent implements AfterViewInit, OnDestroy, OnChanges { + @Input() id: string; + @Input() text: string; + @Input() isVisible: boolean = false; + @Input() position: 'top' | 'right' | 'bottom' | 'left' = 'top'; + + private tooltipElement: HTMLElement | null = null; + private arrowElement: HTMLElement | null = null; + private resizeObserver: ResizeObserver | null = null; + private parentElement: HTMLElement | null = null; + + constructor(private elementRef: ElementRef, private renderer: Renderer2) {} + + ngAfterViewInit() { + this.tooltipElement = document.getElementById(this.id); + this.parentElement = this.elementRef.nativeElement.parentElement; + + if (this.tooltipElement && this.parentElement) { + // Create arrow element + this.arrowElement = this.renderer.createElement('div'); + this.renderer.addClass(this.arrowElement, 'tooltip-arrow'); + this.renderer.appendChild(this.tooltipElement, this.arrowElement); + + // Setup resize observer + this.setupResizeObserver(); + + // Initial positioning + this.updatePosition(); + + // Initial visibility + this.updateTooltipVisibility(); + } + } + + ngOnChanges(changes: SimpleChanges) { + if (changes['isVisible'] && this.tooltipElement) { + this.updateTooltipVisibility(); + } + + if ((changes['position'] || changes['isVisible']) && this.isVisible) { + setTimeout(() => this.updatePosition(), 0); + } + } + + ngOnDestroy() { + if (this.resizeObserver) { + this.resizeObserver.disconnect(); + } + } + + private setupResizeObserver() { + if (window.ResizeObserver && this.parentElement) { + this.resizeObserver = new ResizeObserver(() => { + if (this.isVisible) { + this.updatePosition(); + } + }); + + this.resizeObserver.observe(this.parentElement); + if (this.tooltipElement) { + this.resizeObserver.observe(this.tooltipElement); + } + } + } + + private updateTooltipVisibility() { + if (!this.tooltipElement) return; + + if (this.isVisible) { + this.renderer.removeClass(this.tooltipElement, 'invisible'); + this.renderer.removeClass(this.tooltipElement, 'opacity-0'); + this.renderer.addClass(this.tooltipElement, 'visible'); + this.renderer.addClass(this.tooltipElement, 'opacity-100'); + this.updatePosition(); + } else { + this.renderer.removeClass(this.tooltipElement, 'visible'); + this.renderer.removeClass(this.tooltipElement, 'opacity-100'); + this.renderer.addClass(this.tooltipElement, 'invisible'); + this.renderer.addClass(this.tooltipElement, 'opacity-0'); + } + } + + private updatePosition() { + if (!this.tooltipElement || !this.parentElement || !this.arrowElement) return; + + const parentRect = this.parentElement.getBoundingClientRect(); + const tooltipRect = this.tooltipElement.getBoundingClientRect(); + + // Reset any previous positioning + this.renderer.removeStyle(this.tooltipElement, 'top'); + this.renderer.removeStyle(this.tooltipElement, 'right'); + this.renderer.removeStyle(this.tooltipElement, 'bottom'); + this.renderer.removeStyle(this.tooltipElement, 'left'); + + // Reset arrow classes + this.renderer.removeClass(this.arrowElement, 'arrow-top'); + this.renderer.removeClass(this.arrowElement, 'arrow-right'); + this.renderer.removeClass(this.arrowElement, 'arrow-bottom'); + this.renderer.removeClass(this.arrowElement, 'arrow-left'); + + let top: number = 0; + let left: number = 0; + + switch (this.position) { + case 'top': + top = -tooltipRect.height - 8; + left = (parentRect.width - tooltipRect.width) / 2; + this.renderer.addClass(this.arrowElement, 'arrow-bottom'); + break; + case 'right': + top = (parentRect.height - tooltipRect.height) / 2; + left = parentRect.width + 8; + this.renderer.addClass(this.arrowElement, 'arrow-left'); + break; + case 'bottom': + top = parentRect.height + 8; + left = (parentRect.width - tooltipRect.width) / 2; + this.renderer.addClass(this.arrowElement, 'arrow-top'); + break; + case 'left': + top = (parentRect.height - tooltipRect.height) / 2; + left = -tooltipRect.width - 8; + this.renderer.addClass(this.arrowElement, 'arrow-right'); + break; + } + + // Apply positioning + this.renderer.setStyle(this.tooltipElement, 'top', `${top}px`); + this.renderer.setStyle(this.tooltipElement, 'left', `${left}px`); + + // Make sure the tooltip stays within viewport + this.adjustToViewport(); + } + + private adjustToViewport() { + if (!this.tooltipElement) return; + + const tooltipRect = this.tooltipElement.getBoundingClientRect(); + const viewportWidth = window.innerWidth; + const viewportHeight = window.innerHeight; + + // Adjust horizontal position + if (tooltipRect.left < 0) { + this.renderer.setStyle(this.tooltipElement, 'left', '0px'); + } else if (tooltipRect.right > viewportWidth) { + const newLeft = Math.max(0, viewportWidth - tooltipRect.width); + this.renderer.setStyle(this.tooltipElement, 'left', `${newLeft}px`); + } + + // Adjust vertical position + if (tooltipRect.top < 0) { + this.renderer.setStyle(this.tooltipElement, 'top', '0px'); + } else if (tooltipRect.bottom > viewportHeight) { + const newTop = Math.max(0, viewportHeight - tooltipRect.height); + this.renderer.setStyle(this.tooltipElement, 'top', `${newTop}px`); + } + } +} diff --git a/bizmatch-client/src/app/components/validated-city/validated-city.component.html b/bizmatch-client/src/app/components/validated-city/validated-city.component.html new file mode 100644 index 0000000..a16d228 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-city/validated-city.component.html @@ -0,0 +1,31 @@ +
+ + + @for (city of cities$ | async; track city.id) { + {{ city.name }} - {{ city.state }} + } + +
diff --git a/bizmatch-client/src/app/components/validated-city/validated-city.component.scss b/bizmatch-client/src/app/components/validated-city/validated-city.component.scss new file mode 100644 index 0000000..b27bb07 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-city/validated-city.component.scss @@ -0,0 +1,9 @@ +:host ::ng-deep .ng-select.custom .ng-select-container { + // --tw-bg-opacity: 1; + // background-color: rgb(249 250 251 / var(--tw-bg-opacity)); + // height: 42px; + border-radius: 0.5rem; + .ng-value-container .ng-input { + top: 10px; + } +} diff --git a/bizmatch-client/src/app/components/validated-city/validated-city.component.ts b/bizmatch-client/src/app/components/validated-city/validated-city.component.ts new file mode 100644 index 0000000..6e5dcf7 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-city/validated-city.component.ts @@ -0,0 +1,70 @@ +import { CommonModule } from '@angular/common'; +import { Component, forwardRef, Input } from '@angular/core'; +import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { NgSelectModule } from '@ng-select/ng-select'; +import { catchError, concat, distinctUntilChanged, Observable, of, Subject, switchMap, tap } from 'rxjs'; +import { GeoResult } from '../../../../../bizmatch-server/src/models/main.model'; +import { City } from '../../../../../bizmatch-server/src/models/server.model'; +import { GeoService } from '../../services/geo.service'; +import { SelectOptionsService } from '../../services/select-options.service'; +import { BaseInputComponent } from '../base-input/base-input.component'; +import { TooltipComponent } from '../tooltip/tooltip.component'; +import { ValidationMessagesService } from '../validation-messages.service'; + +@Component({ + selector: 'app-validated-city', + standalone: true, + imports: [CommonModule, FormsModule, NgSelectModule, TooltipComponent], + templateUrl: './validated-city.component.html', + styleUrl: './validated-city.component.scss', + providers: [ + { + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => ValidatedCityComponent), + multi: true, + }, + ], +}) +export class ValidatedCityComponent extends BaseInputComponent { + @Input() items; + @Input() labelClasses: string; + @Input() state: string; + cities$: Observable; + cityInput$ = new Subject(); + countyInput$ = new Subject(); + cityLoading = false; + constructor(validationMessagesService: ValidationMessagesService, private geoService: GeoService, public selectOptions: SelectOptionsService) { + super(validationMessagesService); + } + + override ngOnInit() { + super.ngOnInit(); + this.loadCities(); + } + onInputChange(event: City): void { + this.value = event; //{ ...event, longitude: parseFloat(event.longitude), latitude: parseFloat(event.latitude) }; + this.onChange(this.value); + } + private loadCities() { + this.cities$ = concat( + of([]), // default items + this.cityInput$.pipe( + distinctUntilChanged(), + tap(() => (this.cityLoading = true)), + switchMap(term => + this.geoService.findCitiesStartingWith(term, this.state).pipe( + catchError(() => of([])), // empty list on error + // map(cities => cities.map(city => city.city)), // transform the list of objects to a list of city names + tap(() => (this.cityLoading = false)), + ), + ), + ), + ); + } + trackByFn(item: GeoResult) { + return item.id; + } + compareFn = (item, selected) => { + return item.id === selected.id; + }; +} diff --git a/bizmatch-client/src/app/components/validated-county/validated-county.component.html b/bizmatch-client/src/app/components/validated-county/validated-county.component.html new file mode 100644 index 0000000..5d810d1 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-county/validated-county.component.html @@ -0,0 +1,34 @@ +
+ @if(label){ + + } + + @for (county of counties$ | async; track county.id) { + {{ county }} + } + +
diff --git a/bizmatch-client/src/app/components/validated-county/validated-county.component.scss b/bizmatch-client/src/app/components/validated-county/validated-county.component.scss new file mode 100644 index 0000000..b27bb07 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-county/validated-county.component.scss @@ -0,0 +1,9 @@ +:host ::ng-deep .ng-select.custom .ng-select-container { + // --tw-bg-opacity: 1; + // background-color: rgb(249 250 251 / var(--tw-bg-opacity)); + // height: 42px; + border-radius: 0.5rem; + .ng-value-container .ng-input { + top: 10px; + } +} diff --git a/bizmatch-client/src/app/components/validated-county/validated-county.component.ts b/bizmatch-client/src/app/components/validated-county/validated-county.component.ts new file mode 100644 index 0000000..2d666e3 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-county/validated-county.component.ts @@ -0,0 +1,70 @@ +import { CommonModule } from '@angular/common'; +import { Component, forwardRef, Input } from '@angular/core'; +import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { NgSelectModule } from '@ng-select/ng-select'; +import { catchError, concat, distinctUntilChanged, map, Observable, of, Subject, switchMap, tap } from 'rxjs'; +import { CountyResult, GeoResult } from '../../../../../bizmatch-server/src/models/main.model'; +import { City } from '../../../../../bizmatch-server/src/models/server.model'; +import { GeoService } from '../../services/geo.service'; +import { SelectOptionsService } from '../../services/select-options.service'; +import { BaseInputComponent } from '../base-input/base-input.component'; +import { TooltipComponent } from '../tooltip/tooltip.component'; +import { ValidationMessagesService } from '../validation-messages.service'; + +@Component({ + selector: 'app-validated-county', + standalone: true, + imports: [CommonModule, FormsModule, NgSelectModule, TooltipComponent], + templateUrl: './validated-county.component.html', + styleUrl: './validated-county.component.scss', + providers: [ + { + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => ValidatedCountyComponent), + multi: true, + }, + ], +}) +export class ValidatedCountyComponent extends BaseInputComponent { + @Input() items; + @Input() labelClasses: string; + @Input() state: string; + @Input() readonly = false; + counties$: Observable; + countyLoading = false; + countyInput$ = new Subject(); + constructor(validationMessagesService: ValidationMessagesService, private geoService: GeoService, public selectOptions: SelectOptionsService) { + super(validationMessagesService); + } + + override ngOnInit() { + super.ngOnInit(); + this.loadCounties(); + } + onInputChange(event: City): void { + this.value = event; //{ ...event, longitude: parseFloat(event.longitude), latitude: parseFloat(event.latitude) }; + this.onChange(this.value); + } + private loadCounties() { + this.counties$ = concat( + of([]), // default items + this.countyInput$.pipe( + distinctUntilChanged(), + tap(() => (this.countyLoading = true)), + switchMap(term => + this.geoService.findCountiesStartingWith(term, this.state ? [this.state] : null).pipe( + catchError(() => of([])), // empty list on error + map(counties => counties.map(county => county.name)), // transform the list of objects to a list of city names + tap(() => (this.countyLoading = false)), + ), + ), + ), + ); + } + trackByFn(item: GeoResult) { + return item.id; + } + compareFn = (item, selected) => { + return item.id === selected.id; + }; +} diff --git a/bizmatch-client/src/app/components/validated-input/validated-input.component.html b/bizmatch-client/src/app/components/validated-input/validated-input.component.html new file mode 100644 index 0000000..568cc75 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-input/validated-input.component.html @@ -0,0 +1,27 @@ +
+ + +
diff --git a/bizmatch-client/src/app/components/validated-input/validated-input.component.ts b/bizmatch-client/src/app/components/validated-input/validated-input.component.ts new file mode 100644 index 0000000..5275ea1 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-input/validated-input.component.ts @@ -0,0 +1,44 @@ +import { CommonModule } from '@angular/common'; +import { Component, forwardRef, Input } from '@angular/core'; +import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { NgxMaskDirective, NgxMaskPipe, provideNgxMask } from 'ngx-mask'; +import { BaseInputComponent } from '../base-input/base-input.component'; +import { TooltipComponent } from '../tooltip/tooltip.component'; +import { ValidationMessagesService } from '../validation-messages.service'; + +@Component({ + selector: 'app-validated-input', + templateUrl: './validated-input.component.html', + standalone: true, + imports: [CommonModule, FormsModule, TooltipComponent, NgxMaskDirective, NgxMaskPipe], + providers: [ + { + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => ValidatedInputComponent), + multi: true, + }, + provideNgxMask(), + ], +}) +export class ValidatedInputComponent extends BaseInputComponent { + @Input() kind: 'text' | 'number' | 'email' = 'text'; + @Input() mask: string; + constructor(validationMessagesService: ValidationMessagesService) { + super(validationMessagesService); + } + + onInputChange(event: string | number): void { + if (this.kind === 'number') { + if (typeof event === 'number') { + this.value = event; + } else { + this.value = parseFloat(event); + } + } else { + const text = event as string; + this.value = text?.length > 0 ? event : null; + } + // this.value = event?.length > 0 ? (this.kind === 'number' ? parseFloat(event) : event) : null; + this.onChange(this.value); + } +} diff --git a/bizmatch-client/src/app/components/validated-location/validated-location.component.html b/bizmatch-client/src/app/components/validated-location/validated-location.component.html new file mode 100644 index 0000000..4d9e542 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-location/validated-location.component.html @@ -0,0 +1,31 @@ +
+ + + @for (place of places$ | async; track place.place_id) { + {{ formatPlaceAddress(place) }} + } + +
diff --git a/bizmatch-client/src/app/components/validated-location/validated-location.component.scss b/bizmatch-client/src/app/components/validated-location/validated-location.component.scss new file mode 100644 index 0000000..b27bb07 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-location/validated-location.component.scss @@ -0,0 +1,9 @@ +:host ::ng-deep .ng-select.custom .ng-select-container { + // --tw-bg-opacity: 1; + // background-color: rgb(249 250 251 / var(--tw-bg-opacity)); + // height: 42px; + border-radius: 0.5rem; + .ng-value-container .ng-input { + top: 10px; + } +} diff --git a/bizmatch-client/src/app/components/validated-location/validated-location.component.ts b/bizmatch-client/src/app/components/validated-location/validated-location.component.ts new file mode 100644 index 0000000..b52b162 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-location/validated-location.component.ts @@ -0,0 +1,159 @@ +import { CommonModule } from '@angular/common'; +import { Component, forwardRef, Input } from '@angular/core'; +import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { NgSelectModule } from '@ng-select/ng-select'; +import { catchError, concat, debounceTime, distinctUntilChanged, Observable, of, Subject, switchMap, tap } from 'rxjs'; +import { GeoResult } from '../../../../../bizmatch-server/src/models/main.model'; +import { Place } from '../../../../../bizmatch-server/src/models/server.model'; +import { GeoService } from '../../services/geo.service'; +import { SelectOptionsService } from '../../services/select-options.service'; +import { BaseInputComponent } from '../base-input/base-input.component'; +import { TooltipComponent } from '../tooltip/tooltip.component'; +import { ValidationMessagesService } from '../validation-messages.service'; + +@Component({ + selector: 'app-validated-location', + standalone: true, + imports: [CommonModule, FormsModule, NgSelectModule, TooltipComponent], + templateUrl: './validated-location.component.html', + styleUrl: './validated-location.component.scss', + providers: [ + { + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => ValidatedLocationComponent), + multi: true, + }, + ], +}) +export class ValidatedLocationComponent extends BaseInputComponent { + @Input() items; + @Input() labelClasses: string; + places$: Observable; + placeInput$ = new Subject(); + placeLoading = false; + constructor(validationMessagesService: ValidationMessagesService, private geoService: GeoService, public selectOptions: SelectOptionsService) { + super(validationMessagesService); + } + + override ngOnInit() { + super.ngOnInit(); + this.loadCities(); + } + onInputChange(event: Place): void { + this.value = event; //{ ...event, longitude: parseFloat(event.longitude), latitude: parseFloat(event.latitude) }; + if (event) { + this.value = { + id: event?.place_id, + name: event?.address.city, + county: event?.address.county, + street: event?.address.road, + housenumber: event?.address.house_number, + state: event?.address['ISO3166-2-lvl4'].substr(3), + latitude: event ? parseFloat(event?.lat) : undefined, + longitude: event ? parseFloat(event?.lon) : undefined, + }; + } + this.onChange(this.value); + } + private loadCities() { + this.places$ = concat( + of([]), // default items + this.placeInput$.pipe( + debounceTime(300), + distinctUntilChanged(), + tap(() => (this.placeLoading = true)), + switchMap(term => + this.geoService.findLocationStartingWith(term).pipe( + catchError(() => of([])), // empty list on error + // map(cities => cities.map(city => city.city)), // transform the list of objects to a list of city names + tap(() => (this.placeLoading = false)), + ), + ), + ), + ); + } + trackByFn(item: GeoResult) { + return item.id; + } + compareFn = (item, selected) => { + return item.id === selected.id; + }; + formatGeoAddress(geoResult: GeoResult | null | undefined): string { + // Überprüfen, ob geoResult null oder undefined ist + if (!geoResult) { + return ''; + } + + let addressParts: string[] = []; + + // Füge Hausnummer hinzu, wenn vorhanden + if (geoResult.housenumber) { + addressParts.push(geoResult.housenumber); + } + + // Füge Straße hinzu, wenn vorhanden + if (geoResult.street) { + addressParts.push(geoResult.street); + } + + // Kombiniere Hausnummer und Straße + let address = addressParts.join(' '); + + // Füge Namen hinzu, wenn vorhanden + if (geoResult.name) { + address = address ? `${address}, ${geoResult.name}` : geoResult.name; + } + + // Füge County hinzu, wenn vorhanden + if (geoResult.county) { + address = address ? `${address}, ${geoResult.county}` : geoResult.county; + } + + // Füge Bundesland hinzu, wenn vorhanden + if (geoResult.state) { + address = address ? `${address} - ${geoResult.state}` : geoResult.state; + } + + return address; + } + formatPlaceAddress(place: Place | null | undefined): string { + // Überprüfen, ob place null oder undefined ist + if (!place) { + return ''; + } + + const { house_number, road, city, county, state } = place.address; + + let addressParts: string[] = []; + + // Füge Hausnummer hinzu, wenn vorhanden + if (house_number) { + addressParts.push(house_number); + } + + // Füge Straße hinzu, wenn vorhanden + if (road) { + addressParts.push(road); + } + + // Kombiniere Hausnummer und Straße + let address = addressParts.join(' '); + + // Füge Stadt hinzu, wenn vorhanden + if (city) { + address = address ? `${address}, ${city}` : city; + } + + // Füge County hinzu, wenn vorhanden + if (county) { + address = address ? `${address}, ${county}` : county; + } + + // Füge Bundesland hinzu, wenn vorhanden + if (state) { + address = address ? `${address} - ${state}` : state; + } + + return address; + } +} diff --git a/bizmatch-client/src/app/components/validated-ng-select/validated-ng-select.component.html b/bizmatch-client/src/app/components/validated-ng-select/validated-ng-select.component.html new file mode 100644 index 0000000..86c4df9 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-ng-select/validated-ng-select.component.html @@ -0,0 +1,16 @@ +
+ + +
diff --git a/bizmatch-client/src/app/components/validated-ng-select/validated-ng-select.component.ts b/bizmatch-client/src/app/components/validated-ng-select/validated-ng-select.component.ts new file mode 100644 index 0000000..c603c98 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-ng-select/validated-ng-select.component.ts @@ -0,0 +1,31 @@ +import { CommonModule } from '@angular/common'; +import { Component, forwardRef, Input } from '@angular/core'; +import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { NgSelectModule } from '@ng-select/ng-select'; +import { BaseInputComponent } from '../base-input/base-input.component'; +import { TooltipComponent } from '../tooltip/tooltip.component'; +import { ValidationMessagesService } from '../validation-messages.service'; + +@Component({ + selector: 'app-validated-ng-select', + standalone: true, + imports: [CommonModule, FormsModule, NgSelectModule, TooltipComponent], + templateUrl: './validated-ng-select.component.html', + providers: [ + { + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => ValidatedNgSelectComponent), + multi: true, + }, + ], +}) +export class ValidatedNgSelectComponent extends BaseInputComponent { + @Input() items; + constructor(validationMessagesService: ValidationMessagesService) { + super(validationMessagesService); + } + onInputChange(event: Event): void { + this.value = event; + this.onChange(this.value); + } +} diff --git a/bizmatch-client/src/app/components/validated-price/validated-price.component.html b/bizmatch-client/src/app/components/validated-price/validated-price.component.html new file mode 100644 index 0000000..a42a521 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-price/validated-price.component.html @@ -0,0 +1,31 @@ +
+ @if(label){ + + } + +
diff --git a/bizmatch-client/src/app/components/validated-price/validated-price.component.ts b/bizmatch-client/src/app/components/validated-price/validated-price.component.ts new file mode 100644 index 0000000..8c28cdd --- /dev/null +++ b/bizmatch-client/src/app/components/validated-price/validated-price.component.ts @@ -0,0 +1,34 @@ +import { CommonModule } from '@angular/common'; +import { Component, forwardRef, Input } from '@angular/core'; +import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { NgxCurrencyDirective } from 'ngx-currency'; +import { BaseInputComponent } from '../base-input/base-input.component'; +import { TooltipComponent } from '../tooltip/tooltip.component'; +import { ValidationMessagesService } from '../validation-messages.service'; + +@Component({ + selector: 'app-validated-price', + standalone: true, + imports: [CommonModule, FormsModule, TooltipComponent, NgxCurrencyDirective], + providers: [ + { + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => ValidatedPriceComponent), + multi: true, + }, + ], + templateUrl: './validated-price.component.html', + styles: `:host{width:100%}`, +}) +export class ValidatedPriceComponent extends BaseInputComponent { + @Input() inputClasses: string; + @Input() placeholder: string = ''; + constructor(validationMessagesService: ValidationMessagesService) { + super(validationMessagesService); + } + + onInputChange(event: Event): void { + this.value = !event ? null : event; + this.onChange(this.value); + } +} diff --git a/bizmatch-client/src/app/components/validated-quill/validated-quill.component.html b/bizmatch-client/src/app/components/validated-quill/validated-quill.component.html new file mode 100644 index 0000000..222f555 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-quill/validated-quill.component.html @@ -0,0 +1,15 @@ + + diff --git a/bizmatch-client/src/app/components/validated-quill/validated-quill.component.ts b/bizmatch-client/src/app/components/validated-quill/validated-quill.component.ts new file mode 100644 index 0000000..20cdb09 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-quill/validated-quill.component.ts @@ -0,0 +1,37 @@ +import { CommonModule } from '@angular/common'; +import { Component, forwardRef } from '@angular/core'; +import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { QuillModule } from 'ngx-quill'; +import { BaseInputComponent } from '../base-input/base-input.component'; +import { TooltipComponent } from '../tooltip/tooltip.component'; +import { ValidationMessagesService } from '../validation-messages.service'; + +@Component({ + selector: 'app-validated-quill', + templateUrl: './validated-quill.component.html', + styles: `quill-editor { + width: 100%; + }`, + standalone: true, + imports: [CommonModule, FormsModule, QuillModule, TooltipComponent], + providers: [ + { + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => ValidatedQuillComponent), + multi: true, + }, + ], +}) +export class ValidatedQuillComponent extends BaseInputComponent { + quillModules = { + toolbar: [['bold', 'italic', 'underline', 'strike'], [{ list: 'ordered' }, { list: 'bullet' }], [{ header: [1, 2, 3, 4, 5, 6, false] }], [{ color: [] }, { background: [] }], ['clean']], + }; + constructor(validationMessagesService: ValidationMessagesService) { + super(validationMessagesService); + } + + onInputChange(event: Event): void { + this.value = event; + this.onChange(this.value); + } +} diff --git a/bizmatch-client/src/app/components/validated-select/validated-select.component.html b/bizmatch-client/src/app/components/validated-select/validated-select.component.html new file mode 100644 index 0000000..660d8d8 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-select/validated-select.component.html @@ -0,0 +1,30 @@ +
+ + +
diff --git a/bizmatch-client/src/app/components/validated-select/validated-select.component.ts b/bizmatch-client/src/app/components/validated-select/validated-select.component.ts new file mode 100644 index 0000000..5ffcd58 --- /dev/null +++ b/bizmatch-client/src/app/components/validated-select/validated-select.component.ts @@ -0,0 +1,36 @@ +import { CommonModule } from '@angular/common'; +import { Component, EventEmitter, forwardRef, Input, Output } from '@angular/core'; +import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { BaseInputComponent } from '../base-input/base-input.component'; +import { TooltipComponent } from '../tooltip/tooltip.component'; +import { ValidationMessagesService } from '../validation-messages.service'; + +@Component({ + selector: 'app-validated-select', + templateUrl: './validated-select.component.html', + standalone: true, + imports: [CommonModule, FormsModule, TooltipComponent], + providers: [ + { + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => ValidatedSelectComponent), + multi: true, + }, + ], +}) +export class ValidatedSelectComponent extends BaseInputComponent { + @Input() options: Array<{ value: any; label: string }> = []; + @Input() disabled = false; + @Output() valueChange = new EventEmitter(); + + constructor(validationMessagesService: ValidationMessagesService) { + super(validationMessagesService); + } + + onSelectChange(event: Event): void { + const value = (event.target as HTMLSelectElement).value; + this.value = value; + this.onChange(value); + this.valueChange.emit(value); + } +} diff --git a/bizmatch-client/src/app/components/validated-textarea/validated-textarea.component.html b/bizmatch-client/src/app/components/validated-textarea/validated-textarea.component.html new file mode 100644 index 0000000..a5f065a --- /dev/null +++ b/bizmatch-client/src/app/components/validated-textarea/validated-textarea.component.html @@ -0,0 +1,17 @@ +
+ + +
diff --git a/bizmatch-client/src/app/components/validated-textarea/validated-textarea.component.ts b/bizmatch-client/src/app/components/validated-textarea/validated-textarea.component.ts new file mode 100644 index 0000000..963eeda --- /dev/null +++ b/bizmatch-client/src/app/components/validated-textarea/validated-textarea.component.ts @@ -0,0 +1,30 @@ +import { CommonModule } from '@angular/common'; +import { Component, forwardRef } from '@angular/core'; +import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { BaseInputComponent } from '../base-input/base-input.component'; +import { TooltipComponent } from '../tooltip/tooltip.component'; +import { ValidationMessagesService } from '../validation-messages.service'; + +@Component({ + selector: 'app-validated-textarea', + templateUrl: './validated-textarea.component.html', + standalone: true, + imports: [CommonModule, FormsModule, TooltipComponent], + providers: [ + { + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => ValidatedTextareaComponent), + multi: true, + }, + ], +}) +export class ValidatedTextareaComponent extends BaseInputComponent { + constructor(validationMessagesService: ValidationMessagesService) { + super(validationMessagesService); + } + + onInputChange(event: string): void { + this.value = event?.length > 0 ? event : null; + this.onChange(this.value); + } +} diff --git a/bizmatch-client/src/app/components/validation-messages.service.ts b/bizmatch-client/src/app/components/validation-messages.service.ts new file mode 100644 index 0000000..451ef76 --- /dev/null +++ b/bizmatch-client/src/app/components/validation-messages.service.ts @@ -0,0 +1,31 @@ +import { Injectable, InjectionToken } from '@angular/core'; +import { BehaviorSubject, Observable } from 'rxjs'; + +export interface ValidationMessage { + field: string; + message: string; +} + +export const VALIDATION_MESSAGES = new InjectionToken('VALIDATION_MESSAGES'); + +@Injectable({ + providedIn: 'root', +}) +export class ValidationMessagesService { + private messagesSubject = new BehaviorSubject([]); + messages$: Observable = this.messagesSubject.asObservable(); + + updateMessages(messages: ValidationMessage[]): void { + this.messagesSubject.next(messages); + } + + clearMessages(): void { + this.messagesSubject.next([]); + } + + getMessage(field: string): string | null { + const messages = this.messagesSubject.value; + const message = messages.find(m => m.field === field); + return message ? message.message : null; + } +} diff --git a/bizmatch-client/src/app/guards/auth.guard.ts b/bizmatch-client/src/app/guards/auth.guard.ts new file mode 100644 index 0000000..01bb7b7 --- /dev/null +++ b/bizmatch-client/src/app/guards/auth.guard.ts @@ -0,0 +1,21 @@ +import { Injectable } from '@angular/core'; +import { CanActivate, Router } from '@angular/router'; +import { AuthService } from '../services/auth.service'; +import { createLogger } from '../utils/utils'; +const logger = createLogger('AuthGuard'); +@Injectable({ + providedIn: 'root', +}) +export class AuthGuard implements CanActivate { + constructor(private authService: AuthService, private router: Router) {} + + async canActivate(): Promise { + const token = await this.authService.getToken(); + if (token) { + return true; + } else { + this.router.navigate(['/login-register']); + return false; + } + } +} diff --git a/bizmatch-client/src/app/guards/listing-category.guard.ts b/bizmatch-client/src/app/guards/listing-category.guard.ts new file mode 100644 index 0000000..d0c99fc --- /dev/null +++ b/bizmatch-client/src/app/guards/listing-category.guard.ts @@ -0,0 +1,35 @@ +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, tap } from 'rxjs/operators'; +import { environment } from '../../environments/environment'; + +@Injectable({ + providedIn: 'root', +}) +export class ListingCategoryGuard implements CanActivate { + private apiBaseUrl = environment.apiBaseUrl; + constructor(private http: HttpClient, private router: Router) {} + + canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + const id = route.paramMap.get('id'); + const url = `${this.apiBaseUrl}/bizmatch/listings/undefined/${id}`; + + return this.http.get(url).pipe( + tap(response => { + const category = response.listingsCategory; + if (category === 'business') { + this.router.navigate(['details-business-listing', id]); + } else if (category === 'commercialProperty') { + this.router.navigate(['details-commercial-property-listing', id]); + } else { + this.router.navigate(['not-found']); + } + }), + catchError(() => { + return of(this.router.createUrlTree(['/not-found'])); + }), + ); + } +} diff --git a/bizmatch-client/src/app/interceptors/auth.interceptor.ts b/bizmatch-client/src/app/interceptors/auth.interceptor.ts new file mode 100644 index 0000000..5317069 --- /dev/null +++ b/bizmatch-client/src/app/interceptors/auth.interceptor.ts @@ -0,0 +1,34 @@ +import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Observable, from } from 'rxjs'; +import { switchMap } from 'rxjs/operators'; +import { environment } from '../../environments/environment'; +import { AuthService } from '../services/auth.service'; + +@Injectable() +export class AuthInterceptor implements HttpInterceptor { + constructor(private authService: AuthService) {} + + intercept(req: HttpRequest, next: HttpHandler): Observable> { + // Prüfe, ob die Anfrage an die apiBaseUrl gerichtet ist + const isApiRequest = req.url.startsWith(environment.apiBaseUrl); + + if (!isApiRequest) { + // Wenn es keine API-Anfrage ist, leite die Anfrage unverändert weiter + return next.handle(req); + } + + // Wenn es eine API-Anfrage ist, füge den Token hinzu (falls vorhanden) + return from(this.authService.getToken()).pipe( + switchMap(token => { + if (token) { + const clonedReq = req.clone({ + setHeaders: { Authorization: `Bearer ${token}` }, + }); + return next.handle(clonedReq); + } + return next.handle(req); + }), + ); + } +} diff --git a/bizmatch-client/src/app/interceptors/loading.interceptor.ts b/bizmatch-client/src/app/interceptors/loading.interceptor.ts new file mode 100644 index 0000000..6fe6dbf --- /dev/null +++ b/bizmatch-client/src/app/interceptors/loading.interceptor.ts @@ -0,0 +1,29 @@ +import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Observable, tap } from 'rxjs'; +import { v4 } from 'uuid'; +import { LoadingService } from '../services/loading.service'; + +@Injectable() +export class LoadingInterceptor implements HttpInterceptor { + constructor(private loadingService: LoadingService) {} + + intercept(request: HttpRequest, next: HttpHandler): Observable> { + const hideLoading = request.headers.get('X-Hide-Loading') === 'true'; + const requestId = `HTTP-${v4()}`; + + if (!hideLoading) { + this.loadingService.startLoading(requestId, request.url); + } + + return next.handle(request).pipe( + tap({ + finalize: () => { + if (!hideLoading) { + this.loadingService.stopLoading(requestId); + } + }, + }), + ); + } +} diff --git a/bizmatch-client/src/app/interceptors/timeout.interceptor.ts b/bizmatch-client/src/app/interceptors/timeout.interceptor.ts new file mode 100644 index 0000000..afebe07 --- /dev/null +++ b/bizmatch-client/src/app/interceptors/timeout.interceptor.ts @@ -0,0 +1,34 @@ +import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; +import { Inject, Injectable, Optional } from '@angular/core'; +import { Observable, throwError, TimeoutError } from 'rxjs'; +import { catchError, timeout } from 'rxjs/operators'; + +@Injectable() +export class TimeoutInterceptor implements HttpInterceptor { + constructor(@Optional() @Inject('TIMEOUT_DURATION') private timeoutDuration: number = 5000) {} + + intercept(req: HttpRequest, next: HttpHandler): Observable> { + // Überprüfen, ob die URL mit '/ai' endet + if (req.url.endsWith('/ai')) { + return next.handle(req).pipe( + timeout(this.timeoutDuration), + catchError((error: any) => { + if (error instanceof TimeoutError) { + // Timeout error handling + return throwError( + () => + new HttpErrorResponse({ + error: 'Request timed out', + status: 408, // HTTP status code for Request Timeout + }), + ); + } + return throwError(() => error); + }), + ); + } + + // Für alle anderen URLs ohne Timeout fortfahren + return next.handle(req); + } +} diff --git a/bizmatch-client/src/app/pages/account/account.component.html b/bizmatch-client/src/app/pages/account/account.component.html new file mode 100644 index 0000000..2c27409 --- /dev/null +++ b/bizmatch-client/src/app/pages/account/account.component.html @@ -0,0 +1,318 @@ +
+ @if (user){ +
+
+

Account Details

+
+
+ + +

You can only modify your email by contacting us at support@bizmatch.net

+
+ @if (isProfessional || (authService.isAdmin() | async)){ +
+
+

Company Logo

+
+ @if(user?.hasCompanyLogo){ + Company logo +
+ + + +
+ } @else { + + } +
+ +
+
+

Your Profile Picture

+
+ @if(user?.hasProfile){ + Profile picture +
+ + + +
+ } @else { + + } +
+ +
+
+ } +
+ +
+ + +
+ +
+ + @if ((authService.isAdmin() | async) && !id){ +
+ + ADMIN +
+ + } + + @if (isProfessional){ + + + } +
+ @if (isProfessional){ +
+ + + + +
+ +
+ + + + + + +
+ + +
+ +
+
+ + +
+ +
+

+ Areas We Serve @if(getValidationMessage('areasServed')){ +
+ ! +
+ + } +

+
+
+ +
+
+ +
+
+ @for (areasServed of user.areasServed; track areasServed; let i=$index){ +
+
+ +
+
+ + +
+
+ +
+
+ } +
+ + + [Add more Areas or remove existing ones.] +
+
+ +
+

+ Licensed In@if(getValidationMessage('licensedIn')){ +
+ ! +
+ + } +

+
+
+ +
+
+ +
+
+ @for (licensedIn of user.licensedIn; track licensedIn; let i=$index){ +
+
+ +
+
+ +
+ +
+ } +
+ + [Add more licenses or remove existing ones.] +
+
+ } + + +
+ +
+
+ + +
+ } +
+ + diff --git a/bizmatch-client/src/app/pages/account/account.component.scss b/bizmatch-client/src/app/pages/account/account.component.scss new file mode 100644 index 0000000..7640bee --- /dev/null +++ b/bizmatch-client/src/app/pages/account/account.component.scss @@ -0,0 +1,42 @@ +.rounded-logo { + border-radius: 6px; + width: 120px; + height: 30px; + border: 1px solid #6b7280; + padding: 1px 1px; + object-fit: contain; +} +.rounded-profile { + // @extend .rounded-logo; + max-width: 100px; + max-height: 120px; + border-radius: 6px; + border: 1px solid #6b7280; + padding: 1px 1px; + object-fit: contain; +} +.wfull { + width: 100%; +} +.image-wrap { + position: relative; /* Ermöglicht die absolute Positionierung des Icons bezogen auf diesen Container */ + display: inline-block; /* Erlaubt die Inline-Anordnung, falls mehrere Bilder vorhanden sind */ +} +/* Stil für das FontAwesome Icon */ +.image-wrap fa-icon { + position: absolute; + top: -5px; /* Positioniert das Icon am oberen Rand des Bildes */ + right: -18px; /* Positioniert das Icon am rechten Rand des Bildes */ + color: #fff; /* Weiße Farbe für das Icon */ + background-color: rgba(0, 0, 0, 0.5); /* Halbtransparenter Hintergrund für bessere Sichtbarkeit */ + padding: 5px; /* Ein wenig Platz um das Icon */ + cursor: pointer; /* Verwandelt den Cursor in eine Hand, um Interaktivität anzudeuten */ + border-radius: 8px; /* Optional: Abrunden der linken unteren Ecke für ästhetische Zwecke */ + font-size: 0.7rem; +} +quill-editor { + width: 100%; +} +:host ::ng-deep .ng-select.ng-select-single .ng-select-container { + height: 42px; +} diff --git a/bizmatch-client/src/app/pages/account/account.component.ts b/bizmatch-client/src/app/pages/account/account.component.ts new file mode 100644 index 0000000..488ba11 --- /dev/null +++ b/bizmatch-client/src/app/pages/account/account.component.ts @@ -0,0 +1,257 @@ +import { CommonModule, DatePipe, TitleCasePipe } from '@angular/common'; +import { ChangeDetectorRef, Component } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { ActivatedRoute, Router, RouterModule } from '@angular/router'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { faTrash } from '@fortawesome/free-solid-svg-icons'; +import { NgSelectModule } from '@ng-select/ng-select'; + +import { NgxCurrencyDirective } from 'ngx-currency'; +import { ImageCropperComponent } from 'ngx-image-cropper'; +import { QuillModule } from 'ngx-quill'; +import { lastValueFrom } from 'rxjs'; +import { User } from '../../../../../bizmatch-server/src/models/db.model'; +import { AutoCompleteCompleteEvent, Invoice, UploadParams, emailToDirName } from '../../../../../bizmatch-server/src/models/main.model'; +import { environment } from '../../../environments/environment'; +import { ConfirmationComponent } from '../../components/confirmation.component'; +import { ImageCropAndUploadComponent, UploadReponse } from '../../components/image-crop-and-upload/image-crop-and-upload.component'; +import { MessageComponent } from '../../components/message/message.component'; +import { TooltipComponent } from '../../components/tooltip/tooltip.component'; +import { ValidatedCityComponent } from '../../components/validated-city/validated-city.component'; +import { ValidatedCountyComponent } from '../../components/validated-county/validated-county.component'; +import { ValidatedInputComponent } from '../../components/validated-input/validated-input.component'; +import { ValidatedLocationComponent } from '../../components/validated-location/validated-location.component'; +import { ValidatedQuillComponent } from '../../components/validated-quill/validated-quill.component'; +import { ValidatedSelectComponent } from '../../components/validated-select/validated-select.component'; +import { ValidationMessage, ValidationMessagesService } from '../../components/validation-messages.service'; +import { AuthService } from '../../services/auth.service'; +import { ConfirmationService } from '../../services/confirmation.service'; +import { GeoService } from '../../services/geo.service'; +import { ImageService } from '../../services/image.service'; +import { LoadingService } from '../../services/loading.service'; +import { MessageService } from '../../services/message.service'; +import { SelectOptionsService } from '../../services/select-options.service'; +import { SharedService } from '../../services/shared.service'; +import { UserService } from '../../services/user.service'; +import { TOOLBAR_OPTIONS, map2User } from '../../utils/utils'; + +@Component({ + selector: 'app-account', + standalone: true, + imports: [ + CommonModule, + FormsModule, + RouterModule, + FontAwesomeModule, + QuillModule, + NgxCurrencyDirective, + NgSelectModule, + ImageCropperComponent, + ConfirmationComponent, + ImageCropAndUploadComponent, + MessageComponent, + ValidatedInputComponent, + ValidatedSelectComponent, + ValidatedQuillComponent, + ValidatedCityComponent, + TooltipComponent, + ValidatedCountyComponent, + ValidatedLocationComponent, + ], + providers: [TitleCasePipe, DatePipe], + templateUrl: './account.component.html', + styleUrl: './account.component.scss', +}) +export class AccountComponent { + id: string | undefined; + user: User; + companyLogoUrl: string; + profileUrl: string; + type: 'company' | 'profile'; + environment = environment; + editorModules = TOOLBAR_OPTIONS; + env = environment; + faTrash = faTrash; + quillModules = { + toolbar: [['bold', 'italic', 'underline', 'strike'], [{ list: 'ordered' }, { list: 'bullet' }], [{ header: [1, 2, 3, 4, 5, 6, false] }], [{ color: [] }, { background: [] }], ['clean']], + }; + uploadParams: UploadParams; + validationMessages: ValidationMessage[] = []; + customerTypeOptions: Array<{ value: string; label: string }> = []; + customerSubTypeOptions: Array<{ value: string; label: string }> = []; + tooltipTargetAreasServed = 'tooltip-areasServed'; + tooltipTargetLicensed = 'tooltip-licensedIn'; + // subscriptions: StripeSubscription[] | any[]; + constructor( + public userService: UserService, + private geoService: GeoService, + public selectOptions: SelectOptionsService, + private cdref: ChangeDetectorRef, + private activatedRoute: ActivatedRoute, + private loadingService: LoadingService, + private imageUploadService: ImageService, + private imageService: ImageService, + private confirmationService: ConfirmationService, + private messageService: MessageService, + private sharedService: SharedService, + private titleCasePipe: TitleCasePipe, + private validationMessagesService: ValidationMessagesService, + // private subscriptionService: SubscriptionsService, + private datePipe: DatePipe, + private router: Router, + public authService: AuthService, + ) {} + async ngOnInit() { + this.id = this.activatedRoute.snapshot.params['id'] as string | undefined; + if (this.id) { + this.user = await this.userService.getById(this.id); + } else { + const token = await this.authService.getToken(); + const keycloakUser = map2User(token); + const email = keycloakUser.email; + this.user = await this.userService.getByMail(email); + } + + // this.subscriptions = await lastValueFrom(this.subscriptionService.getAllSubscriptions(this.user.email)); + // await this.synchronizeSubscriptions(this.subscriptions); + this.profileUrl = this.user.hasProfile ? `${this.env.imageBaseUrl}/pictures/profile/${emailToDirName(this.user.email)}.avif?_ts=${new Date().getTime()}` : `/assets/images/placeholder.png`; + this.companyLogoUrl = this.user.hasCompanyLogo ? `${this.env.imageBaseUrl}/pictures/logo/${emailToDirName(this.user.email)}.avif?_ts=${new Date().getTime()}` : `/assets/images/placeholder.png`; + + this.customerTypeOptions = this.selectOptions.customerTypes + // .filter(ct => ct.value === 'buyer' || ct.value === 'seller' || this.user.customerType === 'professional') + .map(type => ({ + value: type.value, + label: this.titleCasePipe.transform(type.name), + })); + + this.customerSubTypeOptions = this.selectOptions.customerSubTypes + // .filter(ct => ct.value !== 'broker' || this.user.customerSubType === 'broker') + .map(type => ({ + value: type.value, + label: this.titleCasePipe.transform(type.name), + })); + } + + ngOnDestroy() { + this.validationMessagesService.clearMessages(); // Löschen Sie alle bestehenden Validierungsnachrichten + } + printInvoice(invoice: Invoice) {} + + async updateProfile(user: User) { + try { + await this.userService.save(this.user); + this.userService.changeUser(this.user); + this.messageService.addMessage({ severity: 'success', text: 'Account changes have been persisted', duration: 3000 }); + this.validationMessagesService.clearMessages(); // Löschen Sie alle bestehenden Validierungsnachrichten + this.validationMessages = []; + } catch (error) { + this.messageService.addMessage({ + severity: 'danger', + text: 'An error occurred while saving the profile - Please check your inputs', + duration: 5000, + }); + if (error.error && Array.isArray(error.error?.message)) { + this.validationMessagesService.updateMessages(error.error.message); + this.validationMessages = error.error.message; + } + } + } + + onUploadCompanyLogo(event: any) { + const uniqueSuffix = '?_ts=' + new Date().getTime(); + this.companyLogoUrl = `${this.env.imageBaseUrl}/pictures/logo/${emailToDirName(this.user.email)}${uniqueSuffix}`; + } + onUploadProfilePicture(event: any) { + const uniqueSuffix = '?_ts=' + new Date().getTime(); + this.profileUrl = `${this.env.imageBaseUrl}/pictures/profile/${emailToDirName(this.user.email)}${uniqueSuffix}`; + } + setImageToFallback(event: Event) { + (event.target as HTMLImageElement).src = `/assets/images/placeholder.png`; // Pfad zum Platzhalterbild + } + + suggestions: string[] | undefined; + + async search(event: AutoCompleteCompleteEvent) { + const result = await lastValueFrom(this.geoService.findCitiesStartingWith(event.query)); + this.suggestions = result.map(r => `${r.name} - ${r.state}`).slice(0, 5); + } + addLicence() { + this.user.licensedIn.push({ registerNo: '', state: '' }); + } + removeLicence(index: number) { + this.user.licensedIn.splice(index, 1); + } + addArea() { + this.user.areasServed.push({ county: '', state: '' }); + } + removeArea(index: number) { + this.user.areasServed.splice(index, 1); + } + get isProfessional() { + return this.user.customerType === 'professional'; + } + uploadCompanyLogo() { + this.uploadParams = { type: 'uploadCompanyLogo', imagePath: emailToDirName(this.user.email) }; + } + uploadProfile() { + this.uploadParams = { type: 'uploadProfile', imagePath: emailToDirName(this.user.email) }; + } + async uploadFinished(response: UploadReponse) { + if (response.success) { + if (response.type === 'uploadCompanyLogo') { + this.user.hasCompanyLogo = true; // + this.companyLogoUrl = `${this.env.imageBaseUrl}/pictures/logo/${emailToDirName(this.user.email)}.avif?_ts=${new Date().getTime()}`; + } else { + this.user.hasProfile = true; + this.profileUrl = `${this.env.imageBaseUrl}/pictures/profile/${emailToDirName(this.user.email)}.avif?_ts=${new Date().getTime()}`; + this.sharedService.changeProfilePhoto(this.profileUrl); + } + this.userService.changeUser(this.user); + await this.userService.saveGuaranteed(this.user); + } + } + async deleteConfirm(type: 'profile' | 'logo') { + const confirmed = await this.confirmationService.showConfirmation({ message: `Do you want to delete your ${type === 'logo' ? 'Logo' : 'Profile'} image` }); + if (confirmed) { + if (type === 'profile') { + this.user.hasProfile = false; + await Promise.all([this.imageService.deleteProfileImagesByMail(this.user.email), this.userService.saveGuaranteed(this.user)]); + } else { + this.user.hasCompanyLogo = false; + await Promise.all([this.imageService.deleteLogoImagesByMail(this.user.email), this.userService.saveGuaranteed(this.user)]); + } + this.user = await this.userService.getById(this.user.id); + // this.messageService.showMessage('Image deleted'); + this.messageService.addMessage({ + severity: 'success', + text: 'Image deleted.', + duration: 3000, // 3 seconds + }); + } + } + getValidationMessage(fieldName: string): string { + const message = this.validationMessages.find(msg => msg.field === fieldName); + return message ? message.message : ''; + } + + setState(index: number, state: string) { + if (state === null) { + this.user.areasServed[index].county = null; + } + } + // getLevel(i: number) { + // return this.subscriptions[i].metadata.plan; + // } + // getStartDate(i: number) { + // return this.datePipe.transform(new Date(this.subscriptions[i].start_date * 1000)); + // } + // getEndDate(i: number) { + // return this.subscriptions[i].status === 'trialing' ? this.datePipe.transform(new Date(this.subscriptions[i].current_period_end * 1000)) : '---'; + // } + // getNextSettlement(i: number) { + // return this.subscriptions[i].status === 'active' ? this.datePipe.transform(new Date(this.subscriptions[i].current_period_end * 1000)) : '---'; + // } + // getStatus(i: number) { + // return this.subscriptions[i].status ? this.subscriptions[i].status : ''; + // } +} diff --git a/bizmatch-client/src/app/pages/business-listings/business-listings.component.html b/bizmatch-client/src/app/pages/business-listings/business-listings.component.html new file mode 100644 index 0000000..e61bbb2 --- /dev/null +++ b/bizmatch-client/src/app/pages/business-listings/business-listings.component.html @@ -0,0 +1,110 @@ +
+ @if(listings?.length>0){ +
+ + @for (listing of listings; track listing.id) { +
+ +
+
+ + + {{ selectOptions.getBusiness(listing.type) }} + +
+

+ + {{ listing.title }} + @if(listing.draft){ + Draft + } +

+
+ + + {{ selectOptions.getState(listing.location.state) }} + +

+ {{ getDaysListed(listing) }} days listed +

+
+ +

+ Asking price: {{ listing.price | currency : 'USD' : 'symbol' : '1.0-0' }} +

+

Sales revenue: {{ listing.salesRevenue | currency : 'USD' : 'symbol' : '1.0-0' }}

+

Net profit: {{ listing.cashFlow | currency : 'USD' : 'symbol' : '1.0-0' }}

+

Location: {{ listing.location.name ? listing.location.name : listing.location.county }}

+

Established: {{ listing.established }}

+ + Company logo + +
+ +
+
+ } +
+ } @else if (listings?.length===0){ +
+
+ + + + + + + + + + + + + + + + + +
+

There’s no listing here

+

Try changing your filters to
see listings

+
+ + +
+
+
+
+ } +
+ +@if(pageCount>1){ + +} diff --git a/bizmatch-client/src/app/pages/business-listings/business-listings.component.scss b/bizmatch-client/src/app/pages/business-listings/business-listings.component.scss new file mode 100644 index 0000000..b2c131c --- /dev/null +++ b/bizmatch-client/src/app/pages/business-listings/business-listings.component.scss @@ -0,0 +1,32 @@ +// #sky-line { +// background-image: url(../../../../assets/images/bw-sky.jpg); +// height: 204px; +// background-position: bottom; +// background-size: cover; +// margin-bottom: -1px; +// } +// .search { +// background-color: #343f69; +// } +// ::ng-deep p-paginator div { +// background-color: var(--surface-200) !important; +// } +// .icon-pos { +// position: absolute; +// bottom: 1.5rem; +// right: 1.5rem; +// } +// .rounded-image { +// border-radius: 6px; +// max-width: 100px; +// height: 35px; +// border: 1px solid rgba(0, 0, 0, 0.2); +// padding: 1px 1px; +// object-fit: contain; +// } +// ::ng-deep span.p-button-label { +// font-weight: 500; +// } +:host { + width: 100%; +} diff --git a/bizmatch-client/src/app/pages/business-listings/business-listings.component.ts b/bizmatch-client/src/app/pages/business-listings/business-listings.component.ts new file mode 100644 index 0000000..062cd8b --- /dev/null +++ b/bizmatch-client/src/app/pages/business-listings/business-listings.component.ts @@ -0,0 +1,118 @@ +import { CommonModule } from '@angular/common'; +import { ChangeDetectorRef, Component } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { ActivatedRoute, Router, RouterModule } from '@angular/router'; +import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; +import dayjs from 'dayjs'; +import { BusinessListing } from '../../../../../bizmatch-server/src/models/db.model'; +import { BusinessListingCriteria, emailToDirName, LISTINGS_PER_PAGE, ListingType } from '../../../../../bizmatch-server/src/models/main.model'; +import { environment } from '../../../environments/environment'; +import { PaginatorComponent } from '../../components/paginator/paginator.component'; +import { CriteriaChangeService } from '../../services/criteria-change.service'; +import { ListingsService } from '../../services/listings.service'; +import { ModalService } from '../../services/modal.service'; +import { SearchService } from '../../services/search.service'; +import { SelectOptionsService } from '../../services/select-options.service'; +import { assignProperties, getCriteriaProxy, resetBusinessListingCriteria } from '../../utils/utils'; + +@UntilDestroy() +@Component({ + selector: 'app-business-listings', + standalone: true, + imports: [CommonModule, FormsModule, RouterModule, PaginatorComponent], + templateUrl: './business-listings.component.html', + styleUrls: ['./business-listings.component.scss'], +}) +export class BusinessListingsComponent { + environment = environment; + listings: Array; + filteredListings: Array; + criteria: BusinessListingCriteria; + realEstateChecked: boolean; + maxPrice: string; + minPrice: string; + type: string; + state: string; + totalRecords: number = 0; + ts = new Date().getTime(); + first: number = 0; + rows: number = 12; + env = environment; + public category: 'business' | 'commercialProperty' | 'professionals_brokers' | undefined; + page = 1; + pageCount = 1; + emailToDirName = emailToDirName; + constructor( + public selectOptions: SelectOptionsService, + private listingsService: ListingsService, + private activatedRoute: ActivatedRoute, + private router: Router, + private cdRef: ChangeDetectorRef, + private route: ActivatedRoute, + private searchService: SearchService, + private modalService: ModalService, + private criteriaChangeService: CriteriaChangeService, + ) { + this.criteria = getCriteriaProxy('businessListings', this) as BusinessListingCriteria; + this.init(); + this.searchService.currentCriteria.pipe(untilDestroyed(this)).subscribe(criteria => { + if (criteria && criteria.criteriaType === 'businessListings') { + this.criteria = criteria as BusinessListingCriteria; + this.search(); + } + }); + } + async ngOnInit() { + this.search(); + } + async init() { + this.reset(); + } + + async search() { + const listingReponse = await this.listingsService.getListings(this.criteria); + this.listings = listingReponse.results; + this.totalRecords = listingReponse.totalCount; + this.pageCount = this.totalRecords % LISTINGS_PER_PAGE === 0 ? this.totalRecords / LISTINGS_PER_PAGE : Math.floor(this.totalRecords / LISTINGS_PER_PAGE) + 1; + this.page = this.criteria.page ? this.criteria.page : 1; + this.cdRef.markForCheck(); + this.cdRef.detectChanges(); + } + onPageChange(page: any) { + this.criteria.start = (page - 1) * LISTINGS_PER_PAGE; + this.criteria.length = LISTINGS_PER_PAGE; + this.criteria.page = page; + this.search(); + } + imageErrorHandler(listing: ListingType) {} + reset() { + this.criteria.title = null; + } + getDaysListed(listing: BusinessListing) { + return dayjs().diff(listing.created, 'day'); + } + // New methods for filter actions + clearAllFilters() { + // Reset criteria to default values + resetBusinessListingCriteria(this.criteria); + + // Reset pagination + this.criteria.page = 1; + this.criteria.start = 0; + + this.criteriaChangeService.notifyCriteriaChange(); + + // Search with cleared filters + this.searchService.search(this.criteria); + } + + async openFilterModal() { + // Open the search modal with current criteria + const modalResult = await this.modalService.showModal(this.criteria); + if (modalResult.accepted) { + this.searchService.search(this.criteria); + } else { + this.criteria = assignProperties(this.criteria, modalResult.criteria); + } + } +} diff --git a/bizmatch-client/src/app/pages/details-business-listing/details-business-listing.component.html b/bizmatch-client/src/app/pages/details-business-listing/details-business-listing.component.html new file mode 100644 index 0000000..91e79bf --- /dev/null +++ b/bizmatch-client/src/app/pages/details-business-listing/details-business-listing.component.html @@ -0,0 +1,96 @@ +
+
+ + @if(listing){ +
+ +
+

{{ listing.title }}

+

+ +
+
+
{{ detail.label }}
+ +
{{ detail.value }}
+ +
+ + +
+
+
+ @if(listing && listingUser && (listingUser?.email===user?.email || (authService.isAdmin() | async))){ +
+ +
+ } @if(user){ +
+ +
+ } + + +
+ +
+ + + + +
+ + +
+ + +
+ +
Contact the Author of this Listing
+

Please include your contact info below

+
+
+ + +
+ +
+ + + +
+ +
+ +
+ +
+
+
+ } +
+
diff --git a/bizmatch-client/src/app/pages/details-business-listing/details-business-listing.component.ts b/bizmatch-client/src/app/pages/details-business-listing/details-business-listing.component.ts new file mode 100644 index 0000000..b925b06 --- /dev/null +++ b/bizmatch-client/src/app/pages/details-business-listing/details-business-listing.component.ts @@ -0,0 +1,212 @@ +import { ChangeDetectorRef, Component } from '@angular/core'; +import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; +import { ActivatedRoute, NavigationEnd, Router, RouterModule } from '@angular/router'; +import { ShareButton } from 'ngx-sharebuttons/button'; +import { lastValueFrom } from 'rxjs'; + +// Import für Leaflet +// Benannte Importe für Leaflet +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import dayjs from 'dayjs'; +import { BusinessListing, EventTypeEnum, ShareByEMail, User } from '../../../../../bizmatch-server/src/models/db.model'; +import { KeycloakUser, MailInfo } from '../../../../../bizmatch-server/src/models/main.model'; +import { environment } from '../../../environments/environment'; +import { EMailService } from '../../components/email/email.service'; +import { ValidatedInputComponent } from '../../components/validated-input/validated-input.component'; +import { ValidatedNgSelectComponent } from '../../components/validated-ng-select/validated-ng-select.component'; +import { ValidatedTextareaComponent } from '../../components/validated-textarea/validated-textarea.component'; +import { ValidationMessagesService } from '../../components/validation-messages.service'; +import { AuditService } from '../../services/audit.service'; +import { AuthService } from '../../services/auth.service'; +import { GeoService } from '../../services/geo.service'; +import { HistoryService } from '../../services/history.service'; +import { ListingsService } from '../../services/listings.service'; +import { MailService } from '../../services/mail.service'; +import { MessageService } from '../../services/message.service'; +import { SelectOptionsService } from '../../services/select-options.service'; +import { UserService } from '../../services/user.service'; +import { createMailInfo, map2User } from '../../utils/utils'; + +@Component({ + selector: 'app-details-business-listing', + standalone: true, + imports: [CommonModule, FormsModule, RouterModule, FontAwesomeModule, ValidatedInputComponent, ValidatedTextareaComponent, ShareButton, ValidatedNgSelectComponent], + providers: [], + templateUrl: './details-business-listing.component.html', +}) +export class DetailsBusinessListingComponent { + // listings: Array; + responsiveOptions = [ + { + breakpoint: '1199px', + numVisible: 1, + numScroll: 1, + }, + { + breakpoint: '991px', + numVisible: 2, + numScroll: 1, + }, + { + breakpoint: '767px', + numVisible: 1, + numScroll: 1, + }, + ]; + private id: string | undefined; + listing: BusinessListing; + mailinfo: MailInfo; + environment = environment; + keycloakUser: KeycloakUser; + user: User; + listingUser: User; + description: SafeHtml; + private history: string[] = []; + ts = new Date().getTime(); + env = environment; + + constructor( + private activatedRoute: ActivatedRoute, + private listingsService: ListingsService, + private router: Router, + private userService: UserService, + public selectOptions: SelectOptionsService, + private mailService: MailService, + private sanitizer: DomSanitizer, + public historyService: HistoryService, + private validationMessagesService: ValidationMessagesService, + private messageService: MessageService, + private auditService: AuditService, + public emailService: EMailService, + private geoService: GeoService, + public authService: AuthService, + private cdref: ChangeDetectorRef, + ) { + this.router.events.subscribe(event => { + if (event instanceof NavigationEnd) { + this.history.push(event.urlAfterRedirects); + } + }); + this.mailinfo = { sender: {}, email: '', url: environment.mailinfoUrl }; + this.id = this.activatedRoute.snapshot.params['id'] as string | undefined; + } + + async ngOnInit() { + const token = await this.authService.getToken(); + this.keycloakUser = map2User(token); + if (this.keycloakUser) { + this.user = await this.userService.getByMail(this.keycloakUser.email); + this.mailinfo = createMailInfo(this.user); + } + try { + this.listing = await lastValueFrom(this.listingsService.getListingById(this.id)); + this.auditService.createEvent(this.listing.id, 'view', this.user?.email); + this.listingUser = await this.userService.getByMail(this.listing.email); + this.description = this.sanitizer.bypassSecurityTrustHtml(this.listing.description); + } catch (error) { + this.auditService.log({ severity: 'error', text: error.error.message }); + this.router.navigate(['notfound']); + } + } + + ngOnDestroy() { + this.validationMessagesService.clearMessages(); // Löschen Sie alle bestehenden Validierungsnachrichten + } + + async mail() { + try { + this.mailinfo.email = this.listingUser.email; + this.mailinfo.listing = this.listing; + await this.mailService.mail(this.mailinfo); + this.validationMessagesService.clearMessages(); + this.auditService.createEvent(this.listing.id, 'contact', this.user?.email, this.mailinfo.sender); + 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', + text: 'An error occurred while sending the request - Please check your inputs', + duration: 5000, + }); + if (error.error && Array.isArray(error.error?.message)) { + this.validationMessagesService.updateMessages(error.error.message); + } + } + } + get listingDetails() { + let typeOfRealEstate = ''; + if (this.listing.realEstateIncluded) { + typeOfRealEstate = 'Real Estate Included'; + } else if (this.listing.leasedLocation) { + typeOfRealEstate = 'Leased Location'; + } else if (this.listing.franchiseResale) { + typeOfRealEstate = 'Franchise Re-Sale'; + } + const result = [ + { label: 'Category', value: this.selectOptions.getBusiness(this.listing.type) }, + { label: 'Located in', value: `${this.listing.location.name ? this.listing.location.name : this.listing.location.county}, ${this.selectOptions.getState(this.listing.location.state)}` }, + { label: 'Asking Price', value: `${this.listing.price ? `$${this.listing.price.toLocaleString()}` : ''}` }, + { label: 'Sales revenue', value: `${this.listing.salesRevenue ? `$${this.listing.salesRevenue.toLocaleString()}` : ''}` }, + { label: 'Cash flow', value: `${this.listing.cashFlow ? `$${this.listing.cashFlow.toLocaleString()}` : ''}` }, + { label: 'Type of Real Estate', value: typeOfRealEstate }, + { label: 'Employees', value: this.listing.employees }, + { label: 'Established since', value: this.listing.established }, + { label: 'Support & Training', value: this.listing.supportAndTraining }, + { label: 'Reason for Sale', value: this.listing.reasonForSale }, + { label: 'Broker licensing', value: this.listing.brokerLicencing }, + { label: 'Listed since', value: `${this.dateInserted()} - ${this.getDaysListed()} days` }, + { + label: 'Listing by', + value: null, // Wird nicht verwendet + isHtml: true, + isListingBy: true, // Flag für den speziellen Fall + user: this.listingUser, // Übergebe das User-Objekt + imagePath: this.listing.imageName, + imageBaseUrl: this.env.imageBaseUrl, + ts: this.ts, + }, + ]; + if (this.listing.draft) { + result.push({ label: 'Draft', value: this.listing.draft ? 'Yes' : 'No' }); + } + return result; + } + save() { + this.listing.favoritesForUser.push(this.user.email); + this.listingsService.save(this.listing); + this.auditService.createEvent(this.listing.id, 'favorite', this.user?.email); + } + isAlreadyFavorite() { + return this.listing.favoritesForUser.includes(this.user.email); + } + async showShareByEMail() { + const result = await this.emailService.showShareByEMail({ + yourEmail: this.user ? this.user.email : null, + yourName: this.user ? `${this.user.firstname} ${this.user.lastname}` : null, + url: environment.mailinfoUrl, + listingTitle: this.listing.title, + id: this.listing.id, + type: 'business', + }); + if (result) { + this.auditService.createEvent(this.listing.id, 'email', this.user?.email, result); + this.messageService.addMessage({ + severity: 'success', + text: 'Your Email has beend sent', + duration: 5000, + }); + } + } + + createEvent(eventType: EventTypeEnum) { + this.auditService.createEvent(this.listing.id, eventType, this.user?.email); + } + getDaysListed() { + return dayjs().diff(this.listing.created, 'day'); + } + dateInserted() { + return dayjs(this.listing.created).format('DD/MM/YYYY'); + } +} diff --git a/bizmatch-client/src/app/pages/edit-business-listing/edit-business-listing.component.html b/bizmatch-client/src/app/pages/edit-business-listing/edit-business-listing.component.html new file mode 100644 index 0000000..3e0801b --- /dev/null +++ b/bizmatch-client/src/app/pages/edit-business-listing/edit-business-listing.component.html @@ -0,0 +1,382 @@ +
+
+

Edit Listing

+ @if(listing){ +
+
+ + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + + + +
+ + +
+ + +
+ + + + + +
+ + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + +
+ + +
+
+ + + + + @for (licensedIn of listingUser?.licensedIn; track listingUser?.licensedIn) { + {{ licensedIn.state }} {{ licensedIn.registerNo }} + } + +
+ + +
+ + +
+ +
+ +
+ +
+ @if (mode==='create'){ + + } @else { + + } +
+ } +
+
+ + diff --git a/bizmatch-client/src/app/pages/edit-business-listing/edit-business-listing.component.scss b/bizmatch-client/src/app/pages/edit-business-listing/edit-business-listing.component.scss new file mode 100644 index 0000000..81411a5 --- /dev/null +++ b/bizmatch-client/src/app/pages/edit-business-listing/edit-business-listing.component.scss @@ -0,0 +1,34 @@ +:host { + display: block; + font-family: 'Inter', sans-serif; +} + +// .container { +// max-width: 100%; +// margin: 0 auto; +// } + +:host ::ng-deep quill-editor { + .ql-container { + min-height: 200px; + } +} + +// input[type='checkbox'] { +// &:checked + .dot { +// transform: translateX(100%); +// } +// &:checked + .block { +// background-color: #4299e1; +// } +// } + +.dot { + transition: all 0.3s ease-in-out; +} +::ng-deep .ng-select.ng-select-single .ng-select-container { + height: 42px; +} +quill-editor { + width: 100%; +} diff --git a/bizmatch-client/src/app/pages/edit-business-listing/edit-business-listing.component.ts b/bizmatch-client/src/app/pages/edit-business-listing/edit-business-listing.component.ts new file mode 100644 index 0000000..a1959fc --- /dev/null +++ b/bizmatch-client/src/app/pages/edit-business-listing/edit-business-listing.component.ts @@ -0,0 +1,179 @@ +import { Component } from '@angular/core'; +import { ActivatedRoute, NavigationEnd, Router, RouterModule } from '@angular/router'; +import { lastValueFrom } from 'rxjs'; + +import { DragDropModule } from '@angular/cdk/drag-drop'; +import { faTrash } from '@fortawesome/free-solid-svg-icons'; +import { QuillModule } from 'ngx-quill'; + +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { NgSelectModule } from '@ng-select/ng-select'; +import { NgxCurrencyDirective } from 'ngx-currency'; +import { BusinessListing, CommercialPropertyListing, User } from '../../../../../bizmatch-server/src/models/db.model'; +import { AutoCompleteCompleteEvent, createDefaultBusinessListing, emailToDirName, ImageProperty } from '../../../../../bizmatch-server/src/models/main.model'; +import { environment } from '../../../environments/environment'; +import { ValidatedCityComponent } from '../../components/validated-city/validated-city.component'; +import { ValidatedInputComponent } from '../../components/validated-input/validated-input.component'; +import { ValidatedLocationComponent } from '../../components/validated-location/validated-location.component'; +import { ValidatedNgSelectComponent } from '../../components/validated-ng-select/validated-ng-select.component'; +import { ValidatedPriceComponent } from '../../components/validated-price/validated-price.component'; +import { ValidatedQuillComponent } from '../../components/validated-quill/validated-quill.component'; +import { ValidatedTextareaComponent } from '../../components/validated-textarea/validated-textarea.component'; +import { ValidationMessagesService } from '../../components/validation-messages.service'; +import { ArrayToStringPipe } from '../../pipes/array-to-string.pipe'; +import { AuthService } from '../../services/auth.service'; +import { GeoService } from '../../services/geo.service'; +import { ImageService } from '../../services/image.service'; +import { ListingsService } from '../../services/listings.service'; +import { LoadingService } from '../../services/loading.service'; +import { MessageService } from '../../services/message.service'; +import { SelectOptionsService } from '../../services/select-options.service'; +import { UserService } from '../../services/user.service'; +import { map2User, routeListingWithState, TOOLBAR_OPTIONS } from '../../utils/utils'; + +@Component({ + selector: 'business-listing', + standalone: true, + imports: [ + CommonModule, + FormsModule, + RouterModule, + FontAwesomeModule, + ArrayToStringPipe, + DragDropModule, + QuillModule, + NgxCurrencyDirective, + NgSelectModule, + ValidatedInputComponent, + ValidatedQuillComponent, + ValidatedNgSelectComponent, + ValidatedPriceComponent, + ValidatedTextareaComponent, + ValidatedCityComponent, + ValidatedLocationComponent, + ], + providers: [], + templateUrl: './edit-business-listing.component.html', + styleUrl: './edit-business-listing.component.scss', +}) +export class EditBusinessListingComponent { + listingsCategory = 'business'; + category: string; + location: string; + mode: 'edit' | 'create'; + separator: '\n\n'; + listing: BusinessListing; + private id: string | undefined; + user: User; + environment = environment; + config = { aspectRatio: 16 / 9 }; + editorModules = TOOLBAR_OPTIONS; + draggedImage: ImageProperty; + faTrash = faTrash; + data: CommercialPropertyListing; + typesOfBusiness = []; + quillModules = { + toolbar: [['bold', 'italic', 'underline', 'strike'], [{ list: 'ordered' }, { list: 'bullet' }], [{ header: [1, 2, 3, 4, 5, 6, false] }], [{ color: [] }, { background: [] }], ['clean']], + }; + listingUser: User; + constructor( + public selectOptions: SelectOptionsService, + private router: Router, + private activatedRoute: ActivatedRoute, + private listingsService: ListingsService, + public userService: UserService, + private geoService: GeoService, + private imageService: ImageService, + private loadingService: LoadingService, + private messageService: MessageService, + private route: ActivatedRoute, + private validationMessagesService: ValidationMessagesService, + private authService: AuthService, + ) { + this.router.events.subscribe(event => { + if (event instanceof NavigationEnd) { + this.mode = event.url.startsWith('/createBusinessListing') ? 'create' : 'edit'; + } + }); + this.route.data.subscribe(async () => { + if (this.router.getCurrentNavigation().extras.state) { + this.data = this.router.getCurrentNavigation().extras.state['data']; + } + }); + this.typesOfBusiness = selectOptions.typesOfBusiness.map(e => { + return { name: e.name, value: e.value }; + }); + this.id = this.activatedRoute.snapshot.params['id'] as string | undefined; + } + async ngOnInit() { + const token = await this.authService.getToken(); + const keycloakUser = map2User(token); + this.listingUser = await this.userService.getByMail(keycloakUser.email); + if (this.mode === 'edit') { + this.listing = await lastValueFrom(this.listingsService.getListingById(this.id)); + } else { + this.listing = createDefaultBusinessListing(); + this.listing.email = this.listingUser.email; + this.listing.imageName = emailToDirName(keycloakUser.email); + if (this.data) { + this.listing.title = this.data?.title; + this.listing.description = this.data?.description; + } + } + } + ngOnDestroy() { + this.validationMessagesService.clearMessages(); // Löschen Sie alle bestehenden Validierungsnachrichten + } + async save() { + try { + this.listing = await this.listingsService.save(this.listing); + this.router.navigate(['editBusinessListing', this.listing.id]); + this.messageService.addMessage({ severity: 'success', text: 'Listing changes have been persisted', duration: 3000 }); + this.validationMessagesService.clearMessages(); // Löschen Sie alle bestehenden Validierungsnachrichten + } catch (error) { + this.messageService.addMessage({ + severity: 'danger', + text: 'An error occurred while saving the profile - Please check your inputs', + duration: 5000, + }); + if (error.error && Array.isArray(error.error?.message)) { + this.validationMessagesService.updateMessages(error.error.message); + } + } + } + + suggestions: string[] | undefined; + + async search(event: AutoCompleteCompleteEvent) { + const result = await lastValueFrom(this.geoService.findCitiesStartingWith(event.query)); + this.suggestions = result.map(r => r.name).slice(0, 5); + } + + changeListingCategory(value: 'business' | 'commercialProperty') { + routeListingWithState(this.router, value, this.listing); + } + onNumericInputChange(value: string, modelProperty: string): void { + const newValue = value === '' ? null : +value; + this.setPropertyByPath(this, modelProperty, newValue); + } + + private setPropertyByPath(obj: any, path: string, value: any): void { + const keys = path.split('.'); + let target = obj; + for (let i = 0; i < keys.length - 1; i++) { + target = target[keys[i]]; + } + target[keys[keys.length - 1]] = value; + } + onCheckboxChange(checkbox: string, value: boolean) { + // 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] = value; + } +} diff --git a/bizmatch-client/src/app/pages/email-authorized/email-authorized.component.html b/bizmatch-client/src/app/pages/email-authorized/email-authorized.component.html new file mode 100644 index 0000000..b9dd44d --- /dev/null +++ b/bizmatch-client/src/app/pages/email-authorized/email-authorized.component.html @@ -0,0 +1,35 @@ +
+
+ + +
+
+
+

Verifying your email address...

+
+ + + +
+ + + +
+

Your email has been verified

+

You will be redirected to your account page in 5 seconds

+ Go to Account Page Now +
+ + + +
+ + + +
+

Verification Failed

+

{{ errorMessage }}

+ Return to Login +
+
+
diff --git a/bizmatch-client/src/app/pages/email-authorized/email-authorized.component.ts b/bizmatch-client/src/app/pages/email-authorized/email-authorized.component.ts new file mode 100644 index 0000000..de82ccb --- /dev/null +++ b/bizmatch-client/src/app/pages/email-authorized/email-authorized.component.ts @@ -0,0 +1,68 @@ +import { CommonModule } from '@angular/common'; +import { HttpClient } from '@angular/common/http'; +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router, RouterModule } from '@angular/router'; +import { environment } from '../../../environments/environment'; +import { AuthService } from '../../services/auth.service'; +import { UserService } from '../../services/user.service'; + +@Component({ + selector: 'app-email-authorized', + standalone: true, + imports: [CommonModule, RouterModule], + templateUrl: './email-authorized.component.html', +}) +export class EmailAuthorizedComponent implements OnInit { + verificationStatus: 'pending' | 'success' | 'error' = 'pending'; + errorMessage: string | null = null; + + constructor(private route: ActivatedRoute, private router: Router, private http: HttpClient, private authService: AuthService, private userService: UserService) {} + + ngOnInit(): void { + const oobCode = this.route.snapshot.queryParamMap.get('oobCode'); + const email = this.route.snapshot.queryParamMap.get('email'); + const mode = this.route.snapshot.queryParamMap.get('mode'); + + if (mode === 'verifyEmail' && oobCode && email) { + this.verifyEmail(oobCode, email); + } else { + this.verificationStatus = 'error'; + this.errorMessage = 'Invalid verification link'; + } + } + + private verifyEmail(oobCode: string, email: string): void { + this.http.post<{ message: string; token: string }>(`${environment.apiBaseUrl}/bizmatch/auth/verify-email`, { oobCode, email }).subscribe({ + next: async response => { + this.verificationStatus = 'success'; + + try { + // Use the custom token from the server to sign in with Firebase + await this.authService.signInWithCustomToken(response.token); + + // Try to get user info + try { + const user = await this.userService.getByMail(email); + console.log('User retrieved:', user); + } catch (userError) { + console.error('Error getting user:', userError); + // Don't change verification status - it's still a success + } + + // Redirect to dashboard after a short delay + setTimeout(() => { + this.router.navigate(['/account']); + }, 5000); + } catch (authError) { + console.error('Error signing in with custom token:', authError); + // Keep success status for verification, but add warning about login + this.errorMessage = 'Email verified, but there was an issue signing you in. Please try logging in manually.'; + } + }, + error: err => { + this.verificationStatus = 'error'; + this.errorMessage = err.error?.message || 'Verification failed'; + }, + }); + } +} diff --git a/bizmatch-client/src/app/pages/email-us/email-us.component.html b/bizmatch-client/src/app/pages/email-us/email-us.component.html new file mode 100644 index 0000000..a40bdd3 --- /dev/null +++ b/bizmatch-client/src/app/pages/email-us/email-us.component.html @@ -0,0 +1,29 @@ +
+
+

Contact Us

+
+
+ + +
+
+ +
+ +
+
+
+ +
+
+ +
+
+
+
diff --git a/bizmatch-client/src/app/pages/email-us/email-us.component.scss b/bizmatch-client/src/app/pages/email-us/email-us.component.scss new file mode 100644 index 0000000..65f1175 --- /dev/null +++ b/bizmatch-client/src/app/pages/email-us/email-us.component.scss @@ -0,0 +1,7 @@ +:host ::ng-deep .ng-select-container { + height: 42px !important; + border-radius: 0.5rem; + .ng-value-container .ng-input { + top: 10px; + } +} diff --git a/bizmatch-client/src/app/pages/email-us/email-us.component.ts b/bizmatch-client/src/app/pages/email-us/email-us.component.ts new file mode 100644 index 0000000..db827b6 --- /dev/null +++ b/bizmatch-client/src/app/pages/email-us/email-us.component.ts @@ -0,0 +1,77 @@ +import { CommonModule } from '@angular/common'; +import { Component } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { User } from '../../../../../bizmatch-server/src/models/db.model'; +import { ErrorResponse, KeycloakUser, MailInfo } from '../../../../../bizmatch-server/src/models/main.model'; +import { ValidatedInputComponent } from '../../components/validated-input/validated-input.component'; +import { ValidatedNgSelectComponent } from '../../components/validated-ng-select/validated-ng-select.component'; +import { ValidatedTextareaComponent } from '../../components/validated-textarea/validated-textarea.component'; +import { ValidationMessagesService } from '../../components/validation-messages.service'; +import { AuditService } from '../../services/audit.service'; +import { AuthService } from '../../services/auth.service'; +import { MailService } from '../../services/mail.service'; +import { MessageService } from '../../services/message.service'; +import { SelectOptionsService } from '../../services/select-options.service'; +import { UserService } from '../../services/user.service'; +import { createMailInfo, map2User } from '../../utils/utils'; + +@Component({ + selector: 'app-email-us', + standalone: true, + imports: [CommonModule, FormsModule, RouterModule, FontAwesomeModule, ValidatedInputComponent, ValidatedTextareaComponent, ValidatedNgSelectComponent], + providers: [], + templateUrl: './email-us.component.html', + styleUrl: './email-us.component.scss', +}) +export class EmailUsComponent { + mailinfo: MailInfo; + keycloakUser: KeycloakUser; + user: User; + errorResponse: ErrorResponse; + constructor( + private mailService: MailService, + private userService: UserService, + private validationMessagesService: ValidationMessagesService, + private messageService: MessageService, + public selectOptions: SelectOptionsService, + private auditService: AuditService, + private authService: AuthService, + ) { + this.mailinfo = createMailInfo(); + } + async ngOnInit() { + const token = await this.authService.getToken(); + this.keycloakUser = map2User(token); + if (this.keycloakUser) { + this.user = await this.userService.getByMail(this.keycloakUser.email); + this.mailinfo = createMailInfo(this.user); + } + } + ngOnDestroy() { + this.validationMessagesService.clearMessages(); // Löschen Sie alle bestehenden Validierungsnachrichten + } + async mail() { + try { + this.validationMessagesService.updateMessages([]); + 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.auditService.createEvent(null, 'emailus', this.mailinfo.email, this.mailinfo); + this.mailinfo = createMailInfo(this.user); + } catch (error) { + this.messageService.addMessage({ + severity: 'danger', + text: 'Please check your inputs', + duration: 5000, + }); + if (error.error && Array.isArray(error.error?.message)) { + this.validationMessagesService.updateMessages(error.error.message); + } + } + } + containsError(fieldname: string) { + return this.errorResponse?.fields.map(f => f.fieldname).includes(fieldname); + } +} diff --git a/bizmatch-client/src/app/pages/email-verification/email-verification.component.html b/bizmatch-client/src/app/pages/email-verification/email-verification.component.html new file mode 100644 index 0000000..ff0dd88 --- /dev/null +++ b/bizmatch-client/src/app/pages/email-verification/email-verification.component.html @@ -0,0 +1,7 @@ +
+
+

Email Verification

+

A verification email has been sent to your email address. Please check your inbox and click the link to verify your account.

+

Once verified, please return to the application.

+
+
diff --git a/bizmatch-client/src/app/pages/email-verification/email-verification.component.ts b/bizmatch-client/src/app/pages/email-verification/email-verification.component.ts new file mode 100644 index 0000000..79f44b7 --- /dev/null +++ b/bizmatch-client/src/app/pages/email-verification/email-verification.component.ts @@ -0,0 +1,9 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-email-verification', + standalone: true, + imports: [], + templateUrl: './email-verification.component.html', +}) +export class EmailVerificationComponent {} diff --git a/bizmatch-client/src/app/pages/favorites/favorites.component.html b/bizmatch-client/src/app/pages/favorites/favorites.component.html new file mode 100644 index 0000000..f42ab5d --- /dev/null +++ b/bizmatch-client/src/app/pages/favorites/favorites.component.html @@ -0,0 +1,85 @@ +
+
+

My Favorites

+ + + + + +
+
+

{{ listing.title }}

+

Category: {{ listing.listingsCategory === 'commercialProperty' ? 'Commercial Property' : 'Business' }}

+

Located in: {{ listing.location.name ? listing.location.name : listing.location.county }}, {{ listing.location.state }}

+

Price: ${{ listing.price.toLocaleString() }}

+
+ @if(listing.listingsCategory==='business'){ + + + } @if(listing.listingsCategory==='commercialProperty'){ + + } + +
+
+
+ + +
+
+ diff --git a/bizmatch-client/src/app/pages/favorites/favorites.component.scss b/bizmatch-client/src/app/pages/favorites/favorites.component.scss new file mode 100644 index 0000000..08b3339 --- /dev/null +++ b/bizmatch-client/src/app/pages/favorites/favorites.component.scss @@ -0,0 +1,3 @@ +.wide-column{ + width: 40%; +} \ No newline at end of file diff --git a/bizmatch-client/src/app/pages/favorites/favorites.component.ts b/bizmatch-client/src/app/pages/favorites/favorites.component.ts new file mode 100644 index 0000000..c71c3b9 --- /dev/null +++ b/bizmatch-client/src/app/pages/favorites/favorites.component.ts @@ -0,0 +1,43 @@ +import { CommonModule } from '@angular/common'; +import { Component } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { BusinessListing } from '../../../../../bizmatch-server/src/models/db.model'; +import { KeycloakUser } from '../../../../../bizmatch-server/src/models/main.model'; +import { ConfirmationComponent } from '../../components/confirmation.component'; +import { AuthService } from '../../services/auth.service'; +import { ConfirmationService } from '../../services/confirmation.service'; +import { ListingsService } from '../../services/listings.service'; +import { SelectOptionsService } from '../../services/select-options.service'; +import { map2User } from '../../utils/utils'; + +@Component({ + selector: 'app-favorites', + standalone: true, + imports: [CommonModule, FormsModule, RouterModule, FontAwesomeModule, ConfirmationComponent], + templateUrl: './favorites.component.html', + styleUrl: './favorites.component.scss', +}) +export class FavoritesComponent { + user: KeycloakUser; + // listings: Array = []; //= dataListings as unknown as Array; + favorites: Array; + constructor(private listingsService: ListingsService, public selectOptions: SelectOptionsService, private confirmationService: ConfirmationService, private authService: AuthService) {} + async ngOnInit() { + const token = await this.authService.getToken(); + this.user = map2User(token); + this.favorites = await this.listingsService.getFavoriteListings(); + } + async confirmDelete(listing: BusinessListing) { + const confirmed = await this.confirmationService.showConfirmation({ message: `Are you sure you want to remove this listing from your Favorites?` }); + if (confirmed) { + // this.messageService.showMessage('Listing has been deleted'); + this.deleteListing(listing); + } + } + async deleteListing(listing: BusinessListing) { + await this.listingsService.removeFavorite(listing.id); + this.favorites = await this.listingsService.getFavoriteListings(); + } +} diff --git a/bizmatch-client/src/app/pages/home/home.component.html b/bizmatch-client/src/app/pages/home/home.component.html new file mode 100644 index 0000000..60d11a2 --- /dev/null +++ b/bizmatch-client/src/app/pages/home/home.component.html @@ -0,0 +1,248 @@ + + + + +
+
+ +
+
+

Connect with Your Ideal Business Opportunity

+

BizMatch is your trusted partner in buying, selling, and valuing businesses in Texas.

+
+
+ Business handshake +
+
+ +
+
+ + +
+
+
+

Our Services

+

We offer comprehensive business brokerage services to help you navigate the complex process of buying or selling a business.

+
+ +
+ +
+
+
+ + + +
+

Business Sales

+

We help business owners prepare and market their businesses to qualified buyers, ensuring confidentiality throughout the process.

+
+
+ + +
+
+
+ + + +
+

Business Acquisitions

+

We assist buyers in finding the right business opportunity, perform due diligence, and negotiate favorable terms for acquisition.

+
+
+ + +
+
+
+ + + +
+

Business Valuation

+

Our expert team provides accurate business valuations based on industry standards, financial performance, and market conditions.

+
+
+
+ + +
+

See How We Work

+
+ +
+
+
+
+ + +
+
+
+

Why Choose BizMatch

+

With decades of experience in the business brokerage industry, we provide unparalleled service to our clients.

+
+ +
+ +
+
+
+ + + +
+

Experience

+

Over 25 years of combined experience in business brokerage.

+
+
+ + +
+
+
+ + + +
+

Confidentiality

+

We maintain strict confidentiality throughout the entire transaction process.

+
+
+ + +
+
+
+ + + +
+

Network

+

Extensive network of qualified buyers and business owners throughout Texas.

+
+
+ + +
+
+
+ + + +
+

Personalized Approach

+

Customized strategy for each client based on their unique business goals.

+
+
+
+
+
+ + +
+
+
+ +
+
+ +

Visit Our Office

+

Our team of business brokers is ready to assist you at our Corpus Christi location.

+
+ +

BizMatch Headquarters

+

1001 Blucher Street

+

Corpus Christi, TX 78401

+

United States

+

Phone: (555) 123-4567

+

Email: info@bizmatch.net

+
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+

Ready to Get Started?

+

Contact our team of experienced business brokers today for a confidential consultation about buying or selling a business.

+ Contact Us Now +
+
+ + diff --git a/bizmatch-client/src/app/pages/home/home.component.scss b/bizmatch-client/src/app/pages/home/home.component.scss new file mode 100644 index 0000000..d937214 --- /dev/null +++ b/bizmatch-client/src/app/pages/home/home.component.scss @@ -0,0 +1,85 @@ +// Hero section styles +.hero-section { + background: linear-gradient(135deg, #0046b5 0%, #00a0e9 100%); + // height: 70vh; // Made shorter as requested + // min-height: 500px; // Reduced from 600px +} + +// Button hover effects +.btn-primary { + background-color: #0046b5; + transition: all 0.3s ease; + + &:hover { + background-color: #003492; + } +} + +// Service card animation +.service-card { + transition: all 0.3s ease; + + &:hover { + transform: translateY(-10px); + } +} + +// Responsive adjustments +@media (max-width: 768px) { + .hero-section { + height: auto; + padding: 4rem 0; + } +} + +// Make sure the Google Map is responsive +google-map { + display: block; + width: 100%; +} + +// Override Tailwind default styling for video +video { + max-width: 100%; + object-fit: cover; +} + +// Zusätzliche Styles für den Location-Bereich + +// Verbesserte Map-Container Styles +#location { + .rounded-lg.overflow-hidden { + position: relative; + height: 100%; + min-height: 384px; + } + + iframe { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + border: 0; + } + + // Stellen Sie sicher, dass der Kartencontainer im mobilen Layout + // eine angemessene Höhe hat + @media (max-width: 1023px) { + .rounded-lg.overflow-hidden { + height: 400px; + } + } +} + +// Adressbox-Styling verbessern +.bg-white.p-6.rounded-lg.shadow-lg.flex-grow { + display: flex; + flex-direction: column; + justify-content: space-between; + + // Sicherstellen, dass der untere Bereich sichtbar bleibt + .contact-info { + margin-top: auto; + } +} diff --git a/bizmatch-client/src/app/pages/home/home.component.ts b/bizmatch-client/src/app/pages/home/home.component.ts new file mode 100644 index 0000000..725687b --- /dev/null +++ b/bizmatch-client/src/app/pages/home/home.component.ts @@ -0,0 +1,51 @@ +import { CommonModule } from '@angular/common'; +import { Component, OnInit } from '@angular/core'; +import { RouterLink, RouterOutlet } from '@angular/router'; +import { User } from '../../../../../bizmatch-server/src/models/db.model'; +import { KeycloakUser } from '../../../../../bizmatch-server/src/models/main.model'; +import { AuthService } from '../../services/auth.service'; +import { UserService } from '../../services/user.service'; +import { map2User } from '../../utils/utils'; + +@Component({ + selector: 'app-home', + templateUrl: './home.component.html', + styleUrls: ['./home.component.scss'], + standalone: true, + imports: [CommonModule, RouterOutlet, RouterLink], +}) +export class HomeComponent implements OnInit { + showMobileMenu = false; + keycloakUser: KeycloakUser; + user: User; + constructor(private authService: AuthService, private userService: UserService) {} + + async ngOnInit() { + // Add smooth scrolling for anchor links + this.setupSmoothScrolling(); + const token = await this.authService.getToken(); + this.keycloakUser = map2User(token); + if (this.keycloakUser) { + this.user = await this.userService.getByMail(this.keycloakUser.email); + this.userService.changeUser(this.user); + } + } + + toggleMobileMenu(): void { + this.showMobileMenu = !this.showMobileMenu; + } + + private setupSmoothScrolling(): void { + document.querySelectorAll('a[href^="#"]').forEach(anchor => { + anchor.addEventListener('click', function (e) { + e.preventDefault(); + const target = document.querySelector((this as HTMLAnchorElement).getAttribute('href') || ''); + if (target) { + target.scrollIntoView({ + behavior: 'smooth', + }); + } + }); + }); + } +} diff --git a/bizmatch-client/src/app/pages/login-register/login-register.component.html b/bizmatch-client/src/app/pages/login-register/login-register.component.html new file mode 100644 index 0000000..39df5fc --- /dev/null +++ b/bizmatch-client/src/app/pages/login-register/login-register.component.html @@ -0,0 +1,98 @@ +
+
+

+ {{ isLoginMode ? 'Login' : 'Sign Up' }} +

+ + +
+ Login + + Sign Up +
+ + +
+ +
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+ {{ errorMessage }} +
+ + + + + +
+ + or + +
+ + + +
+
diff --git a/bizmatch-client/src/app/pages/login-register/login-register.component.ts b/bizmatch-client/src/app/pages/login-register/login-register.component.ts new file mode 100644 index 0000000..f5088dc --- /dev/null +++ b/bizmatch-client/src/app/pages/login-register/login-register.component.ts @@ -0,0 +1,98 @@ +import { CommonModule } from '@angular/common'; +import { Component } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { faArrowRight, faEnvelope, faLock, faUserPlus } from '@fortawesome/free-solid-svg-icons'; +import { AuthService } from '../../services/auth.service'; +import { LoadingService } from '../../services/loading.service'; + +@Component({ + selector: 'app-login-register', + standalone: true, + imports: [CommonModule, FormsModule, FontAwesomeModule], + templateUrl: './login-register.component.html', +}) +export class LoginRegisterComponent { + email: string = ''; + password: string = ''; + confirmPassword: string = ''; + isLoginMode: boolean = true; // true: Login, false: Registration + errorMessage: string = ''; + envelope = faEnvelope; + lock = faLock; + arrowRight = faArrowRight; + userplus = faUserPlus; + constructor(private authService: AuthService, private route: ActivatedRoute, private router: Router, private loadingService: LoadingService) {} + + ngOnInit(): void { + // Set mode based on query parameter "mode" + this.route.queryParamMap.subscribe(params => { + const mode = params.get('mode'); + this.isLoginMode = mode !== 'register'; + }); + } + + toggleMode(): void { + this.isLoginMode = !this.isLoginMode; + this.errorMessage = ''; + } + + // Login with Email + onSubmit(): void { + this.errorMessage = ''; + if (this.isLoginMode) { + this.authService.clearRoleCache(); + this.authService + .loginWithEmail(this.email, this.password) + .then(userCredential => { + console.log('Successfully logged in:', userCredential); + this.router.navigate([`home`]); + }) + .catch(error => { + console.error('Error during email login:', error); + this.errorMessage = error.message; + }); + } else { + // Registration mode: also check if passwords match + if (this.password !== this.confirmPassword) { + console.error('Passwords do not match'); + this.errorMessage = 'Passwords do not match.'; + return; + } + this.loadingService.startLoading('googleAuth'); + this.authService + .registerWithEmail(this.email, this.password) + .then(userCredential => { + console.log('Successfully registered:', userCredential); + this.loadingService.stopLoading('googleAuth'); + this.router.navigate(['emailVerification']); + }) + .catch(error => { + this.loadingService.stopLoading('googleAuth'); + console.error('Error during registration:', error); + if (error.code === 'auth/email-already-in-use') { + this.errorMessage = 'This email address is already in use. Please try logging in.'; + } else { + this.errorMessage = error.message; + } + }); + } + } + + // Login with Google + loginWithGoogle(): void { + this.errorMessage = ''; + this.authService.clearRoleCache(); + this.authService + .loginWithGoogle() + .then(userCredential => { + console.log('Successfully logged in with Google:', userCredential); + this.router.navigate([`home`]); + }) + .catch(error => { + console.error('Error during Google login:', error); + this.errorMessage = error.message; + }); + } +} diff --git a/bizmatch-client/src/app/pages/logout/logout.component.html b/bizmatch-client/src/app/pages/logout/logout.component.html new file mode 100644 index 0000000..c6ae40e --- /dev/null +++ b/bizmatch-client/src/app/pages/logout/logout.component.html @@ -0,0 +1 @@ +

logout works!

diff --git a/bizmatch-client/src/app/pages/logout/logout.component.ts b/bizmatch-client/src/app/pages/logout/logout.component.ts new file mode 100644 index 0000000..8b3391a --- /dev/null +++ b/bizmatch-client/src/app/pages/logout/logout.component.ts @@ -0,0 +1,17 @@ +import { CommonModule } from '@angular/common'; +import { Component } from '@angular/core'; +import { Router, RouterModule } from '@angular/router'; +import { AuthService } from '../../services/auth.service'; + +@Component({ + selector: 'logout', + standalone: true, + imports: [CommonModule, RouterModule], + template: ``, +}) +export class LogoutComponent { + constructor(private authService: AuthService, private router: Router) { + this.authService.logout(); + this.router.navigate(['/home']); + } +} diff --git a/bizmatch-client/src/app/pages/my-listing/my-listing.component.html b/bizmatch-client/src/app/pages/my-listing/my-listing.component.html new file mode 100644 index 0000000..41678a3 --- /dev/null +++ b/bizmatch-client/src/app/pages/my-listing/my-listing.component.html @@ -0,0 +1,113 @@ +
+
+

My Listings

+ + + + + +
+
+

{{ listing.title }}

+

Category: {{ listing.listingsCategory === 'commercialProperty' ? 'Commercial Property' : 'Business' }}

+

Located in: {{ listing.location.name ? listing.location.name : listing.location.county }} - {{ listing.location.state }}

+

Price: ${{ listing.price.toLocaleString() }}

+
+ Publication Status: + + {{ listing.draft ? 'Draft' : 'Published' }} + +
+
+ @if(listing.listingsCategory==='business'){ + + } @if(listing.listingsCategory==='commercialProperty'){ + + } + +
+
+
+ + +
+
+ diff --git a/bizmatch-client/src/app/pages/my-listing/my-listing.component.scss b/bizmatch-client/src/app/pages/my-listing/my-listing.component.scss new file mode 100644 index 0000000..08b3339 --- /dev/null +++ b/bizmatch-client/src/app/pages/my-listing/my-listing.component.scss @@ -0,0 +1,3 @@ +.wide-column{ + width: 40%; +} \ No newline at end of file diff --git a/bizmatch-client/src/app/pages/my-listing/my-listing.component.ts b/bizmatch-client/src/app/pages/my-listing/my-listing.component.ts new file mode 100644 index 0000000..b9081be --- /dev/null +++ b/bizmatch-client/src/app/pages/my-listing/my-listing.component.ts @@ -0,0 +1,59 @@ +import { CommonModule } from '@angular/common'; +import { ChangeDetectorRef, Component } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { User } from '../../../../../bizmatch-server/src/models/db.model'; +import { ListingType } from '../../../../../bizmatch-server/src/models/main.model'; +import { ConfirmationComponent } from '../../components/confirmation.component'; +import { MessageComponent } from '../../components/message/message.component'; +import { AuthService } from '../../services/auth.service'; +import { ConfirmationService } from '../../services/confirmation.service'; +import { ListingsService } from '../../services/listings.service'; +import { MessageService } from '../../services/message.service'; +import { SelectOptionsService } from '../../services/select-options.service'; +import { UserService } from '../../services/user.service'; +import { map2User } from '../../utils/utils'; + +@Component({ + selector: 'app-my-listing', + standalone: true, + imports: [CommonModule, FormsModule, RouterModule, FontAwesomeModule, ConfirmationComponent, MessageComponent], + providers: [], + templateUrl: './my-listing.component.html', + styleUrl: './my-listing.component.scss', +}) +export class MyListingComponent { + listings: Array = []; //dataListings as unknown as Array; + myListings: Array; + user: User; + constructor( + public userService: UserService, + private listingsService: ListingsService, + private cdRef: ChangeDetectorRef, + public selectOptions: SelectOptionsService, + private messageService: MessageService, + private confirmationService: ConfirmationService, + private authService: AuthService, + ) {} + async ngOnInit() { + const token = await this.authService.getToken(); + const keycloakUser = map2User(token); + const email = keycloakUser.email; + this.user = await this.userService.getByMail(email); + this.myListings = await this.listingsService.getListingsByEmail(this.user.email); + } + + async deleteListing(listing: ListingType) { + await this.listingsService.deleteBusinessListing(listing.id); + this.myListings = await this.listingsService.getListingsByEmail(this.user.email); + } + + async confirm(listing: ListingType) { + const confirmed = await this.confirmationService.showConfirmation({ message: `Are you sure you want to delete this listing?` }); + if (confirmed) { + // this.messageService.showMessage('Listing has been deleted'); + this.deleteListing(listing); + } + } +} diff --git a/bizmatch-client/src/app/pages/not-found/not-found.component.html b/bizmatch-client/src/app/pages/not-found/not-found.component.html new file mode 100644 index 0000000..6084105 --- /dev/null +++ b/bizmatch-client/src/app/pages/not-found/not-found.component.html @@ -0,0 +1,35 @@ + +
+
+
+

404

+

Something's missing.

+

Sorry, we can't find that page

+ + +
+
+
diff --git a/bizmatch-client/src/app/pages/not-found/not-found.component.scss b/bizmatch-client/src/app/pages/not-found/not-found.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/bizmatch-client/src/app/pages/not-found/not-found.component.ts b/bizmatch-client/src/app/pages/not-found/not-found.component.ts new file mode 100644 index 0000000..3c69836 --- /dev/null +++ b/bizmatch-client/src/app/pages/not-found/not-found.component.ts @@ -0,0 +1,11 @@ +import { CommonModule } from '@angular/common'; +import { Component } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +@Component({ + selector: 'app-not-found', + standalone: true, + imports: [CommonModule, RouterModule], + templateUrl: './not-found.component.html', +}) +export class NotFoundComponent {} diff --git a/bizmatch-client/src/app/pages/user-list/user-list.component.html b/bizmatch-client/src/app/pages/user-list/user-list.component.html new file mode 100644 index 0000000..064372d --- /dev/null +++ b/bizmatch-client/src/app/pages/user-list/user-list.component.html @@ -0,0 +1,154 @@ +
+

Benutzerverwaltung

+ + +
+ + +
+ + +
+ {{ error }} + +
+ + +
+ + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
NameE-MailRolleE-Mail bestätigtLetzter LoginAktionen
+
+
+ Profilbild +
+ {{ (user.displayName || user.email || '?').charAt(0).toUpperCase() }} +
+
+
+
{{ user.displayName || 'Kein Name' }}
+
+
+
+
{{ user.email }}
+
+ + {{ user.role || 'Keine' }} + + +
+
+ + + +
+
+ + + +
+
+ {{ user.emailVerified ? 'Ja' : 'Nein' }} +
+
+
+ {{ user.lastSignInTime | date : 'medium' }} + +
+ +
+ +
+
+
+
+ + +
+
+
+ + + +
+
+

Keine Benutzer gefunden.

+
+
+
+ + +
+ +
+
diff --git a/bizmatch-client/src/app/pages/user-list/user-list.component.scss b/bizmatch-client/src/app/pages/user-list/user-list.component.scss new file mode 100644 index 0000000..12e0230 --- /dev/null +++ b/bizmatch-client/src/app/pages/user-list/user-list.component.scss @@ -0,0 +1,64 @@ +// button.share { +// font-size: 13px; +// transform: translateY(-2px) scale(1.03); +// margin-right: 4px; +// margin-left: 2px; +// border-radius: 4px; +// i { +// font-size: 15px; +// } +// } +// .share-msg { +// background-color: #0088cc; +// } +// .share-delete { +// background-color: #e60023; +// } +// .share-cc { +// background-color: #ff961c; +// } +button.share { + font-size: 13px; + transform: translateY(-2px) scale(1.03); + margin-right: 4px; + margin-left: 2px; + border-radius: 4px; + transition: transform 0.2s, background-color 0.2s, opacity 0.2s; +} + +button.share i { + font-size: 15px; +} + +button.share-delete { + background-color: #e60023; /* Rot */ + color: white; +} + +button.share-delete:hover:not(:disabled) { + background-color: #cc001f; /* Dunkleres Rot für Hover */ +} + +button.share-cc { + background-color: #4f46e5; /* Beispiel: Indigo für CC Info */ + color: white; +} + +button.share-cc:hover:not(:disabled) { + background-color: #4338ca; /* Dunkleres Indigo für Hover */ +} + +button.share-msg { + background-color: #10b981; /* Beispiel: Grün für Messages */ + color: white; +} + +button.share-msg:hover:not(:disabled) { + background-color: #059669; /* Dunkleres Grün für Hover */ +} + +/* Deaktivierter Zustand */ +button.share:disabled { + opacity: 0.5; + cursor: not-allowed; +} diff --git a/bizmatch-client/src/app/pages/user-list/user-list.component.ts b/bizmatch-client/src/app/pages/user-list/user-list.component.ts new file mode 100644 index 0000000..8ca8b4b --- /dev/null +++ b/bizmatch-client/src/app/pages/user-list/user-list.component.ts @@ -0,0 +1,97 @@ +import { CommonModule } from '@angular/common'; +import { Component, OnInit } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { FirebaseUserInfo, UserRole, UsersResponse } from '../../../../../bizmatch-server/src/models/main.model'; +import { UserService } from '../../services/user.service'; + +@Component({ + selector: 'app-user-list', + templateUrl: './user-list.component.html', + styleUrls: ['./user-list.component.scss'], + imports: [CommonModule, FormsModule], + standalone: true, +}) +export class UserListComponent implements OnInit { + users: FirebaseUserInfo[] = []; + loading = false; + error: string | null = null; + + // Paginierung + pageToken?: string; + hasMoreUsers = false; + maxResultsPerPage = 50; + + // Filterung + selectedRole: UserRole | 'all' = 'all'; + + constructor(private userService: UserService) {} + + ngOnInit(): void { + this.loadUsers(); + } + + loadUsers(): void { + this.loading = true; + this.error = null; + + if (this.selectedRole !== 'all') { + // Benutzer nach Rolle filtern + this.userService.getUsersByRole(this.selectedRole).subscribe({ + next: response => { + this.users = response.users; + this.loading = false; + this.hasMoreUsers = false; // Bei Rollenfilterung keine Paginierung + }, + error: err => { + this.error = 'Fehler beim Laden der Benutzer: ' + (err.message || err); + this.loading = false; + }, + }); + } else { + // Alle Benutzer mit Paginierung laden + this.userService.getAllUsers(this.maxResultsPerPage, this.pageToken).subscribe({ + next: (response: UsersResponse) => { + this.users = this.pageToken + ? [...this.users, ...response.users] // Anhängen bei Paginierung + : response.users; // Ersetzen beim ersten Laden + + this.pageToken = response.pageToken; + this.hasMoreUsers = !!response.pageToken; + this.loading = false; + }, + error: err => { + this.error = 'Fehler beim Laden der Benutzer: ' + (err.message || err); + this.loading = false; + }, + }); + } + } + + loadMoreUsers(): void { + if (this.hasMoreUsers && !this.loading) { + this.loadUsers(); + } + } + + onRoleFilterChange(role: UserRole | 'all'): void { + this.selectedRole = role; + this.users = []; // Liste zurücksetzen + this.pageToken = undefined; // Paginierung zurücksetzen + this.loadUsers(); + } + + changeUserRole(user: FirebaseUserInfo, newRole: UserRole): void { + this.userService.setUserRole(user.uid, newRole).subscribe({ + next: () => { + // Benutzer in der lokalen Liste aktualisieren + const index = this.users.findIndex(u => u.uid === user.uid); + if (index !== -1) { + this.users[index] = { ...user, role: newRole }; + } + }, + error: err => { + this.error = `Fehler beim Ändern der Rolle für ${user.email}: ${err.message || err}`; + }, + }); + } +} diff --git a/bizmatch-client/src/app/pipes/array-to-string.pipe.ts b/bizmatch-client/src/app/pipes/array-to-string.pipe.ts new file mode 100644 index 0000000..2645482 --- /dev/null +++ b/bizmatch-client/src/app/pipes/array-to-string.pipe.ts @@ -0,0 +1,13 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'arrayToString', + standalone: true +}) +export class ArrayToStringPipe implements PipeTransform { + + transform(value: string|string[], separator: string = '\n'): string { + return Array.isArray(value)?value.join(separator):value; + } + +} diff --git a/bizmatch-client/src/app/services/audit.service.ts b/bizmatch-client/src/app/services/audit.service.ts new file mode 100644 index 0000000..ae8ac3d --- /dev/null +++ b/bizmatch-client/src/app/services/audit.service.ts @@ -0,0 +1,40 @@ +import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { lastValueFrom } from 'rxjs'; +import { EventTypeEnum, ListingEvent } from '../../../../bizmatch-server/src/models/db.model'; +import { LogMessage } from '../../../../bizmatch-server/src/models/main.model'; +import { environment } from '../../environments/environment'; +import { GeoService } from './geo.service'; + +@Injectable({ + providedIn: 'root', +}) +export class AuditService { + private apiBaseUrl = environment.apiBaseUrl; + private apiKey = environment.ipinfo_token; + + constructor(private http: HttpClient, private geoService: GeoService) {} + + async log(message: LogMessage): Promise { + lastValueFrom(this.http.post(`${this.apiBaseUrl}/bizmatch/log`, message)); + } + async createEvent(id: string, eventType: EventTypeEnum, userId: string, additionalData?): Promise { + const ipInfo = await this.geoService.getIpInfo(); + const [latitude, longitude] = ipInfo.loc ? ipInfo.loc.split(',') : [null, null]; //.map(Number); + const listingEvent: ListingEvent = { + listingId: id, + eventType, + eventTimestamp: new Date(), + userAgent: navigator.userAgent, + email: userId, + userIp: ipInfo.ip, + locationCountry: ipInfo.country, + locationCity: ipInfo.city, + locationLat: latitude, + locationLng: longitude, + additionalData, + }; + let headers = new HttpHeaders().set('X-Hide-Loading', 'true'); + lastValueFrom(this.http.post(`${this.apiBaseUrl}/bizmatch/event`, listingEvent, { headers })); + } +} diff --git a/bizmatch-client/src/app/services/auth.service.ts b/bizmatch-client/src/app/services/auth.service.ts new file mode 100644 index 0000000..7e0796d --- /dev/null +++ b/bizmatch-client/src/app/services/auth.service.ts @@ -0,0 +1,305 @@ +// auth.service.ts +import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; +import { Injectable, inject } from '@angular/core'; +import { FirebaseApp } from '@angular/fire/app'; +import { GoogleAuthProvider, UserCredential, createUserWithEmailAndPassword, getAuth, signInWithCustomToken, signInWithEmailAndPassword, signInWithPopup } from 'firebase/auth'; +import { BehaviorSubject, Observable, catchError, firstValueFrom, map, of, shareReplay, take, tap } from 'rxjs'; +import { environment } from '../../environments/environment'; +import { MailService } from './mail.service'; + +export type UserRole = 'admin' | 'pro' | 'guest'; + +@Injectable({ + providedIn: 'root', +}) +export class AuthService { + private app = inject(FirebaseApp); + private auth = getAuth(this.app); + private http = inject(HttpClient); + private mailService = inject(MailService); + // Add a BehaviorSubject to track the current user role + private userRoleSubject = new BehaviorSubject(null); + public userRole$ = this.userRoleSubject.asObservable(); + // Referenz für den gecachten API-Aufruf + private cachedUserRole$: Observable | null = null; + + // Zeitraum in ms, nach dem der Cache zurückgesetzt werden soll (z.B. 5 Minuten) + private cacheDuration = 5 * 60 * 1000; + private lastCacheTime = 0; + constructor() { + // Load role from token when service is initialized + this.loadRoleFromToken(); + } + + private loadRoleFromToken(): void { + this.getToken().then(token => { + if (token) { + const role = this.extractRoleFromToken(token); + this.userRoleSubject.next(role); + } else { + this.userRoleSubject.next(null); + } + }); + } + + private extractRoleFromToken(token: string): UserRole | null { + try { + const payloadBase64 = token.split('.')[1]; + const payloadJson = atob(payloadBase64.replace(/-/g, '+').replace(/_/g, '/')); + const payload = JSON.parse(payloadJson); + return (payload.role as UserRole) || null; + } catch (e) { + return null; + } + } + // Registrierung mit Email und Passwort + async registerWithEmail(email: string, password: string): Promise { + // Bestimmen der aktuellen Umgebung/Domain für die Verifizierungs-URL + let verificationUrl = ''; + + // Prüfen der aktuellen Umgebung basierend auf dem Host + const currentHost = window.location.hostname; + + if (currentHost.includes('localhost')) { + verificationUrl = 'http://localhost:4200/email-authorized'; + } else if (currentHost.includes('dev.bizmatch.net')) { + verificationUrl = 'https://dev.bizmatch.net/email-authorized'; + } else { + verificationUrl = 'https://www.bizmatch.net/email-authorized'; + } + + // ActionCode-Einstellungen mit der dynamischen URL + const actionCodeSettings = { + url: `${verificationUrl}?email=${email}`, + handleCodeInApp: true, + }; + + // Benutzer erstellen + const userCredential = await createUserWithEmailAndPassword(this.auth, email, password); + + // E-Mail-Verifizierung mit den angepassten ActionCode-Einstellungen senden + if (userCredential.user) { + //await sendEmailVerification(userCredential.user, actionCodeSettings); + this.mailService.sendVerificationEmail(userCredential.user.email).subscribe({ + next: () => { + console.log('Verification email sent successfully'); + // Erfolgsmeldung anzeigen + }, + error: error => { + console.error('Error sending verification email', error); + // Fehlermeldung anzeigen + }, + }); + } + + // const token = await userCredential.user.getIdToken(); + // localStorage.setItem('authToken', token); + // localStorage.setItem('refreshToken', userCredential.user.refreshToken); + // if (userCredential.user.photoURL) { + // localStorage.setItem('photoURL', userCredential.user.photoURL); + // } + + return userCredential; + } + + // Login mit Email und Passwort + loginWithEmail(email: string, password: string): Promise { + return signInWithEmailAndPassword(this.auth, email, password).then(async userCredential => { + if (userCredential.user) { + const token = await userCredential.user.getIdToken(); + localStorage.setItem('authToken', token); + localStorage.setItem('refreshToken', userCredential.user.refreshToken); + if (userCredential.user.photoURL) { + localStorage.setItem('photoURL', userCredential.user.photoURL); + } + this.loadRoleFromToken(); + } + return userCredential; + }); + } + + // Login mit Google + loginWithGoogle(): Promise { + const provider = new GoogleAuthProvider(); + return signInWithPopup(this.auth, provider).then(async userCredential => { + if (userCredential.user) { + const token = await userCredential.user.getIdToken(); + localStorage.setItem('authToken', token); + localStorage.setItem('refreshToken', userCredential.user.refreshToken); + if (userCredential.user.photoURL) { + localStorage.setItem('photoURL', userCredential.user.photoURL); + } + this.loadRoleFromToken(); + } + return userCredential; + }); + } + + // Logout: Token, RefreshToken und photoURL entfernen + logout(): Promise { + localStorage.removeItem('authToken'); + localStorage.removeItem('refreshToken'); + localStorage.removeItem('photoURL'); + this.clearRoleCache(); + this.userRoleSubject.next(null); + return this.auth.signOut(); + } + isAdmin(): Observable { + return this.getUserRole().pipe( + map(role => role === 'admin'), + // take(1) ist optional - es beendet die Subscription, nachdem ein Wert geliefert wurde + // Nützlich, wenn du die Methode in einem Template mit dem async pipe verwendest + take(1), + ); + } + // Get current user's role from the server with caching + getUserRole(): Observable { + const now = Date.now(); + + // Cache zurücksetzen, wenn die Caching-Zeit abgelaufen ist oder kein Cache existiert + if (!this.cachedUserRole$ || now - this.lastCacheTime > this.cacheDuration) { + this.lastCacheTime = now; + let headers = new HttpHeaders().set('X-Hide-Loading', 'true').set('Accept-Language', 'en-US'); + this.cachedUserRole$ = this.http.get<{ role: UserRole | null }>(`${environment.apiBaseUrl}/bizmatch/auth/me/role`, { headers }).pipe( + map(response => response.role), + tap(role => this.userRoleSubject.next(role)), + catchError(error => { + console.error('Error fetching user role', error); + return of(null); + }), + // Cache für mehrere Subscriber und behalte den letzten Wert + // Der Parameter 1 gibt an, dass der letzte Wert gecacht werden soll + // refCount: false bedeutet, dass der Cache nicht zurückgesetzt wird, wenn keine Subscriber mehr da sind + shareReplay({ bufferSize: 1, refCount: false }), + ); + } + + return this.cachedUserRole$; + } + clearRoleCache(): void { + this.cachedUserRole$ = null; + this.lastCacheTime = 0; + } + // Check if user has a specific role + hasRole(role: UserRole): Observable { + return this.userRole$.pipe( + map(userRole => { + if (role === 'guest') { + // Any authenticated user can access guest features + return userRole !== null; + } else if (role === 'pro') { + // Both pro and admin can access pro features + return userRole === 'pro' || userRole === 'admin'; + } else if (role === 'admin') { + // Only admin can access admin features + return userRole === 'admin'; + } + return false; + }), + ); + } + + // Force refresh the token to get updated custom claims + async refreshUserClaims(): Promise { + this.clearRoleCache(); + if (this.auth.currentUser) { + await this.auth.currentUser.getIdToken(true); + const token = await this.auth.currentUser.getIdToken(); + localStorage.setItem('authToken', token); + this.loadRoleFromToken(); + } + } + // Prüft, ob ein Token noch gültig ist (über die "exp"-Eigenschaft) + private isTokenValid(token: string): boolean { + try { + const payloadBase64 = token.split('.')[1]; + const payloadJson = atob(payloadBase64.replace(/-/g, '+').replace(/_/g, '/')); + const payload = JSON.parse(payloadJson); + const exp = payload.exp; + const now = Math.floor(Date.now() / 1000); + return exp > now; + } catch (e) { + return false; + } + } + private isEMailVerified(token: string): boolean { + try { + const payloadBase64 = token.split('.')[1]; + const payloadJson = atob(payloadBase64.replace(/-/g, '+').replace(/_/g, '/')); + const payload = JSON.parse(payloadJson); + return payload.email_verified; + } catch (e) { + return false; + } + } + // Versucht, mit dem RefreshToken einen neuen Access Token zu erhalten + async refreshToken(): Promise { + const storedRefreshToken = localStorage.getItem('refreshToken'); + if (!storedRefreshToken) { + return null; + } + const apiKey = environment.firebaseConfig.apiKey; // Stelle sicher, dass dieser Wert in Deiner environment.ts gesetzt ist + const url = `https://securetoken.googleapis.com/v1/token?key=${apiKey}`; + + const body = new HttpParams().set('grant_type', 'refresh_token').set('refresh_token', storedRefreshToken); + + const headers = new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded' }); + + try { + const response: any = await firstValueFrom(this.http.post(url, body.toString(), { headers })); + // response enthält z. B. id_token, refresh_token, expires_in etc. + const newToken = response.id_token; + const newRefreshToken = response.refresh_token; + localStorage.setItem('authToken', newToken); + localStorage.setItem('refreshToken', newRefreshToken); + return newToken; + } catch (error) { + console.error('Error refreshing token:', error); + return null; + } + } + + /** + * Gibt einen gültigen Token zurück. + * Falls der gespeicherte Token noch gültig ist, wird er zurückgegeben. + * Ansonsten wird versucht, einen neuen Token mit dem RefreshToken zu holen. + * Ist auch das nicht möglich, wird null zurückgegeben. + */ + async getToken(): Promise { + const token = localStorage.getItem('authToken'); + if (token && !this.isEMailVerified(token)) { + return null; + } else if (token && this.isTokenValid(token) && this.isEMailVerified(token)) { + return token; + } else { + return await this.refreshToken(); + } + } + + // Add this new method to sign in with a custom token + async signInWithCustomToken(token: string): Promise { + try { + // Sign in to Firebase with the custom token + const userCredential = await signInWithCustomToken(this.auth, token); + + // Store the authentication token + if (userCredential.user) { + const idToken = await userCredential.user.getIdToken(); + localStorage.setItem('authToken', idToken); + localStorage.setItem('refreshToken', userCredential.user.refreshToken); + + if (userCredential.user.photoURL) { + localStorage.setItem('photoURL', userCredential.user.photoURL); + } + + // Load user role from the token + this.loadRoleFromToken(); + } + + return; + } catch (error) { + console.error('Error signing in with custom token:', error); + throw error; + } + } +} diff --git a/bizmatch-client/src/app/services/confirmation.service.ts b/bizmatch-client/src/app/services/confirmation.service.ts new file mode 100644 index 0000000..6f99f0c --- /dev/null +++ b/bizmatch-client/src/app/services/confirmation.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { BehaviorSubject, Observable } from 'rxjs'; +export interface Confirmation { + message: string; + buttons?: 'both' | 'none'; + button_accept_label?: string; + button_reject_label?: string; +} +@Injectable({ + providedIn: 'root', +}) +export class ConfirmationService { + private modalVisibleSubject = new BehaviorSubject(false); + private confirmationSubject = new BehaviorSubject({ message: '' }); + private resolvePromise!: (value: boolean) => void; + + modalVisible$: Observable = this.modalVisibleSubject.asObservable(); + confirmation$: Observable = this.confirmationSubject.asObservable(); + + showConfirmation(confirmation: Confirmation): Promise { + confirmation.buttons = confirmation.buttons ? confirmation.buttons : 'both'; + this.confirmationSubject.next(confirmation); + this.modalVisibleSubject.next(true); + return new Promise(resolve => { + this.resolvePromise = resolve; + }); + } + + accept(): void { + this.modalVisibleSubject.next(false); + this.resolvePromise(true); + } + + reject(): void { + this.modalVisibleSubject.next(false); + this.resolvePromise(false); + } +} diff --git a/bizmatch-client/src/app/services/criteria-change.service.ts b/bizmatch-client/src/app/services/criteria-change.service.ts new file mode 100644 index 0000000..3e402cb --- /dev/null +++ b/bizmatch-client/src/app/services/criteria-change.service.ts @@ -0,0 +1,15 @@ +import { Injectable } from '@angular/core'; +import { Subject } from 'rxjs'; + +@Injectable({ + providedIn: 'root', +}) +export class CriteriaChangeService { + private criteriaChangeSubject = new Subject(); + + criteriaChange$ = this.criteriaChangeSubject.asObservable(); + + notifyCriteriaChange() { + this.criteriaChangeSubject.next(); + } +} diff --git a/bizmatch-client/src/app/services/geo.service.ts b/bizmatch-client/src/app/services/geo.service.ts new file mode 100644 index 0000000..3e18e5d --- /dev/null +++ b/bizmatch-client/src/app/services/geo.service.ts @@ -0,0 +1,56 @@ +import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { lastValueFrom, Observable } from 'rxjs'; +import { CityAndStateResult, CountyResult, GeoResult, IpInfo } from '../../../../bizmatch-server/src/models/main.model'; +import { Place } from '../../../../bizmatch-server/src/models/server.model'; +import { environment } from '../../environments/environment'; + +@Injectable({ + providedIn: 'root', +}) +export class GeoService { + private apiBaseUrl = environment.apiBaseUrl; + private baseUrl: string = 'https://nominatim.openstreetmap.org/search'; + private fetchingData: Observable | null = null; + private readonly storageKey = 'ipInfo'; + constructor(private http: HttpClient) {} + + findCitiesStartingWith(prefix: string, state?: string): Observable { + const stateString = state ? `/${state}` : ''; + return this.http.get(`${this.apiBaseUrl}/bizmatch/geo/${prefix}${stateString}`); + } + findCitiesAndStatesStartingWith(prefix: string): Observable { + return this.http.get(`${this.apiBaseUrl}/bizmatch/geo/citiesandstates/${prefix}`); + } + findCountiesStartingWith(prefix: string, states?: string[]): Observable { + return this.http.post(`${this.apiBaseUrl}/bizmatch/geo/counties`, { prefix, states }); + } + findLocationStartingWith(prefix: string): Observable { + let headers = new HttpHeaders().set('X-Hide-Loading', 'true').set('Accept-Language', 'en-US'); + return this.http.get(`${this.baseUrl}?q=${prefix},US&format=json&addressdetails=1&limit=5`, { headers }) as Observable; + } + private fetchIpAndGeoLocation(): Observable { + return this.http.get(`${this.apiBaseUrl}/bizmatch/geo/ipinfo/georesult/wysiwyg`); + } + + async getIpInfo(): Promise { + // Versuche zuerst, die Daten aus dem sessionStorage zu holen + const storedData = sessionStorage.getItem(this.storageKey); + if (storedData) { + return JSON.parse(storedData); + } + + try { + // Wenn keine Daten im Storage, hole sie vom Server + const data = await lastValueFrom(this.http.get(`${this.apiBaseUrl}/bizmatch/geo/ipinfo/georesult/wysiwyg`)); + + // Speichere die Daten im sessionStorage + sessionStorage.setItem(this.storageKey, JSON.stringify(data)); + + return data; + } catch (error) { + console.error('Error fetching IP info:', error); + return null; + } + } +} diff --git a/bizmatch-client/src/app/services/history.service.ts b/bizmatch-client/src/app/services/history.service.ts new file mode 100644 index 0000000..297bc16 --- /dev/null +++ b/bizmatch-client/src/app/services/history.service.ts @@ -0,0 +1,33 @@ +import { Location } from '@angular/common'; +import { Injectable } from '@angular/core'; +import { NavigationEnd, Router } from '@angular/router'; +import { filter } from 'rxjs/operators'; + +@Injectable({ + providedIn: 'root', +}) +export class HistoryService { + private previousUrl: string | undefined; + private currentUrl: string | undefined; + + constructor(private router: Router, private location: Location) { + this.setupRouterListener(); + } + + private setupRouterListener(): void { + this.router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe((event: NavigationEnd) => { + this.previousUrl = this.currentUrl; + this.currentUrl = event.urlAfterRedirects; + }); + } + + get canGoBack(): boolean { + return !!this.previousUrl || window.history.length > 2; + } + + goBack(): void { + if (this.canGoBack) { + this.location.back(); + } + } +} diff --git a/bizmatch-client/src/app/services/image.service.ts b/bizmatch-client/src/app/services/image.service.ts new file mode 100644 index 0000000..515f4c6 --- /dev/null +++ b/bizmatch-client/src/app/services/image.service.ts @@ -0,0 +1,41 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { lastValueFrom } from 'rxjs'; +import { emailToDirName } from '../../../../bizmatch-server/src/models/main.model'; +import { environment } from '../../environments/environment'; + +@Injectable({ + providedIn: 'root', +}) +export class ImageService { + private apiBaseUrl = environment.apiBaseUrl; + + constructor(private http: HttpClient) {} + + async uploadImage(imageBlob: Blob, type: 'uploadPropertyPicture' | 'uploadCompanyLogo' | 'uploadProfile', imagePath: string, serialId?: number) { + let uploadUrl = `${this.apiBaseUrl}/bizmatch/image/${type}/${imagePath}`; + if (type === 'uploadPropertyPicture') { + uploadUrl = `${this.apiBaseUrl}/bizmatch/image/${type}/${imagePath}/${serialId}`; + } + const formData = new FormData(); + formData.append('file', imageBlob, 'image.png'); + + // return this.http.post(uploadUrl, formData, { + // observe: 'events', + // }); + return await lastValueFrom(this.http.post(uploadUrl, formData)); + } + + async deleteListingImage(imagePath: string, serial: number, name?: string) { + return await lastValueFrom(this.http.delete<[]>(`${this.apiBaseUrl}/bizmatch/image/propertyPicture/${imagePath}/${serial}/${name}`)); + } + + async deleteLogoImagesByMail(email: string) { + const adjustedEmail = emailToDirName(email); + await lastValueFrom(this.http.delete<[]>(`${this.apiBaseUrl}/bizmatch/image/logo/${adjustedEmail}`)); + } + async deleteProfileImagesByMail(email: string) { + const adjustedEmail = emailToDirName(email); + await lastValueFrom(this.http.delete<[]>(`${this.apiBaseUrl}/bizmatch/image/profile/${adjustedEmail}`)); + } +} diff --git a/bizmatch-client/src/app/services/listings.service.ts b/bizmatch-client/src/app/services/listings.service.ts new file mode 100644 index 0000000..8060ea5 --- /dev/null +++ b/bizmatch-client/src/app/services/listings.service.ts @@ -0,0 +1,46 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Observable, lastValueFrom } from 'rxjs'; +import { BusinessListing } from '../../../../bizmatch-server/src/models/db.model'; +import { BusinessListingCriteria, ListingType, ResponseBusinessListingArray } from '../../../../bizmatch-server/src/models/main.model'; +import { environment } from '../../environments/environment'; + +@Injectable({ + providedIn: 'root', +}) +export class ListingsService { + private apiBaseUrl = environment.apiBaseUrl; + constructor(private http: HttpClient) {} + + async getListings(criteria: BusinessListingCriteria): Promise { + const result = await lastValueFrom(this.http.post(`${this.apiBaseUrl}/bizmatch/listings/business/find`, criteria)); + return result; + } + getNumberOfListings(criteria: BusinessListingCriteria): Observable { + return this.http.post(`${this.apiBaseUrl}/bizmatch/listings/business/findTotal`, criteria); + } + async getListingsByPrompt(criteria: BusinessListingCriteria): Promise { + const result = await lastValueFrom(this.http.post(`${this.apiBaseUrl}/bizmatch/listings/business/search`, criteria)); + return result; + } + getListingById(id: string): Observable { + const result = this.http.get(`${this.apiBaseUrl}/bizmatch/listings/business/${id}`); + return result; + } + getListingsByEmail(email: string): Promise { + return lastValueFrom(this.http.get(`${this.apiBaseUrl}/bizmatch/listings/business/user/${email}`)); + } + getFavoriteListings(): Promise { + return lastValueFrom(this.http.get(`${this.apiBaseUrl}/bizmatch/listings/business/favorites/all`)); + } + async save(listing: any) { + return await lastValueFrom(this.http.put(`${this.apiBaseUrl}/bizmatch/listings/business`, listing)); + } + async deleteBusinessListing(id: string) { + await lastValueFrom(this.http.delete(`${this.apiBaseUrl}/bizmatch/listings/business/listing/${id}`)); + } + + async removeFavorite(id: string) { + await lastValueFrom(this.http.delete(`${this.apiBaseUrl}/bizmatch/listings/business/favorite/${id}`)); + } +} diff --git a/bizmatch-client/src/app/services/loading.service.ts b/bizmatch-client/src/app/services/loading.service.ts new file mode 100644 index 0000000..ac050d9 --- /dev/null +++ b/bizmatch-client/src/app/services/loading.service.ts @@ -0,0 +1,50 @@ +import { Injectable } from '@angular/core'; +import { BehaviorSubject, Observable } from 'rxjs'; +import { debounceTime, distinctUntilChanged, map, shareReplay } from 'rxjs/operators'; + +@Injectable({ + providedIn: 'root', +}) +export class LoadingService { + private loading$ = new BehaviorSubject([]); + private loadingTextSubject = new BehaviorSubject(null); + private excludedUrls: string[] = ['/findTotal', '/geo']; // Liste der URLs, für die kein Ladeindikator angezeigt werden soll + + loadingText$: Observable = this.loadingTextSubject.asObservable(); + + public isLoading$ = this.loading$.asObservable().pipe( + map(loading => loading.length > 0), + debounceTime(200), + distinctUntilChanged(), + shareReplay(1), + ); + + public startLoading(type: string, url?: string): void { + if (this.shouldShowLoading(url)) { + if (!this.loading$.value.includes(type)) { + this.loading$.next(this.loading$.value.concat(type)); + if (this.isImageUpload(type, url)) { + this.loadingTextSubject.next("Please wait - we're processing your image..."); + } else { + this.loadingTextSubject.next(null); + } + } + } + } + + public stopLoading(type: string): void { + if (this.loading$.value.includes(type)) { + this.loading$.next(this.loading$.value.filter(t => t !== type)); + this.loadingTextSubject.next(null); + } + } + + private shouldShowLoading(url?: string): boolean { + if (!url) return true; + return !this.excludedUrls.some(excludedUrl => url.includes(excludedUrl)); + } + + private isImageUpload(type: string, url?: string): boolean { + return type === 'uploadImage' || url?.includes('uploadImage') || url?.includes('uploadPropertyPicture') || url?.includes('uploadProfile') || url?.includes('uploadCompanyLogo'); + } +} diff --git a/bizmatch-client/src/app/services/mail.service.ts b/bizmatch-client/src/app/services/mail.service.ts new file mode 100644 index 0000000..b9173d2 --- /dev/null +++ b/bizmatch-client/src/app/services/mail.service.ts @@ -0,0 +1,49 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { lastValueFrom, Observable } from 'rxjs'; +import { ShareByEMail } from '../../../../bizmatch-server/src/models/db.model'; +import { ErrorResponse, MailInfo } from '../../../../bizmatch-server/src/models/main.model'; +import { environment } from '../../environments/environment'; + +@Injectable({ + providedIn: 'root', +}) +export class MailService { + private apiBaseUrl = environment.apiBaseUrl; + constructor(private http: HttpClient) {} + + async mail(mailinfo: MailInfo): Promise { + return await lastValueFrom(this.http.post(`${this.apiBaseUrl}/bizmatch/mail`, mailinfo)); + } + async mailToFriend(shareByEMail: ShareByEMail): Promise { + return await lastValueFrom(this.http.post(`${this.apiBaseUrl}/bizmatch/mail/send2Friend`, shareByEMail)); + } + /** + * Sendet eine E-Mail-Verifizierung an die angegebene E-Mail-Adresse + * @param email Die E-Mail-Adresse des Benutzers + * @param redirectConfig Konfiguration für die Weiterleitung nach Verifizierung + * @returns Observable mit der API-Antwort + */ + sendVerificationEmail( + email: string, + redirectConfig?: { + protocol?: string, + hostname?: string, + port?: number + } + ): Observable { + // Extrahiere aktuelle URL-Informationen, wenn nicht explizit angegeben + const currentUrl = new URL(window.location.href); + + const config = { + protocol: redirectConfig?.protocol || currentUrl.protocol.replace(':', ''), + hostname: redirectConfig?.hostname || currentUrl.hostname, + port: redirectConfig?.port || (currentUrl.port ? parseInt(currentUrl.port) : undefined) + }; + + return this.http.post(`${this.apiBaseUrl}/bizmatch/mail/verify-email`, { + email, + redirectConfig: config + }); + } +} diff --git a/bizmatch-client/src/app/services/message.service.ts b/bizmatch-client/src/app/services/message.service.ts new file mode 100644 index 0000000..21cd39e --- /dev/null +++ b/bizmatch-client/src/app/services/message.service.ts @@ -0,0 +1,30 @@ +import { Injectable } from '@angular/core'; +import { BehaviorSubject, Observable } from 'rxjs'; + +export interface Message { + severity: 'success' | 'danger' | 'warning'; + text: string; + duration: number; +} + +@Injectable({ + providedIn: 'root', +}) +export class MessageService { + private messagesSubject = new BehaviorSubject([]); + messages$: Observable = this.messagesSubject.asObservable(); + + addMessage(message: Message): void { + const currentMessages = this.messagesSubject.value; + this.messagesSubject.next([...currentMessages, message]); + + if (message.duration > 0) { + setTimeout(() => this.removeMessage(message), message.duration); + } + } + + removeMessage(messageToRemove: Message): void { + const currentMessages = this.messagesSubject.value; + this.messagesSubject.next(currentMessages.filter(msg => msg !== messageToRemove)); + } +} diff --git a/bizmatch-client/src/app/services/modal.service.ts b/bizmatch-client/src/app/services/modal.service.ts new file mode 100644 index 0000000..18c3b0f --- /dev/null +++ b/bizmatch-client/src/app/services/modal.service.ts @@ -0,0 +1,57 @@ +// 1. Shared Service (modal.service.ts) +import { Injectable } from '@angular/core'; +import { BehaviorSubject, Observable } from 'rxjs'; +import { + BusinessListingCriteria, + CommercialPropertyListingCriteria, + ModalResult, + UserListingCriteria, +} from '../../../../bizmatch-server/src/models/main.model'; + +@Injectable({ + providedIn: 'root', +}) +export class ModalService { + private modalVisibleSubject = new BehaviorSubject(false); + private messageSubject = new BehaviorSubject< + | BusinessListingCriteria + | CommercialPropertyListingCriteria + | UserListingCriteria + >(null); + private resolvePromise!: (value: ModalResult) => void; + + modalVisible$: Observable = this.modalVisibleSubject.asObservable(); + message$: Observable< + | BusinessListingCriteria + | CommercialPropertyListingCriteria + | UserListingCriteria + > = this.messageSubject.asObservable(); + + showModal( + message: + | BusinessListingCriteria + | CommercialPropertyListingCriteria + | UserListingCriteria + ): Promise { + this.messageSubject.next(message); + this.modalVisibleSubject.next(true); + return new Promise((resolve) => { + this.resolvePromise = resolve; + }); + } + + accept(): void { + this.modalVisibleSubject.next(false); + this.resolvePromise({ accepted: true }); + } + + reject( + backupCriteria: + | BusinessListingCriteria + | CommercialPropertyListingCriteria + | UserListingCriteria + ): void { + this.modalVisibleSubject.next(false); + this.resolvePromise({ accepted: false, criteria: backupCriteria }); + } +} diff --git a/bizmatch-client/src/app/services/search.service.ts b/bizmatch-client/src/app/services/search.service.ts new file mode 100644 index 0000000..e99ca16 --- /dev/null +++ b/bizmatch-client/src/app/services/search.service.ts @@ -0,0 +1,17 @@ +import { Injectable } from '@angular/core'; +import { Subject } from 'rxjs'; +import { BusinessListingCriteria } from '../../../../bizmatch-server/src/models/main.model'; + +@Injectable({ + providedIn: 'root', +}) +export class SearchService { + private criteriaSource = new Subject(); + currentCriteria = this.criteriaSource.asObservable(); + + constructor() {} + + search(criteria: BusinessListingCriteria): void { + this.criteriaSource.next(criteria); + } +} diff --git a/bizmatch-client/src/app/services/select-options.service.ts b/bizmatch-client/src/app/services/select-options.service.ts new file mode 100644 index 0000000..1227dcf --- /dev/null +++ b/bizmatch-client/src/app/services/select-options.service.ts @@ -0,0 +1,90 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { lastValueFrom } from 'rxjs'; +import { KeyValue, KeyValueAsSortBy, KeyValueStyle } from '../../../../bizmatch-server/src/models/main.model'; +import { environment } from '../../environments/environment'; + +@Injectable({ + providedIn: 'root', +}) +export class SelectOptionsService { + private apiBaseUrl = environment.apiBaseUrl; + constructor(private http: HttpClient) {} + + async init() { + const allSelectOptions = await lastValueFrom(this.http.get(`${this.apiBaseUrl}/bizmatch/select-options`)); + this.typesOfBusiness = allSelectOptions.typesOfBusiness; + this.prices = allSelectOptions.prices; + this.listingCategories = allSelectOptions.listingCategories; + this.customerTypes = allSelectOptions.customerTypes; + this.customerSubTypes = allSelectOptions.customerSubTypes; + this.states = allSelectOptions.locations; + this.gender = allSelectOptions.gender; + this.typesOfCommercialProperty = allSelectOptions.typesOfCommercialProperty; + this.distances = allSelectOptions.distances; + this.sortByOptions = allSelectOptions.sortByOptions; + } + public typesOfBusiness: Array; + + public typesOfCommercialProperty: Array; + + public prices: Array; + + public listingCategories: Array; + + public customerTypes: Array; + + public gender: Array; + + public states: Array; + public customerSubTypes: Array; + public distances: Array; + public sortByOptions: Array; + getSortByOption(value: string) { + return this.sortByOptions.find(l => l.value === value)?.name; + } + getState(value: string): string { + return this.states.find(l => l.value === value)?.name; + } + getStateInitials(name: string): string { + return this.states.find(l => l.name === name?.toUpperCase())?.value; + } + getBusiness(value: string): string { + return this.typesOfBusiness.find(t => t.value === value)?.name; + } + getCommercialProperty(value: string): string { + return this.typesOfCommercialProperty.find(t => t.value === value)?.name; + } + getListingsCategory(value: string): string { + return this.listingCategories.find(l => l.value === value)?.name; + } + getCustomerType(value: string): string { + return this.customerTypes.find(c => c.value === value)?.name; + } + getCustomerSubType(value: string): string { + return this.customerSubTypes.find(c => c.value === value)?.name; + } + getGender(value: string): string { + return this.gender.find(c => c.value === value)?.name; + } + getIconType(value: string): string { + return this.typesOfBusiness.find(c => c.value === value)?.icon; + } + getTextColorType(value: string): string { + return this.typesOfBusiness.find(c => c.value === value)?.textColorClass; + } + getIconAndTextColorType(value: string): string { + const category = this.typesOfBusiness.find(c => c.value === value); + return `${category?.icon} ${category?.textColorClass}`; + } + getIconTypeOfCommercials(value: string): string { + return this.typesOfCommercialProperty.find(c => c.value === value)?.icon; + } + getIconAndTextColorTypeOfCommercials(value: string): string { + const category = this.typesOfCommercialProperty.find(c => c.value === value); + return `${category?.icon} ${category?.textColorClass}`; + } + getTextColorTypeOfCommercial(value: string): string { + return this.typesOfCommercialProperty.find(c => c.value === value)?.textColorClass; + } +} diff --git a/bizmatch-client/src/app/services/shared.service.ts b/bizmatch-client/src/app/services/shared.service.ts new file mode 100644 index 0000000..4fc6e1d --- /dev/null +++ b/bizmatch-client/src/app/services/shared.service.ts @@ -0,0 +1,16 @@ +import { Injectable } from '@angular/core'; +import { Subject } from 'rxjs'; + +@Injectable({ + providedIn: 'root', +}) +export class SharedService { + private profilePhotoSource = new Subject(); + currentProfilePhoto = this.profilePhotoSource.asObservable(); + + constructor() {} + + changeProfilePhoto(photoUrl: string) { + this.profilePhotoSource.next(photoUrl); + } +} diff --git a/bizmatch-client/src/app/services/user.service.ts b/bizmatch-client/src/app/services/user.service.ts new file mode 100644 index 0000000..8ed5ff8 --- /dev/null +++ b/bizmatch-client/src/app/services/user.service.ts @@ -0,0 +1,140 @@ +import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { lastValueFrom, Observable, Subject } from 'rxjs'; +import urlcat from 'urlcat'; +import { User } from '../../../../bizmatch-server/src/models/db.model'; +import { + FirebaseUserInfo, + KeycloakUser, + ResponseUsersArray, + UserListingCriteria, + UserRole, + UsersResponse, +} from '../../../../bizmatch-server/src/models/main.model'; +import { environment } from '../../environments/environment'; + +@Injectable({ + providedIn: 'root', +}) +export class UserService { + private apiBaseUrl = environment.apiBaseUrl; + + private userSource = new Subject(); + currentUser = this.userSource.asObservable(); + + constructor(private http: HttpClient) {} + + changeUser(user: User) { + this.userSource.next(user); + } + // ----------------------------- + // DB services + // ----------------------------- + async save(user: User): Promise { + return await lastValueFrom( + this.http.post(`${this.apiBaseUrl}/bizmatch/user`, user) + ); + } + async saveGuaranteed(user: User): Promise { + return await lastValueFrom( + this.http.post(`${this.apiBaseUrl}/bizmatch/user/guaranteed`, user) + ); + } + async getById(id: string): Promise { + return await lastValueFrom( + this.http.get(`${this.apiBaseUrl}/bizmatch/user/${id}`) + ); + } + async getByMail(mail: string, hideLoading: boolean = true): Promise { + const url = urlcat(`${this.apiBaseUrl}/bizmatch/user`, { mail }); + let headers = new HttpHeaders(); + if (hideLoading) { + headers = headers.set('X-Hide-Loading', 'true'); + } + return await lastValueFrom(this.http.get(url, { headers })); + } + async search(criteria?: UserListingCriteria): Promise { + return await lastValueFrom( + this.http.post( + `${this.apiBaseUrl}/bizmatch/user/search`, + criteria + ) + ); + } + getNumberOfBroker(criteria?: UserListingCriteria): Observable { + return this.http.post( + `${this.apiBaseUrl}/bizmatch/user/findTotal`, + criteria + ); + } + getKeycloakUser(id: string): Promise { + return lastValueFrom( + this.http.get( + `${this.apiBaseUrl}/bizmatch/auth/users/${id}` + ) + ); + } + async updateKeycloakUser(keycloakUser: KeycloakUser): Promise { + await lastValueFrom( + this.http.put( + `${this.apiBaseUrl}/bizmatch/auth/users/${keycloakUser.id}`, + keycloakUser + ) + ); + } + // ------------------------------- + // ADMIN SERVICES + // ------------------------------- + /** + * Ruft alle Benutzer mit Paginierung ab + */ + getAllUsers( + maxResults?: number, + pageToken?: string + ): Observable { + let params = new HttpParams(); + + if (maxResults) { + params = params.set('maxResults', maxResults.toString()); + } + + if (pageToken) { + params = params.set('pageToken', pageToken); + } + + return this.http.get(`${this.apiBaseUrl}/bizmatch/auth`, { + params, + }); + } + + /** + * Ruft Benutzer mit einer bestimmten Rolle ab + */ + getUsersByRole(role: UserRole): Observable<{ users: FirebaseUserInfo[] }> { + return this.http.get<{ users: FirebaseUserInfo[] }>( + `${this.apiBaseUrl}/bizmatch/auth/role/${role}` + ); + } + + /** + * Ändert die Rolle eines Benutzers + */ + setUserRole(uid: string, role: UserRole): Observable<{ success: boolean }> { + return this.http.post<{ success: boolean }>( + `${this.apiBaseUrl}/${uid}/bizmatch/auth/role`, + { role } + ); + } + + // ------------------------------- + // OLDADMIN SERVICES + // ------------------------------- + + async deleteCustomerFromStripe(customerId: string): Promise { + await lastValueFrom( + this.http.delete( + `${this.apiBaseUrl}/bizmatch/payment/customer/${customerId}` + ) + ); + } +} diff --git a/bizmatch-client/src/app/utils/utils.ts b/bizmatch-client/src/app/utils/utils.ts new file mode 100644 index 0000000..0805ad6 --- /dev/null +++ b/bizmatch-client/src/app/utils/utils.ts @@ -0,0 +1,278 @@ +import { Router } from '@angular/router'; +import { ConsoleFormattedStream, INFO, createLogger as _createLogger, stdSerializers } from 'browser-bunyan'; +import { jwtDecode } from 'jwt-decode'; +import onChange from 'on-change'; +import { User } from '../../../../bizmatch-server/src/models/db.model'; +import { BusinessListingCriteria, JwtToken, KeycloakUser, MailInfo } from '../../../../bizmatch-server/src/models/main.model'; +import { environment } from '../../environments/environment'; + +export function createEmptyBusinessListingCriteria(): BusinessListingCriteria { + return { + start: 0, + length: 0, + page: 0, + state: null, + city: null, + types: [], + prompt: '', + sortBy: null, + criteriaType: 'businessListings', + 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: '', + searchType: 'exact', + radius: null, + }; +} + +export function resetBusinessListingCriteria(criteria: BusinessListingCriteria) { + criteria.start = 0; + criteria.length = 0; + criteria.page = 0; + criteria.state = null; + criteria.city = null; + criteria.types = []; + criteria.prompt = ''; + criteria.sortBy = null; + criteria.criteriaType = 'businessListings'; + criteria.minPrice = null; + criteria.maxPrice = null; + criteria.minRevenue = null; + criteria.maxRevenue = null; + criteria.minCashFlow = null; + criteria.maxCashFlow = null; + criteria.minNumberEmployees = null; + criteria.maxNumberEmployees = null; + criteria.establishedSince = null; + criteria.establishedUntil = null; + criteria.realEstateChecked = false; + criteria.leasedLocation = false; + criteria.franchiseResale = false; + criteria.title = ''; + criteria.brokerName = ''; + criteria.searchType = 'exact'; + criteria.radius = null; +} + +export function createMailInfo(user?: User): MailInfo { + return { + sender: user + ? { + name: `${user.firstname} ${user.lastname}`, + email: user.email, + phoneNumber: user.phoneNumber, + state: user.location?.state, + comments: null, + } + : { name: '', email: '', phoneNumber: '', state: '', comments: '' }, + email: null, + url: environment.mailinfoUrl, + listing: null, + }; +} +export function createLogger(name: string, level: number = INFO, options: any = {}) { + return _createLogger({ + name, + streams: [{ level, stream: new ConsoleFormattedStream() }], + serializers: stdSerializers, + src: true, + ...options, + }); +} +export function formatPhoneNumber(phone: string): string { + const cleaned = ('' + phone).replace(/\D/g, ''); + const match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/); + if (match) { + return '(' + match[1] + ') ' + match[2] + '-' + match[3]; + } + return phone; +} + +export const getSessionStorageHandler = function (criteriaType, path, value, previous, applyData) { + sessionStorage.setItem(`${criteriaType}_criteria`, JSON.stringify(this)); + console.log('Zusätzlicher Parameter:', criteriaType); +}; +export const getSessionStorageHandlerWrapper = param => { + return function (path, value, previous, applyData) { + getSessionStorageHandler.call(this, param, path, value, previous, applyData); + }; +}; + +export function routeListingWithState(router: Router, value: string, data: any) { + if (value === 'business') { + router.navigate(['createBusinessListing'], { state: { data } }); + } else { + router.navigate(['createCommercialPropertyListing'], { state: { data } }); + } +} + +export function map2User(jwt: string | null): KeycloakUser { + if (jwt) { + const token = jwtDecode(jwt); + return { + id: token.user_id, + firstName: token.given_name, + lastName: token.family_name, + email: token.email, + }; + } else { + return null; + } +} +export function getImageDimensions(imageUrl: string): Promise<{ width: number; height: number }> { + return new Promise(resolve => { + const img = new Image(); + img.onload = () => { + resolve({ width: img.width, height: img.height }); + }; + img.src = imageUrl; + }); +} + +export function getDialogWidth(dimensions): string { + const aspectRatio = dimensions.width / dimensions.height; + let dialogWidth = '50vw'; // Standardbreite + + // Passen Sie die Breite basierend auf dem Seitenverhältnis an + if (aspectRatio < 1) { + dialogWidth = '30vw'; // Hochformat + } else if (aspectRatio > 1) { + dialogWidth = '50vw'; // Querformat + } + return dialogWidth; +} + +export function compareObjects(obj1: T, obj2: T, ignoreProperties: (keyof T)[] = []): number { + let differences = 0; + const keys = Object.keys(obj1) as Array; + + for (const key of keys) { + if (ignoreProperties.includes(key)) { + continue; // Überspringe diese Eigenschaft, wenn sie in der Ignore-Liste ist + } + + const value1 = obj1[key]; + const value2 = obj2[key]; + + if (!areValuesEqual(value1, value2)) { + differences++; + } + } + + return differences; +} + +function areValuesEqual(value1: any, value2: any): boolean { + if (Array.isArray(value1) || Array.isArray(value2)) { + return arraysEqual(value1, value2); + } + + if (typeof value1 === 'string' || typeof value2 === 'string') { + return isEqualString(value1, value2); + } + + if (typeof value1 === 'number' || typeof value2 === 'number') { + return isEqualNumber(value1, value2); + } + + if (typeof value1 === 'boolean' || typeof value2 === 'boolean') { + return isEqualBoolean(value1, value2); + } + + return value1 === value2; +} + +function isEqualString(value1: any, value2: any): boolean { + const isEmptyOrNullish1 = value1 === undefined || value1 === null || value1 === ''; + const isEmptyOrNullish2 = value2 === undefined || value2 === null || value2 === ''; + return (isEmptyOrNullish1 && isEmptyOrNullish2) || value1 === value2; +} + +function isEqualNumber(value1: any, value2: any): boolean { + const isZeroOrNullish1 = value1 === undefined || value1 === null || value1 === 0; + const isZeroOrNullish2 = value2 === undefined || value2 === null || value2 === 0; + return (isZeroOrNullish1 && isZeroOrNullish2) || value1 === value2; +} + +function isEqualBoolean(value1: any, value2: any): boolean { + const isFalseOrNullish1 = value1 === undefined || value1 === null || value1 === false; + const isFalseOrNullish2 = value2 === undefined || value2 === null || value2 === false; + return (isFalseOrNullish1 && isFalseOrNullish2) || value1 === value2; +} + +function arraysEqual(arr1: any[] | null | undefined, arr2: any[] | null | undefined): boolean { + if (arr1 === arr2) return true; + if (arr1 == null || arr2 == null) return false; + if (arr1.length !== arr2.length) return false; + + for (let i = 0; i < arr1.length; i++) { + if (!areValuesEqual(arr1[i], arr2[i])) return false; + } + return true; +} +export function assignProperties(target, source) { + for (let key in source) { + if (source.hasOwnProperty(key)) { + target[key] = source[key]; + } + } + return target; +} +export function checkAndUpdate(changed: boolean, condition: boolean, assignment: () => any): boolean { + if (condition) { + assignment(); + } + return changed || condition; +} +// ----------------------------- +// Criteria Proxy +// ----------------------------- +export function getCriteriaStateObject(criteriaType: 'businessListings' | 'commercialPropertyListings' | 'brokerListings') { + const initialState = createEmptyBusinessListingCriteria(); + + const storedState = sessionStorage.getItem(`${criteriaType}`); + return storedState ? JSON.parse(storedState) : initialState; +} +export function getCriteriaProxy(path: string, component: any): BusinessListingCriteria { + if ('businessListings' === path) { + return createEnhancedProxy(getCriteriaStateObject('businessListings'), component); + } else { + return undefined; + } +} +export function createEnhancedProxy(obj: BusinessListingCriteria, component: any) { + const sessionStorageHandler = function (path, value, previous, applyData) { + sessionStorage.setItem(`${obj.criteriaType}`, JSON.stringify(this)); + }; + + return onChange(obj, function (path, value, previous, applyData) { + // Call the original sessionStorageHandler + sessionStorageHandler.call(this, path, value, previous, applyData); + + // Notify about the criteria change using the component's context + if (component.criteriaChangeService) { + component.criteriaChangeService.notifyCriteriaChange(); + } + }); +} +export const TOOLBAR_OPTIONS = { + toolbar: [ + ['bold', 'italic', 'underline'], // Einige Standardoptionen + [{ header: [1, 2, 3, false] }], // Benutzerdefinierte Header + [{ list: 'ordered' }, { list: 'bullet' }], + [{ color: [] }], // Dropdown mit Standardfarben + ['clean'], // Entfernt Formatierungen + ], +}; diff --git a/bizmatch-client/src/assets/.gitkeep b/bizmatch-client/src/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/bizmatch-client/src/assets/cropped-Favicon-32x32.png b/bizmatch-client/src/assets/cropped-Favicon-32x32.png new file mode 100644 index 0000000..f4489b4 Binary files /dev/null and b/bizmatch-client/src/assets/cropped-Favicon-32x32.png differ diff --git a/bizmatch-client/src/assets/data/listings.json b/bizmatch-client/src/assets/data/listings.json new file mode 100644 index 0000000..6bc6f9a --- /dev/null +++ b/bizmatch-client/src/assets/data/listings.json @@ -0,0 +1,70 @@ +[ + { + "id":"1", + "userId":"14a05316-cb85-4c67-86bc-4a2083ff6af7", + "listingsCategory": "business", + "title": "Industrial Service Company In Corpus Christi For Sale - 1954", + "summary": ["Asking price: $5,500,000","Sales revenue: $1,200,000","Net profit: $650,000"], + "description": ["This company services a wide variety of industries. Asking price includes Business and the Real Estate and is approx 30,000 sq ft with room for expansion including approx 5 acres. Absentee run business."], + "type": "Industrial Services", + "location": "Texas", + "price":5500000, + "salesRevenue":1200000, + "cashFlow":650000, + "brokerLicencing":"TREC Broker #516788", + "established":1954, + "realEstateIncluded":false, + "favoritesForUser":["e0811669-c7eb-4e5e-a699-e8334d5c5b01"] + }, + { + "id":"2", + "userId":"e0811669-c7eb-4e5e-a699-e8334d5c5b01", + "listingsCategory": "business", + "title": "Coastal Bend Manufacturing Business Plastic Injection For Sale - 1950", + "summary": ["Asking price: $165,000","Sales revenue: Undisclosed","Net profit: Undisclosed"], + "description": [""], + "type": "Manufacturing", + "location": "Texas", + "price":165000, + "salesRevenue":null, + "cashFlow":null, + "brokerLicencing":"TREC Broker #516788", + "established":1950, + "realEstateIncluded":false, + "favoritesForUser":["828cc120-51e9-4baa-9a33-a82608fe66b4"] + }, + { + "id":"3", + "userId":"e0811669-c7eb-4e5e-a699-e8334d5c5b01", + "listingsCategory": "business", + "title": "Corner Property On Everhart South-side Corpus Christi For Sale - 1944", + "summary": ["Asking price: $830,000","Sales revenue: Undisclosed","Net profit: Undisclosed"], + "description": [""], + "type": "Real Estate", + "location": "Texas", + "price":830000, + "salesRevenue":null, + "cashFlow":null, + "brokerLicencing":"TREC Broker #516788", + "established":1944, + "realEstateIncluded":false, + "favoritesForUser":[] + }, + { + "id":"4", + "userId":"828cc120-51e9-4baa-9a33-a82608fe66b4", + "listingsCategory": "business", + "title": "Corpus Christi Dessert Business For Sale - 1941", + "summary": ["Asking price: $124,900","Sales revenue: $225,000","Net profit: $50,000"], + "description": [""], + "type": "Food and Restaurant", + "location": "Texas", + "price":830000, + "salesRevenue":225000, + "cashFlow":50000, + "brokerLicencing":"TREC Broker #516788", + "established":1941, + "realEstateIncluded":false, + "favoritesForUser":[] + } + ] \ No newline at end of file diff --git a/bizmatch-client/src/assets/data/user.json b/bizmatch-client/src/assets/data/user.json new file mode 100644 index 0000000..f17c176 --- /dev/null +++ b/bizmatch-client/src/assets/data/user.json @@ -0,0 +1,21 @@ +{ + "id":"1", + "firstname":"Andreas", + "lastname":"Knuth", + "email":"andreas.knuth@gmail.com", + "nickname":"aknuth", + "displayName":"Andreas Knuth", + "subscriptions":[{ + "id":"1", + "level":"Business Broker", + "start":"2024-02-12T21:54:20.603Z", + "modified":"2024-02-12T21:54:20.603Z", + "end":"9999-02-12T21:54:20.603Z", + "status":"active", + "invoices":[{ + "date":"2024-02-12T21:54:20.603Z", + "id":"C991853B99", + "price":0 + }] + }] +} \ No newline at end of file diff --git a/bizmatch-client/src/assets/favicon.png b/bizmatch-client/src/assets/favicon.png new file mode 100644 index 0000000..017f986 Binary files /dev/null and b/bizmatch-client/src/assets/favicon.png differ diff --git a/bizmatch-client/src/assets/images/1_Version.jpg b/bizmatch-client/src/assets/images/1_Version.jpg new file mode 100644 index 0000000..8e3a3e9 Binary files /dev/null and b/bizmatch-client/src/assets/images/1_Version.jpg differ diff --git a/bizmatch-client/src/assets/images/2_1_Version.jpg b/bizmatch-client/src/assets/images/2_1_Version.jpg new file mode 100644 index 0000000..c70083d Binary files /dev/null and b/bizmatch-client/src/assets/images/2_1_Version.jpg differ diff --git a/bizmatch-client/src/assets/images/2_Version.jpg b/bizmatch-client/src/assets/images/2_Version.jpg new file mode 100644 index 0000000..08605bc Binary files /dev/null and b/bizmatch-client/src/assets/images/2_Version.jpg differ diff --git a/bizmatch-client/src/assets/images/avatar-f-3.png b/bizmatch-client/src/assets/images/avatar-f-3.png new file mode 100644 index 0000000..7c3d3a9 Binary files /dev/null and b/bizmatch-client/src/assets/images/avatar-f-3.png differ diff --git a/bizmatch-client/src/assets/images/bw-sky.jpg b/bizmatch-client/src/assets/images/bw-sky.jpg new file mode 100644 index 0000000..65fd5e1 Binary files /dev/null and b/bizmatch-client/src/assets/images/bw-sky.jpg differ diff --git a/bizmatch-client/src/assets/images/corpusChristiSkyline.jpg b/bizmatch-client/src/assets/images/corpusChristiSkyline.jpg new file mode 100644 index 0000000..5aac1b2 Binary files /dev/null and b/bizmatch-client/src/assets/images/corpusChristiSkyline.jpg differ diff --git a/bizmatch-client/src/assets/images/header-logo.png b/bizmatch-client/src/assets/images/header-logo.png new file mode 100644 index 0000000..aba9071 Binary files /dev/null and b/bizmatch-client/src/assets/images/header-logo.png differ diff --git a/bizmatch-client/src/assets/images/index-bg.jpg b/bizmatch-client/src/assets/images/index-bg.jpg new file mode 100644 index 0000000..85f8e8b Binary files /dev/null and b/bizmatch-client/src/assets/images/index-bg.jpg differ diff --git a/bizmatch-client/src/assets/images/index-bg.webp b/bizmatch-client/src/assets/images/index-bg.webp new file mode 100644 index 0000000..54d8c6d Binary files /dev/null and b/bizmatch-client/src/assets/images/index-bg.webp differ diff --git a/bizmatch-client/src/assets/images/person_placeholder.jpg b/bizmatch-client/src/assets/images/person_placeholder.jpg new file mode 100644 index 0000000..5e2b51e Binary files /dev/null and b/bizmatch-client/src/assets/images/person_placeholder.jpg differ diff --git a/bizmatch-client/src/assets/images/placeholder.png b/bizmatch-client/src/assets/images/placeholder.png new file mode 100644 index 0000000..85156a3 Binary files /dev/null and b/bizmatch-client/src/assets/images/placeholder.png differ diff --git a/bizmatch-client/src/assets/images/placeholder_properties.jpg b/bizmatch-client/src/assets/images/placeholder_properties.jpg new file mode 100644 index 0000000..e411207 Binary files /dev/null and b/bizmatch-client/src/assets/images/placeholder_properties.jpg differ diff --git a/bizmatch-client/src/assets/images/pricing-4.svg b/bizmatch-client/src/assets/images/pricing-4.svg new file mode 100644 index 0000000..de994ae --- /dev/null +++ b/bizmatch-client/src/assets/images/pricing-4.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/bizmatch-client/src/assets/images/video-poster.png b/bizmatch-client/src/assets/images/video-poster.png new file mode 100644 index 0000000..97131bd Binary files /dev/null and b/bizmatch-client/src/assets/images/video-poster.png differ diff --git a/bizmatch-client/src/assets/images/video-poster_.png b/bizmatch-client/src/assets/images/video-poster_.png new file mode 100644 index 0000000..7a23ce2 Binary files /dev/null and b/bizmatch-client/src/assets/images/video-poster_.png differ diff --git a/bizmatch-client/src/assets/leaflet/layers-2x.png b/bizmatch-client/src/assets/leaflet/layers-2x.png new file mode 100644 index 0000000..200c333 Binary files /dev/null and b/bizmatch-client/src/assets/leaflet/layers-2x.png differ diff --git a/bizmatch-client/src/assets/leaflet/layers.png b/bizmatch-client/src/assets/leaflet/layers.png new file mode 100644 index 0000000..1a72e57 Binary files /dev/null and b/bizmatch-client/src/assets/leaflet/layers.png differ diff --git a/bizmatch-client/src/assets/leaflet/marker-icon-2x.png b/bizmatch-client/src/assets/leaflet/marker-icon-2x.png new file mode 100644 index 0000000..88f9e50 Binary files /dev/null and b/bizmatch-client/src/assets/leaflet/marker-icon-2x.png differ diff --git a/bizmatch-client/src/assets/leaflet/marker-icon.png b/bizmatch-client/src/assets/leaflet/marker-icon.png new file mode 100644 index 0000000..950edf2 Binary files /dev/null and b/bizmatch-client/src/assets/leaflet/marker-icon.png differ diff --git a/bizmatch-client/src/assets/leaflet/marker-shadow.png b/bizmatch-client/src/assets/leaflet/marker-shadow.png new file mode 100644 index 0000000..9fd2979 Binary files /dev/null and b/bizmatch-client/src/assets/leaflet/marker-shadow.png differ diff --git a/bizmatch-client/src/assets/silent-check-sso.html b/bizmatch-client/src/assets/silent-check-sso.html new file mode 100644 index 0000000..f4de3a9 --- /dev/null +++ b/bizmatch-client/src/assets/silent-check-sso.html @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/bizmatch-client/src/assets/videos/Bizmatch30Spot.mp4 b/bizmatch-client/src/assets/videos/Bizmatch30Spot.mp4 new file mode 100755 index 0000000..9b56200 Binary files /dev/null and b/bizmatch-client/src/assets/videos/Bizmatch30Spot.mp4 differ diff --git a/bizmatch-client/src/build.ts b/bizmatch-client/src/build.ts new file mode 100644 index 0000000..a06d4d1 --- /dev/null +++ b/bizmatch-client/src/build.ts @@ -0,0 +1,6 @@ +// Build information, automatically generated by `the_build_script` :zwinkern: +const build = { + timestamp: "GER: 16.05.2024 22:55 | TX: 05/16/2024 3:55 PM" +}; + +export default build; \ No newline at end of file diff --git a/bizmatch-client/src/environments/environment.base.ts b/bizmatch-client/src/environments/environment.base.ts new file mode 100644 index 0000000..2f02d29 --- /dev/null +++ b/bizmatch-client/src/environments/environment.base.ts @@ -0,0 +1,25 @@ +export const hostname = window.location.hostname; +export const environment_base = { + // apiBaseUrl: 'http://localhost:3000', + apiBaseUrl: `http://${hostname}:4200`, + imageBaseUrl: 'https://dev.bizmatch.net', + buildVersion: '', + mailinfoUrl: 'https://dev.bizmatch.net', + keycloak: { + url: 'https://auth.bizmatch.net', + realm: 'bizmatch-dev', + clientId: 'bizmatch-dev', + redirectUri: 'https://dev.bizmatch.net', + }, + ipinfo_token: '7029590fb91214', + firebaseConfig: { + apiKey: 'AIzaSyBqVutQqdgUzwD9tKiKJrJq2Q6rD1hNdzw', + //authDomain: 'bizmatch-net.firebaseapp.com', + authDomain: 'auth.bizmatch.net', + projectId: 'bizmatch-net', + storageBucket: 'bizmatch-net.firebasestorage.app', + messagingSenderId: '1065122571067', + appId: '1:1065122571067:web:1124571ab67bc0f5240d1e', + measurementId: 'G-MHVDK1KSWV', + }, +}; diff --git a/bizmatch-client/src/environments/environment.ts b/bizmatch-client/src/environments/environment.ts new file mode 100644 index 0000000..d5ba7d9 --- /dev/null +++ b/bizmatch-client/src/environments/environment.ts @@ -0,0 +1,25 @@ +export const hostname = window.location.hostname; +export const environment = { + // apiBaseUrl: 'http://localhost:3000', + apiBaseUrl: `http://${hostname}:4200`, + imageBaseUrl: 'https://dev.bizmatch.net', + buildVersion: '', + mailinfoUrl: 'https://dev.bizmatch.net', + keycloak: { + url: 'https://auth.bizmatch.net', + realm: 'bizmatch-dev', + clientId: 'bizmatch-dev', + redirectUri: 'https://dev.bizmatch.net', + }, + ipinfo_token: '7029590fb91214', + firebaseConfig: { + apiKey: 'AIzaSyBqVutQqdgUzwD9tKiKJrJq2Q6rD1hNdzw', + //authDomain: 'bizmatch-net.firebaseapp.com', + authDomain: 'auth.bizmatch.net', + projectId: 'bizmatch-net', + storageBucket: 'bizmatch-net.firebasestorage.app', + messagingSenderId: '1065122571067', + appId: '1:1065122571067:web:1124571ab67bc0f5240d1e', + measurementId: 'G-MHVDK1KSWV', + }, +}; diff --git a/bizmatch-client/src/favicon.png b/bizmatch-client/src/favicon.png new file mode 100644 index 0000000..017f986 Binary files /dev/null and b/bizmatch-client/src/favicon.png differ diff --git a/bizmatch-client/src/index.html b/bizmatch-client/src/index.html new file mode 100644 index 0000000..42fb79c --- /dev/null +++ b/bizmatch-client/src/index.html @@ -0,0 +1,13 @@ + + + + + BizmatchClient + + + + + + + + diff --git a/bizmatch-client/src/main.server.ts b/bizmatch-client/src/main.server.ts new file mode 100644 index 0000000..4b9d4d1 --- /dev/null +++ b/bizmatch-client/src/main.server.ts @@ -0,0 +1,7 @@ +import { bootstrapApplication } from '@angular/platform-browser'; +import { AppComponent } from './app/app.component'; +import { config } from './app/app.config.server'; + +const bootstrap = () => bootstrapApplication(AppComponent, config); + +export default bootstrap; diff --git a/bizmatch-client/src/main.ts b/bizmatch-client/src/main.ts new file mode 100644 index 0000000..35b00f3 --- /dev/null +++ b/bizmatch-client/src/main.ts @@ -0,0 +1,6 @@ +import { bootstrapApplication } from '@angular/platform-browser'; +import { appConfig } from './app/app.config'; +import { AppComponent } from './app/app.component'; + +bootstrapApplication(AppComponent, appConfig) + .catch((err) => console.error(err)); diff --git a/bizmatch-client/src/server.ts b/bizmatch-client/src/server.ts new file mode 100644 index 0000000..0ddcff3 --- /dev/null +++ b/bizmatch-client/src/server.ts @@ -0,0 +1,67 @@ +import { APP_BASE_HREF } from '@angular/common'; +import { CommonEngine, isMainModule } from '@angular/ssr/node'; +import express from 'express'; +import { dirname, join, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import bootstrap from './main.server'; + +const serverDistFolder = dirname(fileURLToPath(import.meta.url)); +const browserDistFolder = resolve(serverDistFolder, '../browser'); +const indexHtml = join(serverDistFolder, 'index.server.html'); + +const app = express(); +const commonEngine = new CommonEngine(); + +/** + * Example Express Rest API endpoints can be defined here. + * Uncomment and define endpoints as necessary. + * + * Example: + * ```ts + * app.get('/api/**', (req, res) => { + * // Handle API request + * }); + * ``` + */ + +/** + * Serve static files from /browser + */ +app.get( + '**', + express.static(browserDistFolder, { + maxAge: '1y', + index: 'index.html' + }), +); + +/** + * Handle all other requests by rendering the Angular application. + */ +app.get('**', (req, res, next) => { + const { protocol, originalUrl, baseUrl, headers } = req; + + commonEngine + .render({ + bootstrap, + documentFilePath: indexHtml, + url: `${protocol}://${headers.host}${originalUrl}`, + publicPath: browserDistFolder, + providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }], + }) + .then((html) => res.send(html)) + .catch((err) => next(err)); +}); + +/** + * Start the server if this module is the main entry point. + * The server listens on the port defined by the `PORT` environment variable, or defaults to 4000. + */ +if (isMainModule(import.meta.url)) { + const port = process.env['PORT'] || 4000; + app.listen(port, () => { + console.log(`Node Express server listening on http://localhost:${port}`); + }); +} + +export default app; diff --git a/bizmatch-client/src/styles.scss b/bizmatch-client/src/styles.scss new file mode 100644 index 0000000..7985189 --- /dev/null +++ b/bizmatch-client/src/styles.scss @@ -0,0 +1,111 @@ +@import url('https://fonts.googleapis.com/css?family=Open+Sans&display=swap'); +@import '@fortawesome/fontawesome-free/css/all.min.css'; + +@import 'tailwindcss/base.css'; +@import 'tailwindcss/components.css'; +@import 'tailwindcss/utilities.css'; + +@import 'ngx-sharebuttons/themes/default'; + +:root { + --text-color-secondary: rgba(255, 255, 255); + --wrapper-width: 1491px; + // --secondary-color: #ffffff; /* Setzt die secondary Farbe auf weiß */ +} +.p-button.p-button-secondary.p-button-outlined { + color: #ffffff; +} +html, +body, +app-root { + margin: 0; + height: 100%; + &:hover a { + cursor: pointer; + } +} + +app-root { + display: flex; + flex-direction: column; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + margin: 0; +} + +body, +input, +button, +select, +textarea { + // font-family: 'Open Sans', sans-serif; + font-family: var(--font-family); + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.wrapper { + min-height: 100%; + display: flex; + flex-direction: column; +} + +// header { +// height: 64px; /* Feste Höhe */ +// } + +main { + flex: 1 0 auto; /* Füllt den verfügbaren Platz */ +} + +footer { + flex-shrink: 0; /* Verhindert Schrumpfen */ +} + +*:focus, +.p-focus { + box-shadow: none !important; +} + +p-menubarsub ul { + gap: 4px; +} + +::-webkit-scrollbar { + width: 3px; +} + +::-webkit-scrollbar-track { + background: transparent; +} + +::-webkit-scrollbar-thumb { + background-color: rgba(155, 155, 155, 0.5); + border-radius: 20px; + border: transparent; +} + +.wrapper { + width: var(--wrapper-width); + max-width: 100%; + height: 100%; + margin: auto; +} +.p-editor-container .ql-toolbar { + background: #f9fafb; + border-top-right-radius: 6px; + border-top-left-radius: 6px; +} +.p-dropdown-panel .p-dropdown-header .p-dropdown-filter { + margin-right: 0 !important; +} +input::placeholder, +textarea::placeholder { + color: #999 !important; +} diff --git a/bizmatch-client/tailwind.config.js b/bizmatch-client/tailwind.config.js new file mode 100644 index 0000000..3d0bc83 --- /dev/null +++ b/bizmatch-client/tailwind.config.js @@ -0,0 +1,50 @@ +module.exports = { + safelist: [ + 'text-red-400', + 'text-purple-400', + 'text-pink-400', + 'text-teal-400', + 'text-green-400', + 'text-yellow-400', + 'text-blue-400', + 'text-cyan-400', + 'text-gray-400', + 'text-sky-400', + 'text-orange-400', + 'text-violet-400', + 'text-indigo-400', + 'text-amber-700' + // Fügen Sie hier alle möglichen Farbklassen hinzu, die dynamisch geladen werden könnten + ], + content: [ + "./src/**/*.{html,ts}", + "./node_modules/flowbite/**/*.js" // add this line + ], + theme: { + extend: { + fontSize: { + 'xs': '.75rem', + 'sm': '.875rem', + 'base': '1rem', + 'lg': '1.125rem', + 'xl': '1.25rem', + '2xl': '1.5rem', + '3xl': '1.875rem', + '4xl': '2.25rem', + '5xl': '3rem', + }, + dropShadow: { + 'custom-bg': '0 15px 20px rgba(0, 0, 0, 0.3)', // Wähle einen aussagekräftigen Namen + 'custom-bg-mobile': '0 1px 2px rgba(0, 0, 0, 0.2)', // Wähle einen aussagekräftigen Namen + 'inner-faint': '0 3px 6px rgba(0, 0, 0, 0.1)', + 'custom-md': '0 10px 15px rgba(0, 0, 0, 0.25)', // Dein mittlerer Schatten + 'custom-lg': '0 15px 20px rgba(0, 0, 0, 0.3)' // Dein großer Schatten + // ... andere benutzerdefinierte Schatten, falls vorhanden + } + }, + }, + plugins: [ + require('flowbite/plugin') // add this line + ], +} + diff --git a/bizmatch-client/tsconfig.app.json b/bizmatch-client/tsconfig.app.json new file mode 100644 index 0000000..9ab8527 --- /dev/null +++ b/bizmatch-client/tsconfig.app.json @@ -0,0 +1,19 @@ +/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ +/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/app", + "types": [ + "node" + ] + }, + "files": [ + "src/main.ts", + "src/main.server.ts", + "src/server.ts" + ], + "include": [ + "src/**/*.d.ts" + ] +} diff --git a/bizmatch-client/tsconfig.json b/bizmatch-client/tsconfig.json new file mode 100644 index 0000000..268414f --- /dev/null +++ b/bizmatch-client/tsconfig.json @@ -0,0 +1,27 @@ +/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ +/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ +{ + "compileOnSave": false, + "compilerOptions": { + "outDir": "./dist/out-tsc", + "strict": false, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "skipLibCheck": true, + "isolatedModules": true, + "esModuleInterop": true, + "experimentalDecorators": true, + "moduleResolution": "bundler", + "importHelpers": true, + "target": "ES2022", + "module": "ES2022" + }, + "angularCompilerOptions": { + "enableI18nLegacyMessageIdFormat": false, + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true + } +} diff --git a/bizmatch-client/tsconfig.spec.json b/bizmatch-client/tsconfig.spec.json new file mode 100644 index 0000000..5fb748d --- /dev/null +++ b/bizmatch-client/tsconfig.spec.json @@ -0,0 +1,15 @@ +/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ +/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/spec", + "types": [ + "jasmine" + ] + }, + "include": [ + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/bizmatch-client/version.js b/bizmatch-client/version.js new file mode 100644 index 0000000..9fd9c49 --- /dev/null +++ b/bizmatch-client/version.js @@ -0,0 +1,35 @@ +#! /usr/bin/env node +const fs = require('fs'); +const dayjs = require('dayjs'); +const timezone = require('dayjs/plugin/timezone'); +const utc = require('dayjs/plugin/utc'); +var localizedFormat = require('dayjs/plugin/localizedFormat'); + +dayjs.extend(utc); +dayjs.extend(timezone); +dayjs.extend(localizedFormat); + +const write = (content, path) => { + const writePath = path || `${process.cwd()}/src/build.ts`; + try { + fs.writeFileSync( + writePath, + '// Build information, automatically generated by `the_build_script` :zwinkern:\n' + 'const build = ' + JSON.stringify(content, null, 4).replace(/\"([^(\")"]+)\":/g, '$1:') + ';\n\nexport default build;', + ); + } catch (error) { + console.log(error); + } +}; +const package = require(`${process.cwd()}/package.json`); +(() => { + console.log('start build.js script ...'); + // Generate `build` object + const build = {}; + const acDate = new Date(); + const german = dayjs(acDate).tz('Europe/Berlin').format('DD.MM.YYYY HH:mm'); + const texan = dayjs(acDate).tz('America/Chicago').format('L LT'); + build.timestamp = `GER: ${german} | TX: ${texan}`; + // Write Build information to file + write(build); + console.log('build.js script finished ...'); +})();