new initialization process, keycloak update 24.0.4

This commit is contained in:
2024-05-20 15:54:01 -05:00
parent 747435bfba
commit dc9adb151d
30 changed files with 379 additions and 389 deletions

View File

@@ -3,7 +3,7 @@ import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
import { lastValueFrom } from 'rxjs';
import { ListingsService } from '../../../services/listings.service';
import { SelectOptionsService } from '../../../services/select-options.service';
import { createDefaultBusinessListing, routeListingWithState } from '../../../utils/utils';
import { createDefaultBusinessListing, map2User, routeListingWithState } from '../../../utils/utils';
import { DragDropModule } from '@angular/cdk/drag-drop';
import { faTrash } from '@fortawesome/free-solid-svg-icons';
@@ -23,6 +23,7 @@ import { InputNumberModule } from '../../../components/inputnumber/inputnumber.c
import { ArrayToStringPipe } from '../../../pipes/array-to-string.pipe';
import { GeoService } from '../../../services/geo.service';
import { ImageService } from '../../../services/image.service';
import { KeycloakService } from '../../../services/keycloak.service';
import { LoadingService } from '../../../services/loading.service';
import { UserService } from '../../../services/user.service';
import { SharedModule } from '../../../shared/shared/shared.module';
@@ -99,6 +100,7 @@ export class EditBusinessListingComponent {
public dialogService: DialogService,
private confirmationService: ConfirmationService,
private route: ActivatedRoute,
private keycloakService: KeycloakService,
) {
this.router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
@@ -115,11 +117,13 @@ export class EditBusinessListingComponent {
});
}
async ngOnInit() {
const token = await this.keycloakService.getToken();
const keycloakUser = map2User(token);
if (this.mode === 'edit') {
this.listing = await lastValueFrom(this.listingsService.getListingById(this.id, 'business'));
} else {
this.listing = createDefaultBusinessListing();
this.listing.userId = await this.userService.getId();
this.listing.userId = await this.userService.getId(keycloakUser.email);
if (this.data) {
this.listing.title = this.data?.title;
this.listing.description = this.data?.description;