last fix i hope

This commit is contained in:
2025-08-29 14:13:54 +03:00
parent 04f8e56d76
commit 12672fa0bf
5 changed files with 16 additions and 21 deletions

View File

@@ -32,7 +32,7 @@
<!-- Map View -->
@if (viewMode() === 'map') {
<app-candidates-map
[candidates]="applicationList()"
[candidates]="this.dataService.cachedApplicationList()"
[cities]="availableCities()">
</app-candidates-map>
}

View File

@@ -43,7 +43,6 @@ export class ApplicationListComponent implements OnInit {
snackBar = inject(MatSnackBar)
environment = environment;
applicationList = signal<any[]>([]);
searchTerm = signal('');
filterCity = signal('');
sortField = signal<string>('fullName');
@@ -52,7 +51,7 @@ export class ApplicationListComponent implements OnInit {
availableCities = signal<City[]>(CITY_LIST);
filteredList = computed(() => {
const apps = this.applicationList();
const apps = this.dataService.cachedApplicationList();
const term = this.searchTerm().toLowerCase();
const city = this.filterCity();
@@ -99,7 +98,7 @@ export class ApplicationListComponent implements OnInit {
constructor() {
effect(() => {
const data = this.applicationList();
const data = this.dataService.cachedApplicationList();
if (data.length === 0) {
this.ageChartData.set({ labels: [], datasets: [] });
@@ -183,27 +182,27 @@ export class ApplicationListComponent implements OnInit {
ngOnInit(): void {
this.dataService.loadCandidateList().subscribe(data => {
this.applicationList.set(data);
this.dataService.cachedApplicationList.set(data);
this.availableCities.set(this.getUniqueCities(data));
});
this.socketService.onCandidateRegistered().subscribe(newCandidate => {
this.applicationList.update(list => [newCandidate, ...list]);
this.availableCities.set(this.getUniqueCities(this.applicationList()));
this.dataService.cachedApplicationList.update(list => [newCandidate, ...list]);
this.availableCities.set(this.getUniqueCities(this.dataService.cachedApplicationList()));
});
this.socketService.onCandidateUpdated().subscribe(updatedCandidate => {
this.applicationList.update(list =>
this.dataService.cachedApplicationList.update(list =>
list.map(app => app.id === updatedCandidate.id ? updatedCandidate : app)
);
this.availableCities.set(this.getUniqueCities(this.applicationList()));
this.availableCities.set(this.getUniqueCities(this.dataService.cachedApplicationList()));
});
this.socketService.onCandidateDeleted().subscribe(deletedCandidateId => {
this.applicationList.update(list =>
this.dataService.cachedApplicationList.update(list =>
list.filter(app => app.id !== deletedCandidateId)
);
this.availableCities.set(this.getUniqueCities(this.applicationList()));
this.availableCities.set(this.getUniqueCities(this.dataService.cachedApplicationList()));
});
}

View File

@@ -18,7 +18,7 @@
<mat-icon>chevron_left</mat-icon>
</button>
<span class="navigation-info">
{{ currentIndex() + 1 }} of {{ applicationList().length }}
{{ currentIndex() + 1 }} of {{ this.dataService.cachedApplicationList().length }}
</span>
<button
mat-icon-button

View File

@@ -44,7 +44,6 @@ export class ApplicationComponent implements OnInit {
currentApplication = signal<any>(null);
applicationList = signal<any[]>([]);
currentIndex = signal<number>(-1);
environment = environment;
@@ -56,7 +55,7 @@ export class ApplicationComponent implements OnInit {
canGoToPrevious = computed(() => this.currentIndex() > 0);
canGoToNext = computed(() =>
this.currentIndex() >= 0 &&
this.currentIndex() < this.applicationList().length - 1
this.currentIndex() < this.dataService.cachedApplicationList().length - 1
);
canEdit = computed(() => {
@@ -70,13 +69,11 @@ export class ApplicationComponent implements OnInit {
ngOnInit(): void {
if (this.dataService.cachedApplicationList().length > 0) {
this.applicationList.set(this.dataService.cachedApplicationList());
this.initializeApplication();
return;
}
this.dataService.loadCandidateList().subscribe({
next: (data) => {
this.applicationList.set(data);
this.initializeApplication();
},
error: (error) => {
@@ -101,7 +98,7 @@ export class ApplicationComponent implements OnInit {
}
const applicationId = Number.parseInt(id, 10);
const foundIndex = this.applicationList().findIndex(app => app.id === applicationId);
const foundIndex = this.dataService.cachedApplicationList().findIndex(app => app.id === applicationId);
if (foundIndex === -1) {
alert('Application not found');
@@ -140,7 +137,7 @@ export class ApplicationComponent implements OnInit {
if (this.canGoToPrevious()) {
const newIndex = this.currentIndex() - 1;
this.currentIndex.set(newIndex);
const prevId = this.applicationList()[newIndex].id;
const prevId = this.dataService.cachedApplicationList()[newIndex].id;
this.loadApplication(prevId)?.subscribe();
}
}
@@ -149,7 +146,7 @@ export class ApplicationComponent implements OnInit {
if (this.canGoToNext()) {
const newIndex = this.currentIndex() + 1;
this.currentIndex.set(newIndex);
const nextId = this.applicationList()[newIndex].id;
const nextId = this.dataService.cachedApplicationList()[newIndex].id;
this.loadApplication(nextId)?.subscribe();
}
}

View File

@@ -13,7 +13,6 @@ export class SocketIOService {
onCandidateRegistered(): Observable<any> {
return new Observable(observer => {
this.socket.on('candidateRegistered', (data) => {
console.log(data);
observer.next(data);
});
});