add logic

This commit is contained in:
2026-10-07 17:32:25 +03:00
parent cdcdd22526
commit f86777e2cd
69 changed files with 1519 additions and 637 deletions
+25 -8
View File
@@ -3,8 +3,8 @@ import { MatProgressBar } from '@angular/material/progress-bar';
import { RouterLink } from '@angular/router';
import { Store } from '@ngrx/store';
import { CityCatalogService } from '../../root/services/city-catalog.service';
import { selectCollectedIdSet, selectOpenedCount, selectProgress } from '../../state';
import { areaOpenedCount, areaProgress, areaTotalCount, type Area, type Attraction } from '../../areas/area.models';
import { GorodarActions, selectAreas, selectAreasError, selectAreasStatus, selectCollectedIdSet } from '../../state';
@Component({
selector: 'app-cities-page',
@@ -14,13 +14,30 @@ import { selectCollectedIdSet, selectOpenedCount, selectProgress } from '../../s
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CitiesPage {
private readonly catalog = inject(CityCatalogService);
private readonly store = inject(Store);
protected readonly city = this.catalog.city;
protected readonly upcomingCities = ['Москва', 'Санкт-Петербург'];
protected readonly areas = this.store.selectSignal(selectAreas);
protected readonly status = this.store.selectSignal(selectAreasStatus);
protected readonly error = this.store.selectSignal(selectAreasError);
protected readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
protected readonly openedCount = this.store.selectSignal(selectOpenedCount);
protected readonly totalCount = this.city.objects.length;
protected readonly progress = this.store.selectSignal(selectProgress);
protected openedCount(area: Area): number {
return areaOpenedCount(area, this.collectedIds());
}
protected totalCount(area: Area): number {
return areaTotalCount(area);
}
protected progress(area: Area): number {
return areaProgress(area, this.collectedIds());
}
protected obtained(attraction: Attraction): boolean {
return attraction.visited || this.collectedIds().has(attraction.id);
}
protected reload(): void {
this.store.dispatch(GorodarActions.areasRequested());
}
}