2025-07-17 13:56:18 -03:00
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
|
|
import { afterNextRender, Component, inject, viewChild } from '@angular/core';
|
|
|
|
|
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
|
|
|
|
import { MatAccordion } from '@angular/material/expansion';
|
|
|
|
|
import { UserPreferences } from '../../core/models/user-preference';
|
|
|
|
|
import { ActivatedRoute } from '@angular/router';
|
|
|
|
|
import { UserPreferencesService } from '../../core/services/user-preference.service';
|
|
|
|
|
import { BasicDetailComponent } from '../basic-details/basic-details.component';
|
|
|
|
|
import { ContactsComponent } from '../contacts/contacts.component';
|
2025-07-17 22:21:04 -03:00
|
|
|
import { StorageService } from '../../core/services/common/storage.service';
|
|
|
|
|
import { NavigationService } from '../../core/services/common/navigation.service';
|
2025-07-17 13:56:18 -03:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-edit-holder',
|
|
|
|
|
imports: [AngularMaterialModule, CommonModule, BasicDetailComponent, ContactsComponent],
|
|
|
|
|
templateUrl: './edit-holder.component.html',
|
|
|
|
|
styleUrl: './edit-holder.component.scss'
|
|
|
|
|
})
|
|
|
|
|
export class EditHolderComponent {
|
|
|
|
|
accordion = viewChild.required(MatAccordion);
|
|
|
|
|
isEditMode = true;
|
|
|
|
|
holderid = 0;
|
|
|
|
|
holderName: string | null = null;
|
|
|
|
|
userPreferences: UserPreferences;
|
2025-07-17 22:21:04 -03:00
|
|
|
currentApplicationDetails: { headerid: number, applicationName: string } | null = null;
|
2025-07-17 13:56:18 -03:00
|
|
|
|
|
|
|
|
private route = inject(ActivatedRoute);
|
2025-07-17 22:21:04 -03:00
|
|
|
private navigationService = inject(NavigationService);
|
|
|
|
|
private storageService = inject(StorageService);
|
2025-07-17 13:56:18 -03:00
|
|
|
|
|
|
|
|
constructor(userPrefenceService: UserPreferencesService) {
|
|
|
|
|
this.userPreferences = userPrefenceService.getPreferences();
|
2025-07-17 22:21:04 -03:00
|
|
|
this.currentApplicationDetails = this.storageService.get<{ headerid: number, applicationName: string }>('currentapplication')
|
|
|
|
|
|
2025-07-17 13:56:18 -03:00
|
|
|
afterNextRender(() => {
|
|
|
|
|
this.accordion().openAll();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
const idParam = this.route.snapshot.paramMap.get('holderid');
|
|
|
|
|
this.holderid = idParam ? parseInt(idParam, 10) : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onHolderNameUpdate(event: string): void {
|
|
|
|
|
this.holderName = event;
|
|
|
|
|
}
|
2025-07-17 22:21:04 -03:00
|
|
|
|
|
|
|
|
goBackToCarnetApplication(): void {
|
|
|
|
|
this.storageService.removeItem('currentapplication')
|
|
|
|
|
this.navigationService.navigate(["edit-carnet", this.currentApplicationDetails?.headerid],
|
|
|
|
|
{
|
|
|
|
|
state: { isEditMode: true },
|
|
|
|
|
queryParams: {
|
|
|
|
|
applicationname: this.currentApplicationDetails?.applicationName,
|
|
|
|
|
return: 'holder'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2025-07-17 13:56:18 -03:00
|
|
|
}
|